Considering your use case, you may want to try a slightly different
approach.  You can bypass the AWTEvent capture and use the DOM Event
structure in SVG.

Check out http://www.w3.org/TR/SVG/interact.html with special attention to
pointer-events and event names.

// create a listener:

        EventListener myListener = new EventListener() {
            public void handleEvent(Event evt) {
                 String evtType = evt.getType();
                 if(evt.equals("mousemove")) {
                     ...
                 }
            }
        };

// attach the listener to the element:

((EventTarget) myEl).addEventListener("mousemove", myListener, false);


Keep in mind that you can then use SVGLocatable.getTransformToElement() if
you need to transform to another coord system within the document.




On Mon, Mar 1, 2010 at 6:41 AM, HODAC, Olivier <olivier.ho...@airbus.com>wrote:

>  OK, I’ll give it a try
>
>
>
> I thought I missed something, but it is not straightforward at all!
>
>
>
> Do you think it will be costfull if ran on each mouse move? I want that my
> user can click an element of the canvas and move it in a different location.
> And I want the canvas updated during the mousemove so that he can see the
> result in real time
>
>
>
> *De :* jonathan wood [mailto:jonathanshaww...@gmail.com]
> *Envoyé :* lundi 1 mars 2010 04:03
> *À :* batik-users@xmlgraphics.apache.org
> *Objet :* Re: coordinate conversion
>
>
>
>
> Most of what you need can be found in SVGLocatable.  The below is not
> tested, but should be close:
>
> 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);
>
>
> On Fri, Feb 26, 2010 at 8:34 AM, dao <dao.ho...@gmail.com> wrote:
>
> hello,
>
> Sorry for this stupid question: how do I transform coordinates from a AWT
> mouse event to the coordinates in the svg file the canvas represents?
>
> I mean, I have a panel with the canvas (rotated, zoomed, panned in the
> worst case) and I want to know the coordinates of the svg point my mouse
> cursor is pointing.
>
>
>
> --
> Dao Hodac
>
>
>
> This mail has originated outside your organization, either from an external 
> partner or the Global Internet.
>
> Keep this in mind if you answer this message.
>
>
>
> The information in this e-mail is confidential. The contents may not be 
> disclosed or used by anyone other than the addressee. Access to this e-mail 
> by anyone else is unauthorised.
> If you are not the intended recipient, please notify Airbus immediately and 
> delete this e-mail.
> Airbus cannot accept any responsibility for the accuracy or completeness of 
> this e-mail as it has been sent over public networks. If you have any 
> concerns over the content of this message or its Accuracy or Integrity, 
> please contact Airbus immediately.
> All outgoing e-mails from Airbus are checked using regularly updated virus 
> scanning software but you should take whatever measures you deem to be 
> appropriate to ensure that this message and any attachments are virus free.
>
>

Reply via email to