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);
w.close();
}
}
).start();
doc=fac.createSVGDocument("someURI", r);
svg.setSVGDocument(doc);
}
Martin
--
>From my MacBook Pro
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]