Vincent
Many thanks for your reply. This is pretty much along the lines of what
I had been trying without success.
The only difference is the line :
// In case you want to stream through g
g.setRoot(g);
I have tried batik 1.1 and 1.5beta4 and neither appear to support a
setRoot method in SVGGraphics2D. Is there something I am missing?
Below is what I am currently trying.
-----------------------------------------------------
/// Create an instance of the SVG Generator
SVGGraphics2D svgGenerator = new SVGGraphics2D(ctx, false);
svgGenerator.setSVGCanvasSize(outputSize.getSize());
/// Draw the chart to the output.
chart.draw(svgGenerator, outputSize, null);
Element svgRoot = svgGenerator.getRoot();
/// set SVG Canvas size (For auto resizing)
String viewBox = "0 0 " + outputSize.width + " " +
outputSize.height ;
svgRoot.setAttributeNS(null,
svgGenerator.SVG_VIEW_BOX_ATTRIBUTE,
viewBox);
/// Stream the output
svgGenerator.stream(writer, true);
writer.flush();
writer.close();
-----------------------------------------------------
-----Original Message-----
Hello Bryan,
You'll need to do something like:
SVGGraphics2D g = ....;
g.setSVGCanvasSize(new Dimension(800, 600));
// ...
// Draw into g
// ....
Element root = g.getRoot();
root.setAttributeNS(null, "viewBox", "0 0 800 600");
// In case you want to stream through g
g.setRoot(g);
Regards,
Vincent.
Bryan Scott wrote:
> Hi
>
> I am hoping that someone has some sample code for how to include a
> viewBox attribute to the svg element using batik?
>
> I can generate SVG graphics, but I cannnot get it to include a viewBox
> attribute. i.e something like : <svg ......... width="800"
> height="600" viewBox="0 0 800 600">
>
> I am heading to sea today for three months so could replies be cc'ed
> to [EMAIL PROTECTED], as we do not have net access.
>
> Many thanks.
>
>
> Bryan Scott
> Marine Science Support
> Australian Antarctic Division
>
>
> ______________________________________________________________________
> _____
>
> Australian Antarctic Division - Commonwealth of Australia
> IMPORTANT: This transmission is intended for the addressee only. If
> you are not the intended recipient, you are notified that use or
> dissemination of this communication is strictly prohibited by
> Commonwealth law. If you have received this transmission in error,
> please notify the sender immediately by e-mail or by telephoning +61 3
6232 3209 and DELETE the message.
> Visit our web site at http://www.aad.gov.au/
> ______________________________________________________________________
> _____
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
___________________________________________________________________________
Australian Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are
not the intended recipient, you are notified that use or dissemination of
this communication is strictly prohibited by Commonwealth law. If you have
received this transmission in error, please notify the sender immediately
by e-mail or by telephoning +61 3 6232 3209 and DELETE the message.
Visit our web site at http://www.aad.gov.au/
___________________________________________________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]