|
sorry,
but i dont have any clue how to do this
practically. may you please give some example code: i have something like
this:
JSVGCanvas worldMap = new JSVGCanvas();
//get the XML Code from
"world.svg"
String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); String uri = "http://www.nettrace.de/world.svg"; Document worldWithRectangle = f.createDocument(uri); //create a new rectangle
node
Element rectangle = world.createElementNS(uri, "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"); //add the rectangle to the xml of world.svg
worldWithRectangle.appendChild(rectangle);
//show the 'new' SVGDocument worldMap.setDocument(worldWithRectangle); but this brings the following exception:
[EMAIL PROTECTED] org.w3c.dom.DOMException : The current node (type: 9, name: #document) do not allow children of the given type (type: 1, name: rect)at org.apache.batik.dom.AbstractNode.createDOMException(Unknown Source)at org.apache.batik.dom.AbstractDocument.checkChildType(Unknown Source) at org.apache.batik.dom.AbstractParentNode.checkAndRemove(Unknown Source) at org.apache.batik.dom.AbstractParentNode.appendChild(Unknown Source) at AppletApplication.init( AppletApplication.java:151)at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) |
