xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Jacobson <jacobson.mar...@gmail.com>
Subject Re: create a JSVGCanvas from an inputstream
Date Sun, 03 Jan 2010 09:04:21 GMT
I don't know whether this code is (a) relevant, (b) useful -- :-) --
but this is how I generate an SVG for the JSVGCanvas. I generate maps
by interrogating a spatial db (not shown), and placing the data into a
Velocity context (not shown, but called "ctx"). I pipe the output from
the Velocity engine into the "createSVGDocument()" method. The
PipedWriter must write in a different Thread from the PipedReader. It
works very well for me. I hope somebody finds it useful.

public void buildMap(JSVGCanvas svg) {
        // missing code (lots!)
	PipedReader r = new PipedReader();
	PipedWriter w = new PipedWriter(r);
	String prs = "org.apache.xerces.parsers.SAXParser";
	SAXSVGDocumentFactory fac = new SAXSVGDocumentFactory(prs);
	String templateName = "myTemplate.svg";
	new Thread(
		new Runnable() {
			public void run() {
				Velocity.mergeTemplate(templateName, "UTF8", ctx, w);
	doc=fac.createSVGDocument("someURI", r);

>From my MacBook Pro

To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

View raw message