xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: Multiple Group Elements Selection and Moving
Date Tue, 20 Jun 2006 09:53:38 GMT
Hi Sudhakar,

Sudhakar S <yessudhakar@hotmail.com> wrote on 06/20/2006 04:15:52 AM:

> I think i did mistake in my explanation. while moving the mouse, last
> selected/clicked group element only should move with mouse cursor 
position.
> Others selected group elements also should move, but it should maintain 
the
> distance which has, while selecting the group elements. 

   Yes, I understood this.

> If i tried to implement as per your suggestion, since startX and startY 
is
> using the last selected elements position, all the selected elements are
> moving to last selected element's position and moving with mousemove.

    The code I provided calculates the 'delta' for each mouse move
in the parent coordinate system of each group and applies that to 
each group.  The 'absolute' position of start and current are 
irrelevant to the code only the change.   If this code works
for 'the last group' it should work for all of the groups.

    One comment, since the code totally replaces the transform on the
group if it had a pre-existing transform (say from a previous move)
at the start of the 'second' move it will snap back to it's initial
position.  To fix this you either need to remember the total
dx/dy from the last move (I often use attributes in a custom namespace
for this), or you need to 'move' the translation into something
else (sometimes I will use a 'use' element and I will use transform
to move the use, and then store result in 'x' and 'y' attributes).

    DOMMouseEvent mEvt = (DOMMouseEvent)evt;
    currX = mEvt.getClientX();
    currY = mEvt.getClientY();

    Iterator i = moveGroups.iterator();
    while (i.hasNext()) {
        Element e = (Element)i.next();
        Element p = (Element)e.getParentNode();
        SVGPoint sp = localPt(p, startX, startY);
        SVGPoint cp = localPt(p, currX,  currY);

        float dx = cp.getX()-sp.getX();
        float dy = cp.getY()-sp.getY();
        e.setAttributeNS(null, "transform",
                         "translate("+dx+","+dy+")");
    }


> 
> So can you please explain, how to move the selected group elements along
> with distance between the elements?
> 
> Thanks,
> Sudhakar
> --
> View this message in context: 
http://www.nabble.com/Multiple-Group-Elements-
> Selection-and-Moving-t1799038.html#a4951018
> Sent from the Batik - Users forum at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


---------------------------------------------------------------------
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