You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Tobin Fricke <to...@splorg.org> on 2004/08/19 01:26:44 UTC
displaying SVG from a string
I see that the JSVGCanvas class has a "setURI" method to fetch an SVG from
some URI. However, I have an SVG document in a String... I just want to
give this SVG string to the JSVGCanvas and have it display it. How should
I accomplish this?
Secondly, what's the proper way to build something that has a dependency
on Batik? i.e., what classpath do I use?
thanks,
Tobin
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: displaying SVG from a string
Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Tobin,
Tobin Fricke wrote:
> I see that the JSVGCanvas class has a "setURI" method to fetch an SVG from
> some URI. However, I have an SVG document in a String... I just want to
> give this SVG string to the JSVGCanvas and have it display it. How should
> I accomplish this?
Turn the String into a Reader (java.io.StringReader), parse it into
a DOM tree using the org.apache.batik.dom.svg.SAXSVGDocumentFactory
class. Give the resulting document to the canvas
JSVGCanvas.setSVGDocument.
> Secondly, what's the proper way to build something that has a dependency
> on Batik? i.e., what classpath do I use?
Depends on what you want or need out of the Batik toolkit.
Take a look at http://xml.apache.org/batik/install.html#jarFiles for
a diagram of jar file dependencies. You could also just build your
own jar file the ant build file has an 'all-jar' target that builds
one jar file that includes everything.
You might also look at the manifest files for the batik
applications to see how they work.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org
Re: displaying SVG from a string
Posted by Tonny Kohar <to...@kiyut.com>.
Hi,
> I see that the JSVGCanvas class has a "setURI" method to fetch an SVG from
> some URI. However, I have an SVG document in a String... I just want to
> give this SVG string to the JSVGCanvas and have it display it. How should
> I accomplish this?
Here is the example
StringReader reader = new StringReader(someString);
try {
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
doc = f.createSVGDocument(baseDocumentURI,reader);
} catch (Exception ex) { }
jsvgCanvas.setDocument(doc);
Regards
Tonny Kohar
--
Sketsa
SVG Graphics Editor
http://www.kiyut.com
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org