> As far as I'm aware, the root element gets overwritten if you use the
> document as DOM factory for your SVGGraphics2D instance. I
> think you might have better luck if you set the attribute on
> the root of the tree *after* generation by svgGenerator. Info
> in the tutorial on "Customizing the generated SVG style"
> (http://xml.apache.org/batik/svggen.html#custom) may be
> of interest to you.
> Paul
I tried that and it was even stranger.
My code is essentially:
// Create an instance of org.w3c.dom.Document
Document document = impl.createDocument(svgNS, "svg", null);
Rectangle2D b2d = new Rectangle2D.Double(0, 0, 600, 400);
// Create an instance of the SVG Generator
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
svgGenerator.setSVGCanvasSize(new Dimension((int) b2d.getWidth(),
(int) b2d.getHeight()));
//This generates the graph
graph.draw(svgGenerator, b2d);
//*** This viewBox attribute causes corruption
Element el = svgGenerator.getRoot();
el.setAttributeNS(svgNS, "viewBox", "0, 0, 600, 400" );
If I comment out the two lines after *** I get (as expected):
<?xml version="1.0" encoding="Cp1252"?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN'
'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
<svg style="stroke-dasharray:none; shape-rendering:auto;
font-family:'Arial'; text-rendering:auto; fill-opacity:1;
color-rendering:auto; color-interpolation:auto; font-size:12; fill:black;
stroke:black; image-rendering:auto; stroke-miterlimit:10;
stroke-linecap:square; stroke-linejoin:miter; font-style:normal;
stroke-width:1; stroke-dashoffset:0; font-weight:normal; stroke-opacity:1;"
xmlns="http://www.w3.org/2000/svg" width="600"
contentScriptType="text/ecmascript" preserveAspectRatio="xMidYMid meet"
xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify"
version="1.0" contentStyleType="text/css" height="400">
<!--Generated by the Batik Graphics2D SVG Generator-->
<defs id="genericDefs" />
<g>
<g style="fill:white; font-size:8; stroke:white;">
<rect x="0" y="0" width="600" style="stroke:none;" height="400" />
<text x="230.3486328125" y="19.302831649780273" style="font-size:14;
fill:black; stroke:none;" xml:space="preserve">Second sample Graph
</text>
</g>
*** Deleted many lines
</g>
</g>
</svg>
If I include the two lines after *** I get the entire file as attached
below.
Note complete absence of viewBox and any other data! The draw method is not
threaded in any way. Any ideas?
<?xml version="1.0" encoding="Cp1252"?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN'
'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
<svg style="stroke-dasharray:none; shape-rendering:auto;
font-family:'Arial'; text-rendering:auto; fill-opacity:1;
color-rendering:auto; color-interpolation:auto; font-size:12; fill:black;
stroke:black; image-rendering:auto; stroke-miterlimit:10;
stroke-linecap:square; stroke-linejoin:miter; font-style:normal;
stroke-width:1; stroke-dashoffset:0; font-weight:normal; stroke-opacity:1;"
xmlns="http://www.w3.org/2000/svg" width="600"
contentScriptType="text/ecmascript" preserveAspectRatio="xMidYMid meet"
xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="magnify"
version="1.0" contentStyleType="text/css" height="400">
<!--Generated by the Batik Graphics2D SVG Generator-->
<defs id="genericDefs" />
<g />
</svg>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]