Hi Thomas,

> You need to do the above for every group you want to apply the 
> move to.  The tricky bit being that you need to start point for 
> each group.  Probably it's best to remember the start point as it 
> came out of the event and then for each group call 'localPt' 
> with both the start and current points for each update. 

In MouseDownAction, I am storing all the selected elements initial position
in HashMap. Also I am storing the position of the element, which was
selected last in startPt.

startPt = localPt((Element)grpElement, elEvt.getClientX(),
elEvt.getClientY());
                   
SVGPoint tPoint = new SVGOMPoint(0, 0);
tPoint.setX(startPt.getX());
tPoint.setY(startPt.getY());

_startPoints.put(_current, tPoint);

In mouseMoveAction, here I am finding dx and dy value to perform transform
for selected group elements. Using this values last selected group element
is moving properly with mouse move. But other group elements are not. I
think I am doing mistake in calculating dx and dy in else part. So please
explain, how to calculate dx and dy value for remaining elements.

SVGPoint pt = localPt((Element)selElement.getParentNode(),
elEvt.getClientX(), elEvt.getClientY()); 
 
Element elements[] = getSelectedElements(); 
for (int i = 0; i < elements.length; i++) { 

    SVGPoint sPt = (SVGPoint)_startPoints.get(elements[i]);
    float dx = 0;
    float dy = 0;

   // _current used to store the element which was selected last.

    if (_current.equals(elements[i])) {
          dx = pt.getX();- sPt.getX();
          dy = pt.getY();- sPt.getY();
     } else {

         // problem in here in calculating dx and dy value

         int spX = pt.getX() - (int)startPt.getX();
         int spY = pt.getY() - (int)startPt.getY();
         dx = sPt.getX() + spX;
         dy = sPt.getY() + spY;
     }          
     elements[i].setAttribute("transform", "translate(" + dx + ", " + dy +
")");
} 


Thanks,
Sudhakar

--
View this message in context: 
http://www.nabble.com/Multiple-Group-Elements-Selection-and-Moving-t1799038.html#a4914471
Sent from the Batik - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to