Hi there,
I'm new to batik and tried to add some custom functions to the Rhino Interpreter as mentioned in docs/scripting.html. However I found out that the source example doesn't work.
| org.apache.batik.bridge BridgeContext ctx = ...;
I realized that "..." actually means
"svgCanvas.getUpdateManager().getBridgeContext();", however the
documentations doens't say anything about *where* this code should be
placed.
Actually it does:
For example if you are using the Batik SVGBrowser application you
should be able to use the previous piece of code on a subclass of
the JSVGCanvas class in the createBridgeContext() method.
This would be the 'best' place to put it for two reasons, firstly it would ensure that no-one has looked at the bridge context interpreter pool yet. And Second, see below...
Just after creation of the Canvas and loading the URL bridgeContext doesn't yet exist, so it would raise NullPointerException. Putting this code in the gvtBuildCompleted() method of the GVTTreeBuilderListener() worked for me, is it the right place?
This is pretty early in the processes and in particular I think it is before 'onload' dispatch so I think it would work but I think that the tutorial's suggestion is 'the right one'.
| org.apache.batik.script.InterpreterPool pool =
| new org.apache.batik.script.InterpreterPool();
| pool.putInterpreterFactory("text/ecmascript", | new ExtendedRhinoInterpreterFactory());
| ctx.setInterpreterPool(pool);
This would fail, because setInterpreterPool() is protected. I worked around this problem by patching batik sources and making this public, but I guess, this is not what users are supposed to do. Is there a better solution?
Yes, second you can change the constructor it calls so that it uses your interpreter pool rather than the default one (or subclass so you can call setInterpreterPool).
BTW, the example code in the docs contains three typos ("intepreter"
instead of "interpreter").
Thanks I'll take a look at fixing these.
P.S. Is this a bug or a feature that the line number in script errors is always relative to the beginning of the script and not the actual line number in the corresponding SVG file?
In the current version of Batik (1.5.1) it is improved somewhat, it includes the line in the SVG that the script starts and the line within in the script it's self. I think I recently noticed that an API exists to tell Rhino what line a piece of script actually starts on so it might be possible to have it merge these two.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
