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 Julien Beghin <mi...@hotmail.com> on 2010/05/19 16:14:59 UTC

Getting a bounded box


Hi there,
 
We are dealing with a matter of bounded box :
 
First of all, we are defining a link  via the "use" tag like following : 
 

<use transform="translate(180,-325)" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#6b0e597d-917e-4534-bb96-178a151a146c" xlink:type="simple" xlink:actuate="onLoad" id="INSTANCE_6b0e597d-917e-4534-bb96-178a151a146c" xlink:show="embed" pointer-events="stroke"/>
 
This link points towrds a group in the definition part : 
 

<g id="6b0e597d-917e-4534-bb96-178a151a146c" cursor="pointer" transform="scale(1.00,-1.00)" stroke-linejoin="round" stroke-linecap="round">

<desc>0LHT026VE</desc>
<text style="text-anchor:middle;font-size:2.50000pt;font-family:monotxt" transform="translate(0.00000,-2.50000) scale(1,-1) rotate(-0.00000) scale(1.00000,1)">
<tspan dx="0" dy="2.5" fill="rgb(0,0,0)" x="0" xml:space="preserve" stroke="rgb(0,0,0)">026VE</tspan>
</text>
<path fill="none" d="M -2.5 -1.5 L -2.5 1.5 L 2.5 -1.5 L 2.5 1.5" stroke-dasharray="1.00000,1.00000" stroke-width="0.600000" stroke="rgb(0,0,0)"/>
<path fill="none" stroke-width="0.800000" stroke-dasharray="1.00000,1.00000" d="M -2.9 1.25 A 0.4 0.4 0.0 1 1 -2.1 1.25 A 0.4 0.4 0.0 1 1 -2.9 1.25" stroke="rgb(0,0,0)"/>
</g>
 
What we are wanting to do is to get the bounded box of the text element, in this group.
There is no problem with getting the bounded box of the whole group, but curiously, I can't find a way to only the "text"'s bounded box
 
Can someone help ?
 
Regards, 
 
Julien  		 	   		  
_________________________________________________________________
Découvrez Windows Phone 7 : Une nouvelle ère de téléphones !
http://www.microsoft.com/windowsmobile/fr-fr/cmpn1/windowsphone7series/default.mspx

Re: Getting a bounded box

Posted by Martin Jacobson <ja...@gmail.com>.
I put an id on every element, so I'd do a getElementById(...), but
however you get the element, let's call it  "textElement"...

SVGRect bb = ((SVGOMTextElement) textElement).getBBox();

gets the bounding box.

HTH
Martin

On 19 May 2010 15:14, Julien Beghin <mi...@hotmail.com> wrote:
> Hi there,
>
>
>
> We are dealing with a matter of bounded box :
>
>
>
> First of all, we are defining a link  via the "use" tag like following :
>
>
>
> <use transform="translate(180,-325)"
> xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="#6b0e597d-917e-4534-bb96-178a151a146c" xlink:type="simple"
> xlink:actuate="onLoad" id="INSTANCE_6b0e597d-917e-4534-bb96-178a151a146c"
> xlink:show="embed" pointer-events="stroke"/>
>
>
>
> This link points towrds a group in the definition part :
>
>
>
> <g id="6b0e597d-917e-4534-bb96-178a151a146c" cursor="pointer"
> transform="scale(1.00,-1.00)" stroke-linejoin="round"
> stroke-linecap="round">
>
> <desc>0LHT026VE</desc>
>
> <text style="text-anchor:middle;font-size:2.50000pt;font-family:monotxt"
> transform="translate(0.00000,-2.50000) scale(1,-1) rotate(-0.00000)
> scale(1.00000,1)">
>
> <tspan dx="0" dy="2.5" fill="rgb(0,0,0)" x="0" xml:space="preserve"
> stroke="rgb(0,0,0)">026VE</tspan>
>
> </text>
>
> <path fill="none" d="M -2.5 -1.5 L -2.5 1.5 L 2.5 -1.5 L 2.5 1.5"
> stroke-dasharray="1.00000,1.00000" stroke-width="0.600000"
> stroke="rgb(0,0,0)"/>
>
> <path fill="none" stroke-width="0.800000" stroke-dasharray="1.00000,1.00000"
> d="M -2.9 1.25 A 0.4 0.4 0.0 1 1 -2.1 1.25 A 0.4 0.4 0.0 1 1 -2.9 1.25"
> stroke="rgb(0,0,0)"/>
>
> </g>
>
>
>
> What we are wanting to do is to get the bounded box of the text element, in
> this group.
>
> There is no problem with getting the bounded box of the whole group, but
> curiously, I can't find a way to only the "text"'s bounded box
>
>
>
> Can someone help ?
>
>
>
> Regards,
>
>
>
> Julien
>
> ________________________________
> De nouvelles Emoticones sur Messenger ? Téléchargez les Emoticones pâte à
> modeler !



-- 
>From my MacBook Pro

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


Re: Getting a bounded box

Posted by jonathan wood <jo...@gmail.com>.
Are you calling the method while in the update thread?  If I recall
correctly, it may be required be required

If needed, wrapper with something like:

getUpdateManager().getUpdateRunnableQueue().invokeLater(new Runnable() {
    public void run() {
           ....get bbox
    }
});


On Wed, May 19, 2010 at 11:37 AM, Julien Beghin <mi...@hotmail.com>wrote:

>  Well both of the solutions seem's to do "nothing" ....
>
> The getBBox method always return null, maybe because the tesxt element is
> location under the group tag (G) and in the définition part,
> The text is not under a use tag...
>
> Any other idea ?
>
> ------------------------------
> From: jonathanshawwood@gmail.com
> Date: Wed, 19 May 2010 11:24:11 -0400
> Subject: Re: Getting a bounded box
> To: batik-users@xmlgraphics.apache.org
>
>
> I've always used:
>
> SVGRedt bbox = ((SVGLocatable)element).getBBox();
>
> you may need to account for the transforms also....use
> SVGLocatable.getTransformToElement() and SVGPoint.matrixTransform() if
> needed
>
>
>
>
>
> On Wed, May 19, 2010 at 10:14 AM, Julien Beghin <mi...@hotmail.com>wrote:
>
>  Hi there,
>
>
>
> We are dealing with a matter of bounded box :
>
>
>
> First of all, we are defining a link  via the "use" tag like following :
>
>
>
> <use transform="translate(180,-325)" xmlns:xlink="
> http://www.w3.org/1999/xlink"
> xlink:href="#6b0e597d-917e-4534-bb96-178a151a146c" xlink:type="simple"
> xlink:actuate="onLoad" id="INSTANCE_6b0e597d-917e-4534-bb96-178a151a146c"
> xlink:show="embed" pointer-events="stroke"/>
>
>
>
> This link points towrds a group in the definition part :
>
>
>
> <g id="6b0e597d-917e-4534-bb96-178a151a146c" cursor="pointer"
> transform="scale(1.00,-1.00)" stroke-linejoin="round"
> stroke-linecap="round">
>
> <desc>0LHT026VE</desc>
>
> <text style="text-anchor:middle;font-size:2.50000pt;font-family:monotxt"
> transform="translate(0.00000,-2.50000) scale(1,-1) rotate(-0.00000)
> scale(1.00000,1)">
>
> <tspan dx="0" dy="2.5" fill="rgb(0,0,0)" x="0" xml:space="preserve"
> stroke="rgb(0,0,0)">026VE</tspan>
>
> </text>
>
> <path fill="none" d="M -2.5 -1.5 L -2.5 1.5 L 2.5 -1.5 L 2.5 1.5"
> stroke-dasharray="1.00000,1.00000" stroke-width="0.600000"
> stroke="rgb(0,0,0)"/>
>
> <path fill="none" stroke-width="0.800000"
> stroke-dasharray="1.00000,1.00000" d="M -2.9 1.25 A 0.4 0.4 0.0 1 1 -2.1
> 1.25 A 0.4 0.4 0.0 1 1 -2.9 1.25" stroke="rgb(0,0,0)"/>
>
> </g>
>
>
>
> What we are wanting to do is to get the bounded box of the text element, in
> this group.
>
> There is no problem with getting the bounded box of the whole group, but
> curiously, I can't find a way to only the "text"'s bounded box
>
>
>
> Can someone help ?
>
>
>
> Regards,
>
>
>
> Julien
>
> ------------------------------
> De nouvelles Emoticones sur Messenger ? Téléchargez les Emoticones pâte à
> modeler !<http://www.ilovemessenger.fr/emoticones/emoticones-pate-a-modeler.aspx>
>
>
>
> ------------------------------
> Envie de plus d'originalité dans vos conversations ? Téléchargez
> gratuitement les Emoch'ticones !<http://www.ilovemessenger.fr/emoticones/telecharger-emoticones-emochticones.aspx>
>

RE: Getting a bounded box

Posted by th...@kodak.com.
Hi Julien,

Thomas DeWeese | CDG Advanced Development | 
Eastman Kodak Company | 343 State Street | Rochester, NY 14650-0128 | 
Thomas.DeWeese@Kodak.com | 585 724-0294 | 
www.kodak.com 

Julien Beghin <mi...@hotmail.com> wrote on 05/19/2010 11:37:19 AM:

> The getBBox method always return null, maybe because the tesxt 
> element is location under the group tag (G) and in the définition part,
> The text is not under a use tag...

    Spot on, elements in the defs section do not have an associated
GraphicsNode, so there is no bounds to provide.  The main issue here
is that when an element is 'use'd it actually get's it's CSS properties
from the use element, so important things like font-size and font-family 
could be different. 

> Any other idea ? 

        You need to copy/put the text element into part of the rendering
tree (probably with visibility=hidden).

> From: jonathanshawwood@gmail.com
> Date: Wed, 19 May 2010 11:24:11 -0400
> Subject: Re: Getting a bounded box
> To: batik-users@xmlgraphics.apache.org
> 
> 
> I've always used:
> 
> SVGRedt bbox = ((SVGLocatable)element).getBBox();
> 
> you may need to account for the transforms also....use 
> SVGLocatable.getTransformToElement() and SVGPoint.matrixTransform() if 
needed
> 
> 
> 
> 

> On Wed, May 19, 2010 at 10:14 AM, Julien Beghin <minimoi1234@hotmail.com
> > wrote:
> Hi there,
> 
> We are dealing with a matter of bounded box :
> 
> First of all, we are defining a link  via the "use" tag like following : 

> 
> <use transform="translate(180,-325)" xmlns:xlink="
http://www.w3.org/1999/xlink
> " xlink:href="#6b0e597d-917e-4534-bb96-178a151a146c" 
> xlink:type="simple" xlink:actuate="onLoad" 
> id="INSTANCE_6b0e597d-917e-4534-bb96-178a151a146c" 
> xlink:show="embed" pointer-events="stroke"/>
> 
> This link points towrds a group in the definition part : 
> 
> <g id="6b0e597d-917e-4534-bb96-178a151a146c" cursor="pointer" 
> transform="scale(1.00,-1.00)" stroke-linejoin="round" 
stroke-linecap="round">
> <desc>0LHT026VE</desc>
> <text style="text-anchor:middle;font-size:2.50000pt;font-
> family:monotxt" transform="translate(0.00000,-2.50000) scale(1,-1) 
> rotate(-0.00000) scale(1.00000,1)">
> <tspan dx="0" dy="2.5" fill="rgb(0,0,0)" x="0" xml:space="preserve" 
> stroke="rgb(0,0,0)">026VE</tspan>
> </text>
> <path fill="none" d="M -2.5 -1.5 L -2.5 1.5 L 2.5 -1.5 L 2.5 1.5" 
> stroke-dasharray="1.00000,1.00000" stroke-width="0.600000" 
> stroke="rgb(0,0,0)"/>
> <path fill="none" stroke-width="0.800000" stroke-dasharray="1.00000,
> 1.00000" d="M -2.9 1.25 A 0.4 0.4 0.0 1 1 -2.1 1.25 A 0.4 0.4 0.0 1 
> 1 -2.9 1.25" stroke="rgb(0,0,0)"/>
> </g>
> 
> What we are wanting to do is to get the bounded box of the text 
> element, in this group.
> There is no problem with getting the bounded box of the whole group,
> but curiously, I can't find a way to only the "text"'s bounded box
> 
> Can someone help ?
> 
> Regards, 
> 
> Julien 
> 
> De nouvelles Emoticones sur Messenger ? Téléchargez les Emoticones 
> pâte à modeler !
> 
> 
> Envie de plus d'originalité dans vos conversations ? Téléchargez 
> gratuitement les Emoch'ticones !

RE: Getting a bounded box

Posted by Julien Beghin <mi...@hotmail.com>.
Well both of the solutions seem's to do "nothing" ....

 

The getBBox method always return null, maybe because the tesxt element is location under the group tag (G) and in the définition part,

The text is not under a use tag...

 

Any other idea ? 
 


From: jonathanshawwood@gmail.com
Date: Wed, 19 May 2010 11:24:11 -0400
Subject: Re: Getting a bounded box
To: batik-users@xmlgraphics.apache.org


I've always used:

SVGRedt bbox = ((SVGLocatable)element).getBBox();

you may need to account for the transforms also....use SVGLocatable.getTransformToElement() and SVGPoint.matrixTransform() if needed






On Wed, May 19, 2010 at 10:14 AM, Julien Beghin <mi...@hotmail.com> wrote:



Hi there,
 
We are dealing with a matter of bounded box :
 
First of all, we are defining a link  via the "use" tag like following : 
 

<use transform="translate(180,-325)" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#6b0e597d-917e-4534-bb96-178a151a146c" xlink:type="simple" xlink:actuate="onLoad" id="INSTANCE_6b0e597d-917e-4534-bb96-178a151a146c" xlink:show="embed" pointer-events="stroke"/>
 
This link points towrds a group in the definition part : 
 

<g id="6b0e597d-917e-4534-bb96-178a151a146c" cursor="pointer" transform="scale(1.00,-1.00)" stroke-linejoin="round" stroke-linecap="round">

<desc>0LHT026VE</desc>
<text style="text-anchor:middle;font-size:2.50000pt;font-family:monotxt" transform="translate(0.00000,-2.50000) scale(1,-1) rotate(-0.00000) scale(1.00000,1)">
<tspan dx="0" dy="2.5" fill="rgb(0,0,0)" x="0" xml:space="preserve" stroke="rgb(0,0,0)">026VE</tspan>
</text>
<path fill="none" d="M -2.5 -1.5 L -2.5 1.5 L 2.5 -1.5 L 2.5 1.5" stroke-dasharray="1.00000,1.00000" stroke-width="0.600000" stroke="rgb(0,0,0)"/>
<path fill="none" stroke-width="0.800000" stroke-dasharray="1.00000,1.00000" d="M -2.9 1.25 A 0.4 0.4 0.0 1 1 -2.1 1.25 A 0.4 0.4 0.0 1 1 -2.9 1.25" stroke="rgb(0,0,0)"/>
</g>
 
What we are wanting to do is to get the bounded box of the text element, in this group.
There is no problem with getting the bounded box of the whole group, but curiously, I can't find a way to only the "text"'s bounded box
 
Can someone help ?
 
Regards, 
 
Julien 


De nouvelles Emoticones sur Messenger ? Téléchargez les Emoticones pâte à modeler !
 		 	   		  
_________________________________________________________________
Vous voulez regarder la TV directement depuis votre PC ? C'est très simple avec Windows 7
http://clk.atdmt.com/FRM/go/229960614/direct/01/

RE: Getting a bounded box

Posted by Julien Beghin <mi...@hotmail.com>.
Thanks for the tips !

 

Going to try this method... never thought of that !


Martin : The following method returns null : SVGRect bb = ((SVGOMTextElement) textElement).getBBox();

 


From: jonathanshawwood@gmail.com
Date: Wed, 19 May 2010 11:24:11 -0400
Subject: Re: Getting a bounded box
To: batik-users@xmlgraphics.apache.org


I've always used:

SVGRedt bbox = ((SVGLocatable)element).getBBox();

you may need to account for the transforms also....use SVGLocatable.getTransformToElement() and SVGPoint.matrixTransform() if needed






On Wed, May 19, 2010 at 10:14 AM, Julien Beghin <mi...@hotmail.com> wrote:



Hi there,
 
We are dealing with a matter of bounded box :
 
First of all, we are defining a link  via the "use" tag like following : 
 

<use transform="translate(180,-325)" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#6b0e597d-917e-4534-bb96-178a151a146c" xlink:type="simple" xlink:actuate="onLoad" id="INSTANCE_6b0e597d-917e-4534-bb96-178a151a146c" xlink:show="embed" pointer-events="stroke"/>
 
This link points towrds a group in the definition part : 
 

<g id="6b0e597d-917e-4534-bb96-178a151a146c" cursor="pointer" transform="scale(1.00,-1.00)" stroke-linejoin="round" stroke-linecap="round">

<desc>0LHT026VE</desc>
<text style="text-anchor:middle;font-size:2.50000pt;font-family:monotxt" transform="translate(0.00000,-2.50000) scale(1,-1) rotate(-0.00000) scale(1.00000,1)">
<tspan dx="0" dy="2.5" fill="rgb(0,0,0)" x="0" xml:space="preserve" stroke="rgb(0,0,0)">026VE</tspan>
</text>
<path fill="none" d="M -2.5 -1.5 L -2.5 1.5 L 2.5 -1.5 L 2.5 1.5" stroke-dasharray="1.00000,1.00000" stroke-width="0.600000" stroke="rgb(0,0,0)"/>
<path fill="none" stroke-width="0.800000" stroke-dasharray="1.00000,1.00000" d="M -2.9 1.25 A 0.4 0.4 0.0 1 1 -2.1 1.25 A 0.4 0.4 0.0 1 1 -2.9 1.25" stroke="rgb(0,0,0)"/>
</g>
 
What we are wanting to do is to get the bounded box of the text element, in this group.
There is no problem with getting the bounded box of the whole group, but curiously, I can't find a way to only the "text"'s bounded box
 
Can someone help ?
 
Regards, 
 
Julien 


De nouvelles Emoticones sur Messenger ? Téléchargez les Emoticones pâte à modeler !
 		 	   		  
_________________________________________________________________
Hotmail : Simple et Efficace qui vous facilite la vie… Découvrez la NOW génération !
http://www.windowslive.fr/hotmail/nowgeneration/

Re: Getting a bounded box

Posted by jonathan wood <jo...@gmail.com>.
I've always used:

SVGRedt bbox = ((SVGLocatable)element).getBBox();

you may need to account for the transforms also....use
SVGLocatable.getTransformToElement() and SVGPoint.matrixTransform() if
needed





On Wed, May 19, 2010 at 10:14 AM, Julien Beghin <mi...@hotmail.com>wrote:

>  Hi there,
>
>
>
> We are dealing with a matter of bounded box :
>
>
>
> First of all, we are defining a link  via the "use" tag like following :
>
>
>
> <use transform="translate(180,-325)" xmlns:xlink="
> http://www.w3.org/1999/xlink"
> xlink:href="#6b0e597d-917e-4534-bb96-178a151a146c" xlink:type="simple"
> xlink:actuate="onLoad" id="INSTANCE_6b0e597d-917e-4534-bb96-178a151a146c"
> xlink:show="embed" pointer-events="stroke"/>
>
>
>
> This link points towrds a group in the definition part :
>
>
>
> <g id="6b0e597d-917e-4534-bb96-178a151a146c" cursor="pointer"
> transform="scale(1.00,-1.00)" stroke-linejoin="round"
> stroke-linecap="round">
>
> <desc>0LHT026VE</desc>
>
> <text style="text-anchor:middle;font-size:2.50000pt;font-family:monotxt"
> transform="translate(0.00000,-2.50000) scale(1,-1) rotate(-0.00000)
> scale(1.00000,1)">
>
> <tspan dx="0" dy="2.5" fill="rgb(0,0,0)" x="0" xml:space="preserve"
> stroke="rgb(0,0,0)">026VE</tspan>
>
> </text>
>
> <path fill="none" d="M -2.5 -1.5 L -2.5 1.5 L 2.5 -1.5 L 2.5 1.5"
> stroke-dasharray="1.00000,1.00000" stroke-width="0.600000"
> stroke="rgb(0,0,0)"/>
>
> <path fill="none" stroke-width="0.800000"
> stroke-dasharray="1.00000,1.00000" d="M -2.9 1.25 A 0.4 0.4 0.0 1 1 -2.1
> 1.25 A 0.4 0.4 0.0 1 1 -2.9 1.25" stroke="rgb(0,0,0)"/>
>
> </g>
>
>
>
> What we are wanting to do is to get the bounded box of the text element, in
> this group.
>
> There is no problem with getting the bounded box of the whole group, but
> curiously, I can't find a way to only the "text"'s bounded box
>
>
>
> Can someone help ?
>
>
>
> Regards,
>
>
>
> Julien
>
> ------------------------------
> De nouvelles Emoticones sur Messenger ? Téléchargez les Emoticones pâte à
> modeler !<http://www.ilovemessenger.fr/emoticones/emoticones-pate-a-modeler.aspx>
>