xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From VEYSSIERE Nicolas <nicolas.veyssi...@thalesgroup.com>
Subject Invoke ecmascript method from java
Date Fri, 20 May 2011 13:21:26 GMT
Hello,

I am unable to call a method from java, here is my test :

SVG :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" width="100%"
height="100%" viewBox="0 0 70 15" id="svg">
                <script type="application/ecmascript">
                               function lTick()
                               {
                                               .....
                               }
                </script>
                <g>
                               ....
                </g>
</svg>

JAVA :

public class JHorlogeSVGCanvas extends JSVGCanvas
{
                private RhinoInterpreter ecmaInterpreter;

                public JHorlogeSVGCanvas()
                {
                               super();

                               initCanvas();
                }

                private void initCanvas()
                {
                               setURI(getClass().getResource("horloge.svg").toString());
                               setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
                               setBackground(Color.BLACK);
                               setDoubleBuffered(true);
                               setDoubleBufferedRendering(true);
                               setProgressivePaint(true);
                               setRecenterOnResize(true);
                               setOpaque(true);
                               setAnimationLimitingFPS(2);

                               addGVTTreeBuilderListener(new GVTTreeBuilderAdapter()
                               {
                                               @Override
                                               public void gvtBuildStarted(GVTTreeBuilderEvent
e)
                                               {
                                               }

                                               @Override
                                               public void gvtBuildCompleted(GVTTreeBuilderEvent
e)
                                               {
                                                               ecmaInterpreter = (RhinoInterpreter)bridgeContext.getInterpreter("application/ecmascript");

                                                               try
                                                               {
                                                                              ecmaInterpreter.evaluate("alert(2)");
                // OK
                                                                               ecmaInterpreter.evaluate("lTick
()");                    // error
                                                               }
                                                               catch(InterpreterException
e)
                                                               {
                                                                               e.printStackTrace();
                                                               }
                                               }
                               });
                }
}

Here is the error :

org.apache.batik.script.InterpreterException: ReferenceError: " lTick " n'est pas défini
(<SVG>#1)

I am using jdk 1.6u24 on windows, with Batik 1.7.


Can someone tell my where is my problem ?

Regards.

--


Mime
View raw message