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 Alberto Gobbi <ag...@anadyspharma.com> on 2003/07/29 22:47:44 UTC
setPrecission missing in SVGGeneratorContext.createDefault
Hi,
I have started to use batik it is a great tool!!!
I ran into a nullpointer exception in SVGGeneratorContext.doubleString with simple code like:
public void createSVG(OutputStream out) throws IOException
{ // Get a DOMImplementation
DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
// Create an instance of org.w3c.dom.Document
Document document = domImpl.createDocument(null, "svg", null);
// Create an instance of the SVG Generator
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
//svgGenerator.getGeneratorContext().setPrecision(4);
draw(svgGenerator);
svgGenerator.stream(new OutputStreamWriter(out, "UTF-8"), true);
}
and finaly figured out that I had to add a line like:
svgGenerator.getGeneratorContext().setPrecision(4);
I think it would be a good idea to have a call to setPrecision in SVGGeneratorContext.createDefault because that would prevent the exception.
Alberto
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: setPrecission missing in SVGGeneratorContext.createDefault
Posted by Vincent Hardy <vi...@sun.com>.
Hi Alberto,
There is a bug in Batik 1.5 that causes the NullPointerException. This
fixed in CVS. As you figured out, adding a call to setPrecision works
around the issue. However, if you get the latest code from CVS, you'll
find that the default will work (i.e., the default precision works and
there is no need to call setPrecision unless desired).
Vincent.
Alberto Gobbi wrote:
>Hi,
>I have started to use batik it is a great tool!!!
>
>I ran into a nullpointer exception in SVGGeneratorContext.doubleString with simple code like:
>
> public void createSVG(OutputStream out) throws IOException
> { // Get a DOMImplementation
> DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
>
> // Create an instance of org.w3c.dom.Document
> Document document = domImpl.createDocument(null, "svg", null);
>
> // Create an instance of the SVG Generator
> SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
> //svgGenerator.getGeneratorContext().setPrecision(4);
>
> draw(svgGenerator);
> svgGenerator.stream(new OutputStreamWriter(out, "UTF-8"), true);
> }
>
>and finaly figured out that I had to add a line like:
> svgGenerator.getGeneratorContext().setPrecision(4);
>
>I think it would be a good idea to have a call to setPrecision in SVGGeneratorContext.createDefault because that would prevent the exception.
>
>Alberto
>
>
>---------------------------------------------------------------------
>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