This should come first:
svgCanvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
furthermore, there is no need IMO to set the document back on the canvas as you're updating it in place.
And not all of your code below needs to be invoked from the update mgr thread, only the svgdoc.getRootElement().appendChild(elt); is modifying the document really.
HTH Jorg [EMAIL PROTECTED] wrote:
Hi All
Iam trying to add an element dynamically to the svgdocument bound to a JSVGCanvas. Iam doing this inside updatemanagerthread but it doesn't work. can anybody suggest what iam doing wrong here.
The following code snippet is inside a dynamicUpdatebutton.addActionListener(new ActionListener() {
public void actionPerformed
(ActionEvent ae) { svgCanvas.getUpdateManager().getUpdateRunnableQueue
().invokeLater(
new Runnable() {
public void run() {
SVGDocument svgdoc=svgCanvas.getSVGDocument();
Element elt = svgdoc.createElement("a");
elt.setAttribute("xlink:href","http://www.ibm.com/");
Element polygon = svgdoc.createElement("polygon");
polygon.setAttribute("points","60 160,165 172,180 60,290 290,272 280,172 285,250 255");
polygon.setAttribute("style","fill:dimgrey");
elt.appendChild(polygon);
svgdoc.getRootElement().appendChild(elt);
svgCanvas.setDocumentState
(JSVGCanvas.ALWAYS_DYNAMIC);
svgCanvas.setSVGDocument(svgdoc);
}
});
Thanks in advance Chandra
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
