You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by george moudry <gm...@mediaone.net> on 2001/09/18 21:55:46 UTC

Javascript question - can I cache dynamic classes

Hello Batikers, I am playing with w3.org's sample file
http://www.w3.org/Graphics/SVG/Test/20010127/interact-bubble-BE-04.html
and have a question regarding the batik code.

Every time I move my mouse over an object with an 
<g onmouseover="bubbleYes(evt, 'red')"...> script, 
a new java object gets generated and loaded into the VM from the Rhino engine.
This dynamic class is named something like 'org.mozilla.javascript.gen.c4'.
Is it possible to cache the generated code, 
and reuse next time I move the mouse?
Are there any thread safety issues to worry about?

Secondly, how much code is missing to actually redraw the image (ie. change 
the color of a circle in this example) after it has been initially rendrered?

Thanks,
george moudry
los angeles


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org


Re: Javascript question - can I cache dynamic classes

Posted by Christophe Jolif <cj...@ilog.fr>.
George,

george moudry wrote:

> Hello Batikers, I am playing with w3.org's sample file
> http://www.w3.org/Graphics/SVG/Test/20010127/interact-bubble-BE-04.html
> and have a question regarding the batik code.
> 
> Every time I move my mouse over an object with an
> <g onmouseover="bubbleYes(evt, 'red')"...> script,
> a new java object gets generated and loaded into the VM from the Rhino engine.
> This dynamic class is named something like 'org.mozilla.javascript.gen.c4'.
> Is it possible to cache the generated code,
> and reuse next time I move the mouse?
> Are there any thread safety issues to worry about?

Unfortunately I don't really have the time these days to investigate
your question. However I think we can assume that the new dynamic class
that you see is the result of the compilation (by the Rhino engine) of
the piece of code that is evaluated. In your case, the piece of code is:

"bubbleYes(evt, 'red')"

So the answer to your question is:

Yes, it could be posssible to implement a cache by compiling the piece
of script only once and then evaluating it the other times (currently we
compile and evaluate it each time). Of course the problem is not as
simple as this: the piece of code and/or the code that is called by this
piece of code may change during the timelife of the SVG file and in that
case the cache should be cleared. Anyway it is a good suggestion and I
will study that for later versions. Of course if you come up with a good
solution before that, don't hesitate to send it to the batik-dev list!

> Secondly, how much code is missing to actually redraw the image (ie. change
> the color of a circle in this example) after it has been initially rendrered?

In short: a lot of code. In details: if you want to do it cleverly (I
mean have smooth, fast and as limited as possible redraws) this requires
lot of coding, if you want to have a very basic but not really usefull
solution (I mean redraw nearly everything for each modification) it is
simpler. For your information the team aim is to have a dynamic support
in Batik.

(a little remark: you send you message to xml-batik-cvs mailing list
instead of batik-dev one, both are going to the same subscribers but not
necessarly in the same mail folders, so please use batik-dev or
batik-user for your questions not xml-batik-cvs).

-- 
Christophe

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org