>>>>> "GS" == Geeta Shukla <[EMAIL PROTECTED]> writes:
GS> Hi, I am using Batik 1.5b4b version. Through the app i am GS> developing i let the user select a svg file and open it. It opens GS> and renders properly. The app also allows user to add more <text> GS> nodes to the SVG document. I take the value for the text node in a GS> JTextArea and create a text node and append to the SVGDocument. My GS> problem is that even after appending the new <text> node it GS> doesn't show up on the JSVGCanvas. I tried doing the following: GS> 1) setSVGDocument(doc) 2) repaint() on JSVGCanvas 3) repaint() on GS> UpdateManager of the canvas. GS> but nothing worked. If i try writing the SVGDocument to a file, it GS> contains the <text> node which i appened. If i reopen this file GS> again thru my app the text node shows up. But i don't want it that GS> way. I need the canvas to refresh when the SVGDocument changes. Sure, I suspect the problem is namespaces. You need to create elements with namespaces and set Attributes with out namespace with the exception of the 'xlink:href' attribute. You also don't need to set the SVG document at the end just modifying it should cause the repaint to happen. One other things occurs to me is that the height of the svg element might be clipping the new text elements. I suggest you try setting the height of the outermost SVG element large enough to show any text elements ahead of time (there have been issues with updates to the width/height on the outermost svg element so don't count on those changes happening automatically). I updated your function as I think it should be. GS> Please help! I have appended my method which creates the new text GS> node below. public void createAnnotationNode( String annotation, int x, int y, int SVGWidth) throws Exception { SVGDocument document = this.getSVGDocument(); SVGSVGElement root = document.getRootElement(); int xScale = x + (annotation.length()*12); if(xScale > SVGWidth) { root.setAttribute("width", String.valueOf(xScale)); } // create the text Element text = document.createElementNS(SVG_NAMESPACE, "text"); text.setAttribute("x", String.valueOf(x)); text.setAttribute("y", String.valueOf(y)); text.setAttribute("style", "font-size:12"); Text value = document.createTextNode(annotation); text.appendChild(value); // attach the text to the svg root element root.appendChild(text); }//end of method createTextNode --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]