You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Thomas DeWeese <Th...@Kodak.com> on 2003/08/14 22:31:56 UTC
Re: CurrentTranslate attribute
Andres Toussaint wrote:
> HI, i was wondering if there is an equivalent to the emacscript commands
> detailed following, within Batik Java:
>
> var trans = document.documentElement.currentTranslate;
> var scale = document.documentElement.currentScale;
>
> I cannot seem to find them. I am programming drag routines for SVG
> elements, and want to make them relative to the actual zoom and pan
> state. I have made this using emacscript but i want this inside the Java
> application instead of the SVG file.
Yes, there are equiv of the above from the Java Binding:
SVGDocument doc = ....;
SVGSVGElement root = doc.getRootElement();
float scale = root.getCurrentScale();
SVGPoint trans = root.getCurrentTranslate();
However what you probably want to use is:
SVGLocatable elem = ...;
SVGPoint pt = ...
SVGMatrix mat = elem.getScreenCTM(); // elem -> screen
mat = mat.inverse(); // screen -> elem
pt = pt.matrixTransform(pt); // from screen coords->elem
This should also be available in ECMA script (and is with Batik,
but isn't with ASV 3.0 - don't know about 6.0 - I suspect it has it).
This will deal with any intervening transforms (viewbox, transform, etc).
Elem can be just about any 'graphical' element (rect, g, svg, ...).
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: CurrentTranslate attribute
Posted by Thomas DeWeese <Th...@Kodak.com>.
Andres Toussaint wrote:
> What is this SVGPoint referencing:
> SVGPoint pt = ...
> Is it the click spot?
It's what ever you want, in this case probably the clientX/Y.
This is a general technique so it can be applied to any point in
the screen coordinate system.
>
> Thanks.
>
>>
>> SVGLocatable elem = ...;
>> SVGPoint pt = ...
>> SVGMatrix mat = elem.getScreenCTM(); // elem -> screen
>> mat = mat.inverse(); // screen -> elem
>> pt = pt.matrixTransform(pt); // from screen coords->elem
>>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: CurrentTranslate attribute
Posted by Andres Toussaint <an...@onemileup.com>.
What is this SVGPoint referencing:
SVGPoint pt = ...
Is it the click spot?
Thanks.
>
> SVGLocatable elem = ...;
> SVGPoint pt = ...
> SVGMatrix mat = elem.getScreenCTM(); // elem -> screen
> mat = mat.inverse(); // screen -> elem
> pt = pt.matrixTransform(pt); // from screen coords->elem
>
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: CurrentTranslate attribute
Posted by Andres Toussaint <an...@onemileup.com>.
Thomas, thanks again, you have been very kind. I had not considered
SVGLocatable and SVGMatrix since they lack proper description it was not
clear what their function was.
I have succesfully accomplished the drag with getCurrentScale(), and
will try with the SVGMatrix, since it does seem like a cleaner solution,
and I hope it gives a smother drag effect.
Andres.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org