Jorg Heymans wrote:



Thomas DeWeese wrote:

Jorg Heymans wrote:

What is the quickest way of either inserting a new node (say <g> with a bunch of paths) into a document or replacing an existing node ?

I have found that under similar circumstances, replaceChild() is about 10% quicker than appendChild(), but for my application it still takes about 5 seconds to dynamically add it.

Sounds like it's a lot of geometry. Do you know if the time is taken in the add or in the repaint (you should be able to print something after the add and then get a feel for when the repaint finishes)? BTW it is much better to do what you are doing and add all the geometry at once.

Thanks for your feedback. Yes it is a GIS application, we've normalized the paths as much as we could but nevertheless they seem quite complex for batik. But nevertheless, it is strange that when i use setURI() to display my document it display a *lot* quicker.

What happens if you add this at the start of your sample document:

<svg fill="white" preserveAspectRatio="xMidYMid meet" stroke="black" stroke-width="0.002%" viewBox="423463.2 -5470604.7 133015.1 100471.1"
onclick="move('kreis')" >
<script type="text/ecmascript"><![CDATA[
function move(name) {
System.err.println("Start");
var root = document.getRootElement();
var elem = root.getElementById(name);
root.appendChild(elem);
System.err.println("Finish");
}
]]></script>
<rect x="423463.2" y="-5470604.7" width="133015.1" height="100471.1" fill="green" pointer-events="all"/>
<defs>
// The 'kreis' <g>
</defs>
</svg>


   On my system in Squiggle it takes less than a second from when
I click and when the graphic appears (it's a pretty nice laptop but
still I'd be surprised if your system was 5-10x slower).  Could the
time be spent retrieving the data from the server?

My paths are just plain geometries really, no fill, just lines. FWIW i have put a copy (115kb) on www.domek.be/batiktest.svg. The <g id="kreis"> is the element i am trying to insert dynamically.

This should be really fast, and it seems to be in my tests.

Does the XML parser make a difference? I am using JDK 1.4.2 built-in Crimson. I'll see if i can do a test with latest Xerces.

It shouldn't, what is important is that you build the document with our SVGDOMImplementation. Actually in this case you want to make sure that you build the Nodes with the Document that you want to associate them with, otherwise they will need to be cloned into the new document.

   You might want to look at the code in parseXML in
bridge.ScriptingEnvironment (or you might just want to call that
yourself).

Actually how about JDOM? Can it be used with Batik?

Not directly, the SVG spec is built on W3C DOM, and this is what we use natively for the document. You can load stuff with JDOM and manipulate it, but before it get's associated with the Canvas you need to convert it to our SVG DOM.

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



Reply via email to