SVG Graphics DDemo
import java.awt.Rectangle;
import java.awt.Graphics2D;
import java.io.Writer;
import java.io.FileWriter;
import java.io.IOException;
import org.apache.batik.svggen.SVGGraphics2D;
import org.apache.batik.dom.GenericDOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.DOMImplementation;
public class SVGGraphics2DDemo {
public void paint(Graphics2D g){
g.drawString("Java,XML and Web Services Bible",12,12);
}
public static void main(String args[]) throws IOException{
SVGGraphics2DDemo sv2Demo = new SVGGraphics2DDemo();
DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
Document doc = domImpl.createDocument(null, "svg", null);
SVGGraphics2D svg = new SVGGraphics2D(doc);
sv2Demo.paint(svg);
svg.stream(new FileWriter("booktitle.svg"),false);
}
}
//booktitle.svg
/*
<?xml version="1.0" encoding="Cp1252"?>
<svg fill-opacity="1" color-interpolation="sRGB" color-rendering="auto" text-rendering="auto" stroke="black" stroke-linecap="square" width="2147483647" stroke-miterlimit="10" stroke-opacity="1" shape-rendering="auto" fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1" height="2147483647" font-family="'Arial'" font-style="normal" stroke-linejoin="miter" font-size="12" image-rendering="auto" stroke-dashoffset="0">
<defs id="genericDefs" />
<g>
<g>
<text x="12" y="12" stroke="none">Java and XML Bible; WebServices
</text>
</g>
</g>
</svg>
*/
Related examples in the same category