Kristian Spangsege
2005-01-26 10:48:50 UTC
Hi
According to the SVG conformance page, the following method is supported
by Batik:
SVGTextElement.getComputedTextLength()
Yet I have problems with it.
I would appreciate if someone could point out for me what I'm doing wrong.
I'm using Batik 1.5.1.
The Code:
----------------------------------------------------------------------
import org.w3c.dom.svg.*;
import org.apache.batik.dom.*;
import org.apache.batik.dom.svg.*;
public class Test
{
public static void main(String[] args)
{
SVGOMDocument doc =
(SVGOMDocument)SVGDOMImplementation.getDOMImplementation().createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI,
"svg", null);
SVGTextElement text =
(SVGTextElement)doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
"text");
text.appendChild(doc.createTextNode("foo"));
System.err.println(text.getComputedTextLength());
}
}
----------------------------------------------------------------------
I get this error:
----------------------------------------------------------------------
Exception in thread "main" java.lang.NullPointerException
at
org.apache.batik.dom.svg.SVGTextContentSupport.getComputedTextLength(Unknown
Source)
at
org.apache.batik.dom.svg.SVGOMTextContentElement.getComputedTextLength(Unknown
Source)
at Test.main(Test.java:14)
----------------------------------------------------------------------
Regards and thanks in advance,
Kristian Spangsege
According to the SVG conformance page, the following method is supported
by Batik:
SVGTextElement.getComputedTextLength()
Yet I have problems with it.
I would appreciate if someone could point out for me what I'm doing wrong.
I'm using Batik 1.5.1.
The Code:
----------------------------------------------------------------------
import org.w3c.dom.svg.*;
import org.apache.batik.dom.*;
import org.apache.batik.dom.svg.*;
public class Test
{
public static void main(String[] args)
{
SVGOMDocument doc =
(SVGOMDocument)SVGDOMImplementation.getDOMImplementation().createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI,
"svg", null);
SVGTextElement text =
(SVGTextElement)doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,
"text");
text.appendChild(doc.createTextNode("foo"));
System.err.println(text.getComputedTextLength());
}
}
----------------------------------------------------------------------
I get this error:
----------------------------------------------------------------------
Exception in thread "main" java.lang.NullPointerException
at
org.apache.batik.dom.svg.SVGTextContentSupport.getComputedTextLength(Unknown
Source)
at
org.apache.batik.dom.svg.SVGOMTextContentElement.getComputedTextLength(Unknown
Source)
at Test.main(Test.java:14)
----------------------------------------------------------------------
Regards and thanks in advance,
Kristian Spangsege