hello,

thank you for the answers. unfortunatelly, the solution does not work. I
have attached a little code snippet to show the problem:

   - *MoveIssue.java* that shows the problem (needs batik in the classpath)
   - *rects.svg* to use with the code. svg file has to be right in the
   execution folder.


I am a little bit confused with those coord conversions, etc... I suppose
this is a piece of cake for you guys. Could you tell me what's wrong?

here is the code comment:
shows the move issue. The application opens a frame containing rect.svg
(which has to be in the execution folder)
rect.svg contains 3 rects.
You can click on the blue one, hold and move the mouse.
I want the 3 rectangles to move together, so that their relative position
does not change.

In convertCoord I have implemented the 2 solutions of the thread.

I can see that my solution does not work (as Thomas said) but the code of
Jonathan does not work neither (just switch the comments in the method for
the 2 implementations). *Furthermore, when you move the mouse, the rects
does not move smoothly and does not really follows the cursor*.




On Thu, Mar 11, 2010 at 2:01 PM, <thomas.dewe...@kodak.com> wrote:

> Hi Dao,
>
> dao <dao.ho...@gmail.com> wrote on 03/07/2010 03:36:08 PM:
>
> > mask.addEventListener("mousemove",
> >   new org.w3c.dom.events.EventListener() {
> [...]
> >           getCanvas().push(new AttributeUpdateTask(id, "transform",
> value));
>
>    You can change the transform attribute right here, since DOM/SVG
> Events are always delivered in the UpdateManager Thread.  BE CAREFUL
> however because, AWT/Swing events are _not_ delivered in the UpdateManager
> thread (they are delivered in the swing thread).
>
>
> > public static Point2D convert2CanvasCoord(int screenX, int screenY,
> >                                           AbstractJSVGComponent canvas)
> >                       throws NoninvertibleTransformException {
> >   Point2D doc = new Point(screenX, screenY);
> >   AffineTransform tr = canvas.getViewBoxTransform();
>
>    This won't work if the element (or any of it's ancestors)
> have transforms associated with them.
>
> > jonathan wood 
> > [mailto:jonathanshaww...@gmail.com<jonathanshaww...@gmail.com>]
> wrote:
>
> >> Point awtPoint = ...;
> >> Element myEl = document.getElementById("my-el");
> >> SVGPoint svgPoint = document.getRootElement.createSVGPoint();
> >> svgPoint.setX(awtPoint.getX());
> >> svgPoint.setY(awtPoint.getY());
> >> SVGMatrix m = ((SVGLocatable)myEl).getScreenCTM();
> >> m = m.inverse();
> >> svgPoint = svgPoint.matrixTransform(m);
>
>    This code will work regardless of transforms on the parents
> of the element.
>
>


-- 
Dao Hodac

<<attachment: rect.svg>>

Attachment: MoveIssue.java
Description: Binary data

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

Reply via email to