Hi Dao,
dao <[email protected]> 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:[email protected]] 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.