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 Guillaume Pothier <gp...@free.fr> on 2003/09/20 15:58:31 UTC

GraphicsNode.getTransformedBounds ()

Hi!

I have a SVG document with its root <svg> tag, a few geometric objects, 
and a child <svg>, which in turn contains a few geometric objects. Once 
the GVT tree is built, I get the GraphicNode corresponding to one of the 
rectangles in the embedded svg node. If I call getTransformedBounds on 
it, it seems that I am getting its bounds within the embedded svg node, 
and not relative to the root svg node.
My question: should getTransformedBounds return the bounds relative to 
the root svg node, and should I try to find the error on my side, or is 
it normal for getTransformedBounds to return the bounds relative to the 
parent svg node, in which case, is there a method to obtain the bounds 
relative to the root svg element?
Thanks
Guillaume


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: GraphicsNode.getTransformedBounds ()

Posted by Thomas DeWeese <Th...@Kodak.com>.
Guillaume Pothier wrote:

> Thanks, getGlobalTransform made it.

Hi Guillaume,

   I would test this code on an element that has a 'transform' attribute.
I suspect that this code will apply the transform from the element
twice.  You probably need to use getGlobalTransform on the parent
GraphicsNode of theNode or concatenate the inverse of theNode's transform.

> Here is the code I use, in the case somebody is interested:
> AffineTransform theTransform = new 
> AffineTransform(SVGContentManager.TRANSFORM_96DPI);
>                 theTransform.concatenate(theNode.getGlobalTransform());
> Rectangle2D theBounds = theNode.getTransformedBounds(theTransform);
> 
> I get the bounds in mm, not pixels.

> Guillaume
> 
> Thomas DeWeese wrote:
> 
>> Guillaume Pothier wrote:
>>
>>> Hi!
>>>
>>> I have a SVG document with its root <svg> tag, a few geometric 
>>> objects, and a child <svg>, which in turn contains a few geometric 
>>> objects. Once the GVT tree is built, I get the GraphicNode 
>>> corresponding to one of the rectangles in the embedded svg node. If I 
>>> call getTransformedBounds on it, it seems that I am getting its 
>>> bounds within the embedded svg node, and not relative to the root svg 
>>> node.
>>
>>
>>
>>     getTransformedBounds returns the bounds in the coordinate system
>> defined by the affine you pass in, relative to the Node.  So what Affine
>> are you passing into the function?
>>
>>> My question: should getTransformedBounds return the bounds relative 
>>> to the root svg node, and should I try to find the error on my side, 
>>> or is it normal for getTransformedBounds to return the bounds 
>>> relative to the parent svg node, in which case, is there a method to 
>>> obtain the bounds relative to the root svg element?
>>
>>
>>
>>     It depends on what transform you pass in.  For the Identity Affine
>> it will return it's bounds in it's parent's coordinate system.  You might
>> want to look at getGlobalTransform() you probably need to use the
>> inverse of that affine and remove the transform, if any, from the element
>> it's self (getTransform()).
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: GraphicsNode.getTransformedBounds ()

Posted by Guillaume Pothier <gp...@free.fr>.
Thanks, getGlobalTransform made it.
Here is the code I use, in the case somebody is interested:
AffineTransform theTransform = new 
AffineTransform(SVGContentManager.TRANSFORM_96DPI);
				theTransform.concatenate(theNode.getGlobalTransform());
Rectangle2D theBounds = theNode.getTransformedBounds(theTransform);

I get the bounds in mm, not pixels.
Guillaume

Thomas DeWeese wrote:
> Guillaume Pothier wrote:
> 
>> Hi!
>>
>> I have a SVG document with its root <svg> tag, a few geometric 
>> objects, and a child <svg>, which in turn contains a few geometric 
>> objects. Once the GVT tree is built, I get the GraphicNode 
>> corresponding to one of the rectangles in the embedded svg node. If I 
>> call getTransformedBounds on it, it seems that I am getting its bounds 
>> within the embedded svg node, and not relative to the root svg node.
> 
> 
>     getTransformedBounds returns the bounds in the coordinate system
> defined by the affine you pass in, relative to the Node.  So what Affine
> are you passing into the function?
> 
>> My question: should getTransformedBounds return the bounds relative to 
>> the root svg node, and should I try to find the error on my side, or 
>> is it normal for getTransformedBounds to return the bounds relative to 
>> the parent svg node, in which case, is there a method to obtain the 
>> bounds relative to the root svg element?
> 
> 
>     It depends on what transform you pass in.  For the Identity Affine
> it will return it's bounds in it's parent's coordinate system.  You might
> want to look at getGlobalTransform() you probably need to use the
> inverse of that affine and remove the transform, if any, from the element
> it's self (getTransform()).
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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: GraphicsNode.getTransformedBounds ()

Posted by Thomas DeWeese <Th...@Kodak.com>.
Guillaume Pothier wrote:

> Hi!
> 
> I have a SVG document with its root <svg> tag, a few geometric objects, 
> and a child <svg>, which in turn contains a few geometric objects. Once 
> the GVT tree is built, I get the GraphicNode corresponding to one of the 
> rectangles in the embedded svg node. If I call getTransformedBounds on 
> it, it seems that I am getting its bounds within the embedded svg node, 
> and not relative to the root svg node.

     getTransformedBounds returns the bounds in the coordinate system
defined by the affine you pass in, relative to the Node.  So what Affine
are you passing into the function?

> My question: should getTransformedBounds return the bounds relative to 
> the root svg node, and should I try to find the error on my side, or is 
> it normal for getTransformedBounds to return the bounds relative to the 
> parent svg node, in which case, is there a method to obtain the bounds 
> relative to the root svg element?

     It depends on what transform you pass in.  For the Identity Affine
it will return it's bounds in it's parent's coordinate system.  You might
want to look at getGlobalTransform() you probably need to use the
inverse of that affine and remove the transform, if any, from the element
it's self (getTransform()).




---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org