Hello all,

I would appreciate if someone can guide me on building a SVG document. I need to create the labels myself, so I can keep track of the segments and face parts I am generating.
I see the example below on the site, but it is not generating the physical file. What else do I need? How do I specify the location where I want to save the SVG file? What is SVG_NAMESPACE_URI ?
Thanks,
Alice


import org.apache.batik.dom.svg.SVGDOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
Document doc = impl.createDocument(svgNS, "svg", null);

// get the root element (the svg element)
Element svgRoot = doc.getDocumentElement();

// set the width and height attribute on the root svg element
svgRoot.setAttributeNS(null, "width", "400");
svgRoot.setAttributeNS(null, "height", "450");

// create the rectangle
Element rectangle = doc.createElementNS(svgNS, "rect");
rectangle.setAttributeNS(null, "x", "10");
rectangle.setAttributeNS(null, "y", "20");
rectangle.setAttributeNS(null, "width", "100");
rectangle.setAttributeNS(null, "height", "50");
rectangle.setAttributeNS(null, "style", "fill:red");

// attach the rectangle to the svg root element
svgRoot.appendChild(rectangle);

Alice Cristina Mello Cavallo
Interdisciplinary PhD Candidate at Tufts University
Learning, Technology and Drama
http://www.media.mit.edu/~mello/


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to