It's possible I believe, just not simple.  Someone who knows more might correct 
me on this.  It would be something like this:
 
// This is the element in question.
Element element;
 
SVGLocatable locatable = (SVGLocatable) element;
SVGMatrix matrix = locatable.getScreenCTM();
 
This is where I'm a little fuzzy.  I think you'd leave the matrix alone, but 
you might have to call inverse() on it.  What you're going for is a transform 
(matrix) that maps screen coordinates to element coordinates.  I think leaving 
it alone means that putting a document point through the matrix will transform 
it to a screen point.
 
>From that transform, you should be able to derive a scale value, but you may 
>need to remove rotate/skew/shear first in order to find the scale value.
 
Ultimately you want to query your element for its stroke-width and multiply it 
by the appropriate scale value.  See if that gets you anywhere.  I do something 
similar in order to properly draw bounding boxes around my elements.  I can 
provide some code if this is the path you're trying to go down.
 
Michael

________________________________

From: John C. Turnbull [mailto:[EMAIL PROTECTED]
Sent: Wed 10/15/2008 7:02 PM
To: batik-users@xmlgraphics.apache.org
Subject: Querying the canvas for on-screen details



Is it possible to determine the exact position and dimensions of an element on 
the screen after scaling has been applied from within a Java program?  For 
example, I may have a line of thickness 2 which is actually displayed as 8 
pixels wide on the screen when it is scaled.  I would like to be able to query 
the SVG canvas and get that value of 8 returned.

 

Thanks,

 

-JCT

<<winmail.dat>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to