I've encountered a problem wich I can't find a solution for, although I've tried some time now. Maybe it's just too easy and I'm thinking to complicated.
I've got a JDialog which contains a JSVGCanvas created the following way (copied from the examples):
.. DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; doc = impl.createDocument(svgNS, "svg", null); Element svgRoot = doc.getDocumentElement(); svgRoot.setAttributeNS(null, "overflow", "visible"); ... jSVGCanvas1.setDocumentState(JSVGComponent.ALWAYS_DYNAMIC); jSVGCanvas1.setSVGDocument( (SVGDocument) doc); jScrollPane1.getViewport().add(jSVGCanvas1, null);
--------
later on in this GUI I start a simple Timer thread, that gets Objects from a Queue. These Objects will later on create simple SVG Element Document Nodes so I create Runnables that are added to the UpdateQueue.
--------
timer = new Timer(200, new ActionListener() { public void actionPerformed(ActionEvent evt) { ... unrelated calculations ... GraphicalObject g = ecfg.getEventRepresentation(); g.setPosition(x, y); jSVGCanvas1.getUpdateManager().getUpdateRunnableQueue(). \ invokeLater(new SVGUpdate(jSVGCanvas1.getSVGDocument(),g)); } });
-------- The Runnable Object added to the UpdateManager looks like this: --------
public class SVGUpdate implements Runnable { GraphicalObject g; SVGDocument doc;
public SVGUpdate(SVGDocument svgdoc, GraphicalObject g) { this.g = g; doc = svgdoc; }
public void run() { g.append(doc); } }
--------
The getSVGElement Method that should (and does) produce a valid element and the append Method that is called from the UpdateManager Runnable.
--------
public Element getSVGElement(SVGDocument doc) { Element circle = doc.createElementNS(svgNS, "circle"); //DOMImplementation.SVG_NAMESPACE_URI= ^^^^^ circle.setAttributeNS(null, "cx", String.valueOf(x)); circle.setAttributeNS(null, "cy", String.valueOf(y)); circle.setAttributeNS(null, "r", String.valueOf(r)); circle.setAttributeNS(null, "style", "fill:"+fillcolor); return circle; }
public void append(SVGDocument doc) { doc.getRootElement().appendChild(getSVGElement(doc)); }
--------
And now comes the part that I can't understand. When running the Application dynamically generated Elements (by calling getSVGElement()) are displayed in the JSVGCanvas of my Dialog, but a few are missing. It starts with missing a few and later on even more Elements are not showing up. Although the UpdateManager processes all of them (counted debugg outputs in the run() method of SVGUpdate. (560 Elements processed by the Timer and 560 finished run() methods)
I've dumped the generated SVG file from the JSVGCanvas, to download here: http://www.gup.uni-linz.ac.at/~rbrand/dump-display-but-missing.svg
But what really gives me to thing is the fact that if I change the global String variable "svgNS" used in the getSVGElement() Method to something useless or even an emty String "" the Document doesn't get displayed in the JSVGCanvas during runtime at all, but if I dump the file again it's correct without missing Elements, to download here:
http://www.gup.uni-linz.ac.at/~rbrand/dump-nodisplay-nomissing.svg
So how can this happen? As the second version without displaying during runtime shows all Elements are processed sucessfully, but how the heck can it happen that they are not displayed in the first version?
hmmm?
Thanks for any hints! Reinhard -- Reinhard Brandstaedter [EMAIL PROTECTED] GPG: 0x033B81DB - Student of Computer Science - J.K. University of Linz - - <ICQ: 73059068> <Mobile: +43 699 12419541> - - http://adelaide.dnsalias.net -
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]