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 ananth balasubramanyam <ab...@cs.odu.edu> on 2004/02/19 15:53:39 UTC

SVGOMTextElement

Hi,

I have an SVGDocument created from a SVG file. I am trying to
find all the <text> elements and determine their text length and other
properties. Here is my code and it does not seem to work. Am i doing
something wrong :

NodeList textElements = doc.getElementsByTagName("text");
for (int i=0 ; i < textElements.getLength() ; ++i) {
  SVGOMTextElement textElement = (SVGOMTextElement) textElements.item(i);
  SVGOMRect rect = (SVGOMRect) textElement.getBBox();
  System.out.println(rect.getHeight());
  System.out.println(rect.getWidth());
}

thanks in advance,
Ananth

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


Re: SVGOMTextElement

Posted by Thomas DeWeese <Th...@Kodak.com>.
ananth balasubramanyam wrote:

> Hi,
> 
> I have an SVGDocument created from a SVG file. I am trying to
> find all the <text> elements and determine their text length and other
> properties. Here is my code and it does not seem to work. Am i doing
> something wrong :
> 
> NodeList textElements = doc.getElementsByTagName("text");

   use getElementsByTagNameNS("http://www.w3.org/2000/svg", "text");

   Otherwise you are asking for text elements in the 'no name'
namespace.

> for (int i=0 ; i < textElements.getLength() ; ++i) {
>   SVGOMTextElement textElement = (SVGOMTextElement) textElements.item(i);
>   SVGOMRect rect = (SVGOMRect) textElement.getBBox();
>   System.out.println(rect.getHeight());
>   System.out.println(rect.getWidth());
> }

    I will also mention that you can only get the BBOX if the
associated 'rendering tree' for the elements has been constructed
See: batik.bridge.GVTBuilder.


> 
> thanks in advance,
> Ananth
> 
> ---------------------------------------------------------------------
> 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