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 Charles Abreu <ch...@gmail.com> on 2006/07/19 21:17:47 UTC

Getting screen coordinates of a SVGUseElement

I've been successfully calling bridgeContex.getGraphicsNode(element) to get
the graphics node of an element and next obtaining its screen coordinates,
as somebody told me how to do it (thanks!). But when I've tried the same
with <use> elements, I always got the coordiantes of the referenced <symbol>
tag, even if I override them in the <use> tag. How can I get the coordinates
from the cloned <use> element instead?

Thanks in advance,
Charles

Re: Getting screen coordinates of a SVGUseElement

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

"Charles Abreu" <ch...@gmail.com> wrote on 07/21/2006 07:23:53 AM:

> I'm calling document.getElementById("useId"), where "useId" is the id 
defined 
> in the use element, not the id in symbol element. Any idea?

   I think I understand the problem.  Unlike say a 'rect'
element the 'use' element establishes a new user coordinate
system based on it's x,y,width/height attributes.  Since
getBBox is always returned in the local user coordinate
system it may appear that you are getting the bounds of
the symbol element.

   What you appear to want is the bounds of the use element
in it's parent's coordinate system.  In which case you
will want/need to get the transform from the use to it's parent
and apply that transform to the bounds returned by
'getBBox' (which is really preferred over getting the bounds
from the graphics node).

> On 7/19/06, Andreas Neumann <ne...@karto.baug.ethz.ch> wrote:
> Hi Charles,
> 
> how did you get the reference to the graphics node?
> 
> with evt. target?
> 
> if yes, you have to be aware that with use elements you get a reference
> to the original element (in your case it seems to be a symbol tag). You 
> can use evt.currentTarget instead to get a reference to the <use/>
> element, but you have to set the event handler attribute directly on the
> use element. It doesn't work if you put it on the parent group.
> 
> Andreas
> 
> Charles Abreu wrote:
> 
> > I've been successfully calling bridgeContex.getGraphicsNode(element)
> > to get the graphics node of an element and next obtaining its screen
> > coordinates, as somebody told me how to do it (thanks!). But when I've 

> > tried the same with <use> elements, I always got the coordiantes of
> > the referenced <symbol> tag, even if I override them in the <use> tag.
> > How can I get the coordinates from the cloned <use> element instead? 
> >
> > Thanks in advance,
> > Charles
> 
> 
> 
> --
> ----------------------------------------------
> Andreas Neumann
> Institute of Cartography
> ETH Zurich
> Wolfgang-Paulistrasse 15
> CH-8093  Zurich, Switzerland 
> 
> Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
> e-mail: neumann@karto.baug.ethz.ch
> www: http://www.carto.net/neumann/ 
> SVG.Open: http://www.svgopen.org/
> Carto.net: http://www.carto.net/
> 
> 
> --------------------------------------------------------------------- 
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


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


Re: Getting screen coordinates of a SVGUseElement

Posted by Charles Abreu <ch...@gmail.com>.
Andreas,

I'm calling document.getElementById("useId"), where "useId" is the id
defined in the use element, not the id in symbol element. Any idea?

Charles

On 7/19/06, Andreas Neumann <ne...@karto.baug.ethz.ch> wrote:
>
> Hi Charles,
>
> how did you get the reference to the graphics node?
>
> with evt. target?
>
> if yes, you have to be aware that with use elements you get a reference
> to the original element (in your case it seems to be a symbol tag). You
> can use evt.currentTarget instead to get a reference to the <use/>
> element, but you have to set the event handler attribute directly on the
> use element. It doesn't work if you put it on the parent group.
>
> Andreas
>
> Charles Abreu wrote:
>
> > I've been successfully calling bridgeContex.getGraphicsNode(element)
> > to get the graphics node of an element and next obtaining its screen
> > coordinates, as somebody told me how to do it (thanks!). But when I've
> > tried the same with <use> elements, I always got the coordiantes of
> > the referenced <symbol> tag, even if I override them in the <use> tag.
> > How can I get the coordinates from the cloned <use> element instead?
> >
> > Thanks in advance,
> > Charles
>
>
>
> --
> ----------------------------------------------
> Andreas Neumann
> Institute of Cartography
> ETH Zurich
> Wolfgang-Paulistrasse 15
> CH-8093  Zurich, Switzerland
>
> Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
> e-mail: neumann@karto.baug.ethz.ch
> www: http://www.carto.net/neumann/
> SVG.Open: http://www.svgopen.org/
> Carto.net: http://www.carto.net/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>

Re: Getting screen coordinates of a SVGUseElement

Posted by Andreas Neumann <ne...@karto.baug.ethz.ch>.
Hi Charles,

how did you get the reference to the graphics node?

with evt. target?

if yes, you have to be aware that with use elements you get a reference 
to the original element (in your case it seems to be a symbol tag). You 
can use evt.currentTarget instead to get a reference to the <use/> 
element, but you have to set the event handler attribute directly on the 
use element. It doesn't work if you put it on the parent group.

Andreas

Charles Abreu wrote:

> I've been successfully calling bridgeContex.getGraphicsNode(element) 
> to get the graphics node of an element and next obtaining its screen 
> coordinates, as somebody told me how to do it (thanks!). But when I've 
> tried the same with <use> elements, I always got the coordiantes of 
> the referenced <symbol> tag, even if I override them in the <use> tag. 
> How can I get the coordinates from the cloned <use> element instead?
>
> Thanks in advance,
> Charles



-- 
----------------------------------------------
Andreas Neumann
Institute of Cartography
ETH Zurich
Wolfgang-Paulistrasse 15
CH-8093  Zurich, Switzerland

Phone: ++41-44-633 3031, Fax: ++41-44-633 1153
e-mail: neumann@karto.baug.ethz.ch
www: http://www.carto.net/neumann/
SVG.Open: http://www.svgopen.org/
Carto.net: http://www.carto.net/


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