Hi all !
Is this the correct way ti send an event to an element of a svg document loader in a SVGCanvas ?
this.m_svgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new Runnable() { public void run() { DocumentEvent de = null; Element element = null; try { SVGDocument document = m_svgCanvas.getSVGDocument(); element = document.getElementById("unload"); de = (DocumentEvent) document; } catch (Exception e) { // probabilemtne l’svg non è conforme al nostro protocollo e.printStackTrace(); } Event ev = (Event)de.createEvent("MouseEvents"); ev.initEvent("click",false,false); EventTarget t = (EventTarget) element; t.dispatchEvent(ev); /// ß----here sometimes stop for secs
} });
Normally it works. But when application (an applet) uses network sometimes execution flow hangs on method “ t.dispatchEvent(ev); “ The execution stops for a minnumum of 1 sec to a max of 10 sec on slow PC. Normally execution, also on slow PC, doesn’t stop on it. But the very strange think is that detaching Ethernet cable it always run well.
The method t.dispatchEvent(ev); causes a click event on an element with the attribute OnClick that call a Jscript function that do some Jscript work and finally call the method “Commit” of an extended Jscript interpreter :
… ExtendedInterpreter extends RhinoInterpreter { … public ExtendedInterpreter(URL docURL) { super(docURL); final String[] names = {"Initialize", "SetValue","GetValue","Commit","Finish"}; try { getGlobalObject().defineFunctionProperties(names, ExtendedInterpreter.class, ScriptableObject.DONTENUM); } catch (Exception e) { e.printStackTrace(); } } …
so execution goes in Java environment doing some works and at the of method returns in svg. Then call “Finish” that cause SVG to be unloaded and substituted with another svg document.
Dispathing event to the element permits Java -> SVG Jscript communication Extending RhinoInterpreter allows SVG JScript -> Java communication.
Is this a good way to obtain desired behaviour ? And if yes why that strange “thinking” when dispatching event to DOM only when application uses network ? (RMI and sockets)
The last thing to notice is that this happens only with recent nightly batik release (probably 03-11-27 ) but work always well with old downloadable batik jars.
I need to use new batik jar because of their good performance on very heavy (1000 png and lots Jscript) svg document.
Thx for help. Bye
Stefano.
P.S. Msg. Ciao Meo !!!
|
- Re: Sending event to SVG document loaded in JSVGCanvas Stefano Bruna
- Re: Sending event to SVG document loaded in JSVGCanvas Thomas DeWeese