hillion 02/02/13 05:47:44 Modified: sources/org/apache/batik/bridge ScriptingEnvironment.java Log: Modified the 'setTimeout' behavior: the pause is now done by the forked scripting thread, and a repaint is no more forced. Revision Changes Path 1.4 +37 -12 xml-batik/sources/org/apache/batik/bridge/ScriptingEnvironment.java Index: ScriptingEnvironment.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/ScriptingEnvironment.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ScriptingEnvironment.java 12 Feb 2002 15:14:37 -0000 1.3 +++ ScriptingEnvironment.java 13 Feb 2002 13:47:44 -0000 1.4 @@ -28,7 +28,7 @@ * This class contains the informations needed by the SVG scripting. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: ScriptingEnvironment.java,v 1.3 2002/02/12 15:14:37 tkormann Exp $ + * @version $Id: ScriptingEnvironment.java,v 1.4 2002/02/13 13:47:44 hillion Exp $ */ public class ScriptingEnvironment { @@ -113,12 +113,12 @@ return parameters; } public Object call(Object[] args) { - pauseScript(((Long)args[1]).longValue()); Object[] fargs = new Object[args.length - 2]; for (int i = 0; i < fargs.length; i++) { fargs[i] = args[i + 2]; } - runFunction((String)args[0], fargs, lang); + runFunction((String)args[0], fargs, lang, + ((Long)args[1]).longValue()); return null; } }; @@ -134,8 +134,11 @@ /** * Runs a function. */ - public void runFunction(String function, Object[] args, String lang) { - new FunctionCallThread(function, args, lang).start(); + public void runFunction(String function, + Object[] args, + String lang, + long delay) { + new FunctionCallThread(function, args, lang, delay).start(); } /** @@ -250,7 +253,11 @@ */ public void run() { if (interpreter != null) { - beginScript(); + try { + beginScript(); + } catch (StopScriptException e) { + return; + } try { interpreter.evaluate(getScript()); @@ -262,11 +269,10 @@ if (userAgent != null) { userAgent.displayError((ex != null) ? ex : ie); } - } finally { - try { - endScript(); - } catch (StopScriptException e) { - } + } + try { + endScript(); + } catch (StopScriptException e) { } } } @@ -284,14 +290,33 @@ protected class FunctionCallThread extends ScriptingThread { protected String function; protected Object[] arguments; + protected long delay; /** * Creates a new FunctionCallThread. */ - public FunctionCallThread(String fname, Object[] args, String lang) { + public FunctionCallThread(String fname, + Object[] args, + String lang, + long delay) { super(lang); function = fname; arguments = args; + this.delay = delay; + } + + /** + * The main method. + */ + public void run() { + if (delay > 0) { + try { + sleep(delay); + } catch (InterruptedException e) { + return; + } + } + super.run(); } /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]