xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Selva <selvakumar_...@yahoo.co.in>
Subject Mouse drag not working smoothly for Rectangle
Date Tue, 11 Apr 2006 04:29:32 GMT
Hi All,

I am trying to drag the Rectangle in SVGCanvas. If I do it slowly, it is 
working smoothly. But in case of faster dragging, it is not moving properly. I 
have also referred http://wiki.apache.org/xmlgraphics-batik/DragTutorial for 
mouse dragging. But it is not working. I have attached my sample code for your 
reference.

private class OnMoveAction implements EventListener {
    public void handleEvent(Event evt) {

       if (actionNode == null)return;
          dragged = true;
          DOMMouseEvent elEvt = (DOMMouseEvent)evt;

          int nowToX = elEvt.getClientX();
          int nowToY = elEvt.getClientY();
          SVGDocument svgDocument = svgCanvas.getSVGDocument();
          SVGPoint trans = svgDocument.getRootElement().getCurrentTranslate();
          float scale = svgDocument.getRootElement().getCurrentScale();
          nowToX = (int)((nowToX - trans.getX()) / scale);
          nowToY = (int)((nowToY - trans.getY()) / scale);
          if (action == DRAG) {
             ((Element)actionNode).setAttribute("x", "" + (nowToX - dx));
             ((Element)actionNode).setAttribute("y", "" + (nowToY - dy));
	} 
}


Please give me the better solution for dragging the SVG elements in SVGCanvas.

Thanks,
Selva



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message