Hi Thomas,

Apologies for the late reply, here is a bit more info.

1) the code is running in an applet

2) I have a monitor class implementing all 4 listener classes (Updatemanager, svgdocumentloader,gvttreebuilder,gvttreerenderer)

3) I have a class extending the svgloadeventdispatcher, and in svgloadeventdispatchstarted() i assign the document instance
this.document=canvas.getSVGDocument()


4) in init() of the applet i have
canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
canvas.addSVGLoadEventDispatcherListener(new SVGLoadMonitor());
canvas.addSVGDocumentLoaderListener(monitor);
canvas.addGVTTreeBuilderListener(monitor);
canvas.addGVTTreeRendererListener(monitor);
canvas.addUpdateManagerListener(monitor);
canvas.setURI(getClass().getClassLoader().getResource("base.svg")
                .toExternalForm());

5) i am adding and removing DOM elements via checkboxes, so in itemStateChanged(ItemEvent e) i do

  .....
  //ADDING elements (works)
  String parser = XMLResourceDescriptor.getXMLParserClassName();
  SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
  final SVGDocument doc = (SVGDocument) f.createDocument(uri);
  final Node documentNode = document.importNode(doc
                        .getElementsByTagName("g").item(0), true);
  //find the node we need to append to
  String xpath = "//[EMAIL PROTECTED]'" + feature + "']";
  final NodeList nodeList = org.apache.xpath.XPathAPI
                        .selectNodeList(document, xpath);

canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(
new Runnable() {
public void run() {
document.getDocumentElement().replaceChild(
documentNode, nodeList.item(0));
}
});
......
//REMOVING ELEMENTS (does not work)
final Element remove = document.getElementById("wta"); canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(
new Runnable() {
public void run() {
//EXCEPTION OCCURS HERE
remove.getParentNode().removeChild(remove);
}
});


6) The calls to getPreviousSibling() and getNextSibling() on the node i want to remove :
getNodeName() -> "#text"
getNodeValue() -> a few blanks and newlines, seems correct
getNodeType() -> 3


7) Adding and removing happens in thread "RunnableQueue-0" according to log4j. All other operations in thread "AWT-EventQueue-1".

Hope i haven't flooded you with too much info, if you need more info just shout.

Regards
Jorg

Thomas DeWeese wrote:

Hi Jorg,

   I have no idea why you are getting this error.  I have
never seen it.  My initial suspicion is that you are removing
the same element from two different threads.  I would be
curious to know what getPreviousSibling() and getNextSibling()
return right before calling removeChild.

   I would also be interested in knowing how you add the
elements to the DOM.

   Is this error totally reproducable?  can you produce a
reproducable standalone test case?


Jorg Heymans wrote:

Hi,


I am able to add stuff to the DOM in the update thread (getUpdateManager().getUpdateRunnableQueue().invokeLater() )


Why is a simple removal then not working like i expect it to work?
I locate the node to remove using document.getElementById , making sure with getLocalName() and getAttributes() that this is actually the node i want to remove.


Then in the update thread i am doing
removenode.getParent().removeChild(removenode) which results in stacktrace ("g" being the element i want to remove)


org.w3c.dom.DOMException: The child node (type: 1, name: g) is missing.
at org.apache.batik.dom.AbstractNode.createDOMException(Unknown Source)
at org.apache.batik.dom.AbstractParentNode$ChildNodes.remove(Unknown Source)
at org.apache.batik.dom.AbstractParentNode.removeChild(Unknown Source)
at com.terrasel.osgis.batikapplet.SVGApplet$2.run(SVGApplet.java:187)
at org.apache.batik.util.RunnableQueue.run(Unknown Source)
at java.lang.Thread.run(Thread.java:534)


The element i want to remove is the one i just dynamically added. I think i am operating on a recent document instance because i can actually *find* the element.

Removing static elements always works, so where am I missing the sync on the document instance?


Any hints?


Regards Jorg

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


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



Reply via email to