Hello I had a problem to refresh Jsvgcanvas when I load a new document. Sorry to thomas.deweese, but I cannot answer to your reply of my last post. I don't know why.
So I load a SVG file whith the JSVGCanvas (setUri). Then I get the document "Document document = svgcanvas.getSVGDocument". After the update of the DOM DOcument, I try svcanvas.setSVGDocument. I try this: String svgNS="http://www.w3.org/2000/svg"; Element rectangle = document.createElementNS(svgNS, "rect"); rectangle.setAttributeNS (null, "x", "1200"); rectangle.setAttributeNS(null, "y", "2200" ); rectangle.setAttributeNS(null, "width", "3100"); rectangle.setAttributeNS(null, "height", "3510"); rectangle.setAttributeNS(null, "style", "stroke: red; fill: red;"); a1.appendChild(rectangle); It works! But in my software, I need to add a lot of new svg elements from a String. I can put all of the data in Node (newElement). I try to add this node to the newLayer element. Then to add the newLayer element to the g1 element (a kind of root element, the son of the svg element) I try this: String svgNS="http://www.w3.org/2000/svg"; Element newLayer = document.createElementNS(svgNS, "g"); newLayer.setAttribute("id","123"); newLayer.appendChild(document.importNode(newElement,true)); //add the new node g1.appendChild(newLayer); //add the new layer in the <g id="1"> element The Jsvgcanvas doesn't refresh, but when I save the document into a file, the document is ok: <svg ...> <g id="1"> ... <g id="123"> <g id="layer101"> <polyline style="fill:none; stroke:rgb(255,000,000);" points="8325 2232, 8325 2540"/> <polyline style="fill:none; stroke:rgb(255,000,000);" points="7925 2232, 7925 2540"/> <polyline style="fill:none; ... </g> </g> </g> </svg> The file is ok, when I load it in a new Jsvgcanvas, it shows the picture with the new elements So I think that I have a bad using of createElementNS. I try: String svgNS=" http://www.w3.org/2000/svg"; Element group = document.createElementNS(svgNS, "g"); Element rect = document.createElementNS (svgNS, "rect"); rect.setAttributeNS(null, "x", "1200"); rect.setAttributeNS(null, "y", "2200" ); rect.setAttributeNS(null, "width", "3100"); rect.setAttributeNS(null, "height", "3510"); rect.setAttributeNS(null, "style", "stroke: red; fill: red;"); group.appendChild(rectangle); a1.appendChild(group); It works But this (the same without namespace for the child): String svgNS="http://www.w3.org/2000/svg"; Element group = document.createElementNS (svgNS, "g"); Element rect = document.createElement ("rect"); rect.setAttribute( "x", "1200"); rect.setAttribute("y", "2200" ); rect.setAttribute("width", "3100"); rect.setAttribute("height", "3510"); rect.setAttribute("style", "stroke: red; fill: red;"); group.appendChild(rect); a1.appendChild(group); It doesn't works. But in my project, I need to add new elements thanks to a new Node which come from an other document (which have element from a file or a servlet). So I cannot put createElementNS for each element! Is there a way to specify the namespace for a Node (and for all children) which already exists? How can I do to add a new node with a lot of new elements and to refresh the jsvgcanvas? -- This message was sent on behalf of [EMAIL PROTECTED] at openSubscriber.com http://www.opensubscriber.com/messages/[email protected]/topic.html --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
