W3C home > Mailing lists > Public > www-svg@w3.org > May 2000

Re: How To Create a SVG-File in JAVA?

From: Vincent Hardy <vincent.hardy@eng.sun.com>
Date: Tue, 30 May 2000 10:28:54 -0700
Message-ID: <3933FA56.B1412B1E@eng.sun.com>
To: Bernd Grolig <Bernd.Grolig@ptv.de>
CC: www-svg@w3.org

If what you are doing is simply generating SVG code (e.g., on a server)
for rendering later on in a browser, you could do something like (using
Project X, but you could also use Xerces):

import com.sun.xml.tree.*;
import org.w3c.dom.*;

XmlDocument doc = new XmlDocument();

Element svg = doc.createElement("svg");
Element rect = doc.createElement("rect");
rect.setAttribute("width", "400");
rect.setAttribute("width", "400");

// ....

// Stream to file
doc.write(new FileOutputStream("mySvgFile.svg"));

This does not give you the ease of use of the SVG Java bindings, but
it may be enough for what you are trying to do.

I hope this helps. FYI, we (Sun) are also working on a Java 2D API 
Graphics2D SVG generator that would automatically translate any Java 
rendering into its SVG equivalent, but this is not yet available on 
Sun's web site.


Bernd Grolig wrote:
> Hi,
> I'm new to programming in Java. For an application (for my graduation work),
> I want to generate a SVG File containing geographical Inormation.
> For this, I want to use the JavaBinding for SVG and therefor the
> Implemenation from the SVG Toolkit from Csiro (www.csiro.org).
> My question:
> I'm not sure how to start, creating the FileBuffer in Java using the methods
> in provided by the W3C-SVG JavaBinding and the Csiro SVG Toolkit.
> Is there anybody who could post an example. It's just to get an idea of how
> this works.
> Thanks for every idea.
> Regards, Bernd.
Received on Tuesday, 30 May 2000 13:29:13 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:29:12 UTC