Hi Minimo, <[EMAIL PROTECTED]> wrote on 09/17/2008 09:16:15 AM: > I find something that may interest some of you and I wish you could > tell me what you think about my idea. > > I had a look into the node classes and GenericText in particular. I > saw that for each setNodeValue, an event is Fired and propaged to > parent elements.
This event let's Batik know that it needs to update the graphics element associated with the DOM element. > So in my application I cast my svgDoc to a SVGOMDocument and call > setEventsEnabled(false); > I then loop to perform each single update "without" firing event > (they are fired but not taken into account). > > Before the last update I just call setEventsEnabled(true). This line > allow the last event fred to be taken into account and the tree is updated. > Maybe this method is not the best but it works. Can you tell me what > you think about this ? Since you are modifying multiple DOM element's I don't think the above will work. All but the last element won't be updated on the screen. > I'll take this as a solution as I don't have lot of time available > but I'd like to discuss about this. So the following example SVG seems to be a decent simulation of what you are trying to do. After the 'first load' it takes ~32ms on my machine (to update the text content of 20 text elements). What happens for you? Or why isn't this a good simulation of what you are trying to do? <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="800px" height="600px" viewBox="0 0 800 600" enable-background="new 0 0 800 600" xml:space="preserve" onload="update()"> <script type="text/ecmascript"><![CDATA[ var t0; var total =20; function update() { var i=0; while (i<total) { var e = document.createElementNS("http://www.w3.org/2000/svg", "text"); e.setAttributeNS(null, "id", "t"+i); e.setAttributeNS(null, "x", "200"); e.setAttributeNS(null, "y", ""+(20+i*12)); e.setAttributeNS(null, "text-anchor", "middle"); var tc = document.createTextNode("test " + i); e.appendChild(tc); document.getRootElement().appendChild(e); i++; } setTimeout('change()', 500); } function change() { t0 = System.currentTimeMillis(); var i=0; while (i<total) { var tc = document.getElementById("t"+i).firstChild; tc.setNodeValue("change: " + i); i++; } setTimeout('result()', 0); } function result() { var t1 = System.currentTimeMillis(); var tc = document.getElementById("t0").firstChild; tc.setNodeValue("result --> " + (t1-t0) + "ms"); } ]]></script> </svg>
