The difference is that when you use "" in DOM they aren't SVG elements but when seirialized they 'become' SVG elements because they have no prefix and the default namespace is SVG. Thus we must conclude the issue is mostly likely the additional time incurred in repainting the canvas when SVG elements are added to the DOM.
From this I conclude that your GraphicalObject returned by 'ecfg.getEventRepresentation()' is reused, and hence you end up setting the position of the previous circle if the runnable hasn't completed yet. I've confirmed this by checking that there are infact 280 circles in the 'missing' SVG file and some of them have duplicate locations.
I suggest you have getEventRepresentation return a new graphical object each time, or make x,y parameters to SVGUpdage.
Reinhard Brandstädter wrote:
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
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]