it made me ralise that the whole shebang of stylesheet etc (taken from the example) could be omitted.
The main problem was that the output was written twice to the same file, doubling the headers, one with the viewbox set, the other not. The problem had to do with the order of calls. I had to take out the line that used to create the output
svg2d.stream(outWriter, useCss);
and move the root.setAttribute() to after I had rendered the java graphics to the SVGGraphics2D svg2d.Then the call
svg2d.stream(root,outWriter, useCss);
did what I wanted it to do: a squiggle-readable file reacting to resizing the viewing frame.
relevant body of the method:
//
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
// Get a DOMImplementation
DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
// Create an instance of org.w3c.dom.Document Document document = domImpl.createDocument(null, "svg", null);
// set context (i.e parameters) of the document SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document);
// Create an instance of the SVG Generator with context and document SVGGraphics2D svg2d = new SVGGraphics2D(ctx, false);
// stream out SVG to the standard output using UTF-8 // character to byte encoding boolean useCSS = true; // we want to use CSS style attribute Writer outWriter = new OutputStreamWriter(out, "UTF-8");
// Ask the canvas to render into the SVG Graphics2D implementation canvas.paintSVG(svg2d);
// adjust header to make resulting image resize with its 'viewbox'
Element root= svg2d.getRoot();
root.setAttributeNS(null, "viewBox", "0, 0,"+ canvas.getWidth() + "," + canvas.getHeight() );
// write this root with rest to out svg2d.stream(root,outWriter,useCSS);
out.close(); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]