xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julien Beghin <julien.beg...@gmail.com>
Subject Slow updates
Date Wed, 17 Sep 2008 08:44:42 GMT
Hello,

First, thanks to Andreas Neumann for his first advices about my problem.

I am working on a Java application which is using a JSVGCanvas to display some business informations.

Still in the business part of my application, I may need to perform an update on a list of
text elements in my canvas.
The texts elements are Id and when I remove the object corresponding to the text, I have to
rename the other java objects and their corresponding text in the canvas.
This represent from 50 to 100 elements that can need to be updated.

Everything works fine but it tooks real long time to update the complete list.

At first, I was using a function to create my elements :

    private Element getElementFromText(....) {
        // We create the text element
        Element textGroup=svgDom.createElementNS(SVGConstants.SVG_NAMESPACE_URI,SVGConstants.SVG_TEXT_TAG);
        
        // We define its attributes
        ...

        ...
        Node numTextNode = svgDom.createTextNode(displayNum + " ");
        Node statusTextNode = svgDom.createTextNode(displayText);
        
        textGroup.appendChild(numTextNode);
        textGroup.appendChild(statusTextNode);

        MapActionIdToSVGElements.put(id, numTextNode);
        
        return textGroup;
    }


I also added a Map to wrap Id with corresponding Elements in my svgDoc. This will avoid several
getChild operations

This method allows me to create my svg content :
    
    <text style="text-anchor: middle; font-size: 3.3; fill: rgb(0,200,0)" id="TMTEXT2"
transform="translate(0,11.0) scale(1,-1)">
        0 F
    </text>


And now I can show you how i update this : 


The first method is called and just read the map and call a second function which update a
single element

    private void updateActionsLabel() {
        Set<Integer> s = MapActionIdToSVGElements.keySet();
        for(Integer i : s){
            modifyActionNumberInSVGDoc(i,"a");
        }
    }

    private boolean modifyActionNumberInSVGDoc(int id, String displayNum)
    {
        LogManager.getLogManager().log("TMCoreAdaptor>modifyActionNumberInSVGDoc", "call",
null, LogLevel.DEBUG);
        Node n = MapActionIdToSVGElements.get(id);
        n.setNodeValue("0 ");
        return true;
    }

I also added some "simple" timer (removed for this post) to get more info. Here are the results
Updating action labels
 ->  Updating action label 1 (0 ms)
 ->  Updating action label 2 (94 ms)
 ->  Updating action label 3 (78 ms)
 ->  Updating action label 4 (109 ms)
 ->  Updating action label 5 (79 ms)
...
 ->  Updating action label 8 (78 ms)
 ->  Updating action label 9 (438 ms)
 ->  Updating action label 10 (78 ms)
...
 ->  Updating action label 29 (79 ms)
 ->  Updating action label 28 (78 ms)
 ->  Updating action label 30 (625 ms)
...
 ->  Updating action label 52 (78 ms)
Update time 4813 ms


As you can see, there are very long update like #30 with 625ms and the first one is at 0ms....



I am new to Batik and i must have done something wrong ( I hope that is the problem... ).
I also hope, someone will
figure out what is happening there.  
I also tried some other things like :
- suspending the redraw ( same time for execution)
- setting documentstate to static ( better, but i have no refresh)
- removing listeners / adapters (no effect)

Thanks in advance for your help
Julien Beghin

_________________________________________________________________
Installez gratuitement les 20 émôticones Windows Live Messenger les plus fous ! Cliquez
ici !
http://www.emoticones-messenger.fr/
Mime
View raw message