Hi Michael,

 

Thanks for the prompt reply.

 

Yes, I would like to have look at your code if you don't mind as drawing
bounding boxes around elements is precisely what I am trying to do!  I am
only just starting out with Batik and SVG in general so any help would be
warmly appreciated.

 

-JCT

 

From: Bishop, Michael W. CONTR J9C880 [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 16 October 2008 10:30
To: batik-users@xmlgraphics.apache.org
Subject: RE: Querying the canvas for on-screen details

 

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

<<attachment: winmail.dat>>

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

Reply via email to