Hi Olivier,

zze-DAROUX Olivier FTRD/DIH/GRE wrote:
Thanks for your answer.


I'm using batik for a R&D project and I've got a problem using

> the JSVGCanvas. In fact the problem is when I put the mouse > cursor in the canvas, it takes some seconds to highlight a shape > (by using onmouseover event, managed by java, not by ecma script). > Then moving the cursor highlights other shapes correctly, without > delay.

  Can you trace what the program is doing during this time?
When is your runnable called, when does your runnable exit?
Is it possible that the loading delay is your code?


What part do you want ? When I put the cursor over a shape ?
I made a test this morning, I loaded the svg in the canvas, avoiding to
move the cursor on it, and loaded the memory viewer. It indicates 7.7Mo.
I then move the cursor on the canvas, not on a shape, then it's not a
mouseover event, it's the canvas directly, and the monitor indicates
after 1s approx. 10Mo, it seems to load some classes no ? After that,
moving on a shape and highlighting it is immediate.

There are lots of things that could cause it to use 2.3Mb. Where do you register your event listeners? If you are registering individual event listeners on a large document (as per your example below it could take a bit). It sounds to me like something is just taking a long time when the document is loaded.

I so think that it's not a problem in my code (maybe I'm wrong :-)), or
it's in a part that I don't know (this could be that :-))
(How do I trace... ?)

Well on Windows if you run Batik from a DOS window you can press something like ctrl-'break' (the break key) and it will dump the stack trace for all threads. So you can look at what it is doing for those few seconds (i.e. who's code is running). It's probably worth doing a few times to get a more accurate picture.

Morever if I don't move the mouse over the canvas, updates made by

> java (using updatemanager) are not showed. (This my main problem, > the delay is accessory)

  So this really sounds like you are not using the UpdateManager's
RunnableQueue.  Can you post some code that shows how you post the
runnable?  Also an example runnable would be useful (best of course
is a standalone reproducable test case).

Well in fact I'm wrong, the updates are done, without moving on the canvas.

Ahh, that is good to hear. The code below looks good to me.


For the runnable :
queueAction.invokeLater(
    new Runnable() {
       public void run() {
           elt.setAttributeNS(null, "visibility", "visible");
       }
    }
);



where queueAction = canvas.getUpdateManager().getUpdateRunnableQueue();
This is not the method I use to highlight a shape but only the
setAttributeNS part changes :
elt.setAttributeNS(null, "class", "highlighted");

Hmm, I recently fixed a number of performance and propigation bugs in changing 'properties' in CSS. I am skeptical that the performance issues effect you since they would effect you for all changes not just the first one, but it is probably worth while to upgrade to current CVS if you are doing things like the above.

Sorry for the test case, I haven't one.


> In 1.5 release notes I saw that update's classes were > loaded lazily. > Could it be the problem I encounter ? Is there a mean to make them
> loaded at startup, not when firstly used ?


Actually, is this my problem ? :-)
(I use the updatemanager, then, it's not the problem)

I think this refered to the Java Scripting engine which it sounds like you are not using.

Well, registering a listener on the DOM tree using the following is not java scripting ?

No this is just DOM Events. In fact when using Java Script we register a normal Java DOM Event listener and use that to run the Java Script.

OnAction onAction = new OnAction(dynUpdt, this);
Element gSets = svgDoc.getElementById("sets");
NodeList nodeList = gSets.getChildNodes();

Couple of points here. First off DOM Event 'bubble' through the DOM tree so if you just registered listeners on the gSets element you would recieve any events that happen on the child elements.

int i=0;
Node elt;
while ((elt = nodeList.item(i++)) != null) {
  if (elt.getNodeName() != "#text") {

A better check is: (elt.getNodeType() == Node.ELEMENT_NODE) This faster and means you won't get tripped by CData sections or Comments.

    EventTarget t = (EventTarget)elt;
    t.addEventListener("mouseover", onAction.new Over(), false);
    t.addEventListener("mouseout", onAction.new Out(), false);
    t.addEventListener("click", onAction.new Click(), false);
  }
}



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



Reply via email to