Hello, 

I have a problem and I can't seem to get around it.. 

So my java-app loads SVG-map and then I'm trying to add an element to it by
using DOM and I would like to see the change in SVGCanvas.

But when I add an element, the svgCanvas doesn't seem to update at all, even
that I'm pretty sure that the DOM-structure changes.
Funny thing is, that setAttributes -method works nicely and I can change
elements which are
already there (ie. change a fill-color for a circle).

Some code: 

// Loading the document

            String parser = XMLResourceDescriptor.getXMLParserClassName();
            SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
            String uri = img.toString();
            doc = (SVGDocument)f.createDocument(uri);

            JSVGCanvas svgCanvas = new JSVGCanvas();
            svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC); 

            svgCanvas.setSVGDocument((SVGDocument)doc);

// Trying to add DOM-element

        UpdateManager um = svgCanvas.getUpdateManager(); 
        um.getUpdateRunnableQueue().invokeLater(new Runnable() {
                public void run() {

                    // This WORKS
                    Element cir = doc.getElementById("mycircle");
                    cir.setAttribute("fill", "yellow");
                    
                    // This doesn't
                    Element newMarker = doc.createElement("circle");
                    newMarker.setAttribute("cx", "120");
                    newMarker.setAttribute("cy", "120");
                    newMarker.setAttribute("fill", "blue");
                    newMarker.setAttribute("r", "50");
                    newMarker.setAttribute("stroke", "black");
                    newMarker.setAttribute("stroke-width", "4");
                   
svgCanvas.getSVGDocument().getRootElement().appendChild(newMarker);
                    
                    svgCanvas.repaint();
                    
                }    
        }); 

Any help would be welcomed.

-- 
View this message in context: 
http://www.nabble.com/Adding-element-to-DOM-%28problem%29-tp17645225p17645225.html
Sent from the Batik - Users mailing list archive at Nabble.com.


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

Reply via email to