tkormann 02/03/06 09:14:45
Modified: sources/org/apache/batik/bridge ScriptingEnvironment.java
UpdateManager.java
sources/org/apache/batik/transcoder/image
ImageTranscoder.java
Added: sources/org/apache/batik/bridge
BaseScriptingEnvironment.java
Log:
ImageTranscoder can now fire an SVG onload event on demand if the document
is dynamic
Revision Changes Path
1.11 +11 -316
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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ScriptingEnvironment.java 25 Feb 2002 15:14:24 -0000 1.10
+++ ScriptingEnvironment.java 6 Mar 2002 17:14:44 -0000 1.11
@@ -8,161 +8,31 @@
package org.apache.batik.bridge;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
-import org.apache.batik.dom.svg.SVGOMDocument;
-
-import org.apache.batik.dom.util.XLinkSupport;
-
import org.apache.batik.script.Interpreter;
import org.apache.batik.script.InterpreterException;
-import org.apache.batik.script.InterpreterPool;
import org.apache.batik.util.RunnableQueue;
-import org.apache.batik.util.SVGConstants;
import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.events.DocumentEvent;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
-import org.w3c.dom.events.EventTarget;
-
-import org.w3c.dom.svg.SVGSVGElement;
/**
* 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.10 2002/02/25 15:14:24 hillion Exp $
+ * @version $Id: ScriptingEnvironment.java,v 1.11 2002/03/06 17:14:44 tkormann Exp $
*/
-public class ScriptingEnvironment {
-
- /**
- * Tells whether the given SVG document is dynamic.
- */
- public static boolean isDynamicDocument(Document doc) {
- Element elt = doc.getDocumentElement();
- if (elt.getNamespaceURI().equals(SVGConstants.SVG_NAMESPACE_URI)) {
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONABORT_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONERROR_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONRESIZE_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONUNLOAD_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONSCROLL_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONZOOM_ATTRIBUTE).length() > 0) {
- return true;
- }
- return isDynamicElement(doc.getDocumentElement());
- }
- return false;
- }
-
- /**
- * Tells whether the given SVG element is dynamic.
- */
- public static boolean isDynamicElement(Element elt) {
- if (elt.getNamespaceURI().equals(SVGConstants.SVG_NAMESPACE_URI)) {
- String name = elt.getLocalName();
- if (name.equals(SVGConstants.SVG_SCRIPT_TAG)) {
- return true;
- }
- if (name.startsWith("animate") || name.equals("set")) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONERROR_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONACTIVATE_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONCLICK_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONFOCUSIN_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONFOCUSOUT_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONMOUSEDOWN_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONMOUSEMOVE_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONMOUSEOUT_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONMOUSEOVER_ATTRIBUTE).length() > 0) {
- return true;
- }
- if (elt.getAttributeNS
- (null, SVGConstants.SVG_ONMOUSEUP_ATTRIBUTE).length() > 0) {
- return true;
- }
-
- for (Node n = elt.getFirstChild();
- n != null;
- n = n.getNextSibling()) {
- if (n.getNodeType() == Node.ELEMENT_NODE) {
- if (isDynamicElement((Element)n)) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
-
- private final static String EVENT_NAME = "event";
- private final static String ALTERNATE_EVENT_NAME = "evt";
+public class ScriptingEnvironment extends BaseScriptingEnvironment {
/**
* The timer for periodic or delayed tasks.
*/
- Timer timer = new Timer(true);
+ protected Timer timer = new Timer(true);
/**
* The update manager.
@@ -170,64 +40,29 @@
protected UpdateManager updateManager;
/**
- * The repaint manager.
- */
- protected RepaintManager repaintManager;
-
- /**
* The update runnable queue.
*/
protected RunnableQueue updateRunnableQueue;
/**
- * The bridge context.
- */
- protected BridgeContext bridgeContext;
-
- /**
- * The user-agent.
- */
- protected UserAgent userAgent;
-
- /**
- * The document to manage.
- */
- protected Document document;
-
- /**
* Creates a new ScriptingEnvironment.
- * @param um The update manager.
+ * @param ctx the bridge context
*/
- public ScriptingEnvironment(UpdateManager um) {
- updateManager = um;
- bridgeContext = updateManager.getBridgeContext();
- userAgent = bridgeContext.getUserAgent();
- document = updateManager.getDocument();
- updateRunnableQueue = um.getUpdateRunnableQueue();
+ public ScriptingEnvironment(BridgeContext ctx) {
+ super(ctx);
+ updateManager = ctx.getUpdateManager();
+ updateRunnableQueue = updateManager.getUpdateRunnableQueue();
}
/**
* Creates a new Window object.
*/
- public Window createWindow(Interpreter interp, String lang) {
+ public org.apache.batik.script.Window createWindow
+ (Interpreter interp, String lang) {
return new Window(interp, lang);
}
/**
- * Creates a new Window object.
- */
- public Window createWindow() {
- return new Window(null, null);
- }
-
- /**
- * Initializes the environment of the given interpreter.
- */
- public void initializeEnvironment(Interpreter interp, String lang) {
- interp.bindObject("window", new Window(interp, lang));
- }
-
- /**
* Runs an event handler.
*/
public void runEventHandler(String script, Event evt, String lang) {
@@ -258,146 +93,6 @@
}
/**
- * Loads the scripts contained in the <script> elements.
- */
- public void loadScripts() {
- NodeList scripts = document.getElementsByTagNameNS
- (SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_SCRIPT_TAG);
- int len = scripts.getLength();
-
- if (len == 0) {
- return;
- }
-
- Set languages = new HashSet();
-
- for (int i = 0; i < len; i++) {
- Element script = (Element)scripts.item(i);
- String type = script.getAttributeNS
- (null, SVGConstants.SVG_TYPE_ATTRIBUTE);
- Interpreter interpreter = bridgeContext.getInterpreter(type);
-
- if (interpreter == null) {
- UserAgent ua = bridgeContext.getUserAgent();
- if (ua != null) {
- ua.displayError(new Exception("Unknown language: "+type));
- }
- return;
- }
-
- if (!languages.contains(type)) {
- languages.add(type);
- initializeEnvironment(interpreter, type);
- }
-
- try {
- String href = XLinkSupport.getXLinkHref(script);
- Reader reader;
- if (href.length() > 0) {
- // External script.
- URL url = new URL(((SVGOMDocument)document).getURLObject(),
- href);
- reader = new InputStreamReader(url.openStream());
- } else {
- // Inline script.
- Node n = script.getFirstChild();
- if (n != null) {
- StringBuffer sb = new StringBuffer();
- while (n != null) {
- sb.append(n.getNodeValue());
- n = n.getNextSibling();
- }
- reader = new StringReader(sb.toString());
- } else {
- continue;
- }
- }
-
- interpreter.evaluate(reader);
-
- } catch (IOException e) {
- if (userAgent != null) {
- userAgent.displayError(e);
- }
- return;
- } catch (InterpreterException e) {
- handleInterpreterException(e);
- return;
- }
- }
- }
-
- /**
- * Recursively dispatch the SVG 'onload' event.
- */
- public void dispatchSVGLoadEvent() {
- SVGSVGElement root =
- (SVGSVGElement)document.getDocumentElement();
- String lang = root.getContentScriptType();
- Interpreter interp = bridgeContext.getInterpreter(lang);
- if (interp == null) {
- UserAgent ua = bridgeContext.getUserAgent();
- if (ua != null) {
- ua.displayError(new Exception("Unknown language: " + lang));
- }
- return;
- }
- dispatchSVGLoad(root, interp);
- }
-
- /**
- * Auxiliary method for dispatchSVGLoad.
- */
- protected void dispatchSVGLoad(Element elt, final Interpreter interp) {
- for (Node n = elt.getFirstChild();
- n != null;
- n = n.getNextSibling()) {
- if (n.getNodeType() == n.ELEMENT_NODE) {
- dispatchSVGLoad((Element)n, interp);
- }
- }
-
- Event ev;
- DocumentEvent de = (DocumentEvent)elt.getOwnerDocument();
- ev = de.createEvent("SVGEvents");
- ev.initEvent("SVGLoad", false, false);
- EventTarget t = (EventTarget)elt;
-
- final String s =
- elt.getAttributeNS(null, SVGConstants.SVG_ONLOAD_ATTRIBUTE);
- EventListener l = null;
- if (s.length() > 0) {
- l = new EventListener() {
- public void handleEvent(Event evt) {
- try {
- interp.bindObject(EVENT_NAME, evt);
- interp.bindObject(ALTERNATE_EVENT_NAME, evt);
- interp.evaluate(new StringReader(s));
- } catch (IOException io) {
- } catch (InterpreterException e) {
- handleInterpreterException(e);
- }
- }
- };
- t.addEventListener("SVGLoad", l, false);
- }
- t.dispatchEvent(ev);
- if (s.length() > 0) {
- t.removeEventListener("SVGLoad", l, false);
- }
- }
-
- /**
- * Handles the given exception.
- */
- protected void handleInterpreterException(InterpreterException ie) {
- if (userAgent != null) {
- Exception ex = ie.getException();
- userAgent.displayError((ex == null) ? ie : ex);
- }
- }
-
- /**
* To wrap an event listener.
*/
protected class EventListenerWrapper implements EventListener {
@@ -493,7 +188,7 @@
/**
* Represents the window object of this environment.
*/
- public class Window implements org.apache.batik.script.Window {
+ protected class Window implements org.apache.batik.script.Window {
/**
* The associated interpreter.
1.15 +3 -3 xml-batik/sources/org/apache/batik/bridge/UpdateManager.java
Index: UpdateManager.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/UpdateManager.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- UpdateManager.java 6 Mar 2002 13:56:25 -0000 1.14
+++ UpdateManager.java 6 Mar 2002 17:14:44 -0000 1.15
@@ -41,7 +41,7 @@
* This class provides features to manage the update of an SVG document.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: UpdateManager.java,v 1.14 2002/03/06 13:56:25 hillion Exp $
+ * @version $Id: UpdateManager.java,v 1.15 2002/03/06 17:14:44 tkormann Exp $
*/
public class UpdateManager implements RunnableQueue.RunHandler {
@@ -49,7 +49,7 @@
* Tells whether the given SVG document is dynamic.
*/
public static boolean isDynamicDocument(Document doc) {
- return ScriptingEnvironment.isDynamicDocument(doc);
+ return BaseScriptingEnvironment.isDynamicDocument(doc);
}
/**
@@ -126,7 +126,7 @@
graphicsNode = gn;
- scriptingEnvironment = new ScriptingEnvironment(this);
+ scriptingEnvironment = new ScriptingEnvironment(ctx);
}
/**
1.1
xml-batik/sources/org/apache/batik/bridge/BaseScriptingEnvironment.java
Index: BaseScriptingEnvironment.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.batik.bridge;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
import java.net.URL;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.batik.dom.svg.SVGOMDocument;
import org.apache.batik.dom.util.XLinkSupport;
import org.apache.batik.script.Interpreter;
import org.apache.batik.script.InterpreterException;
import org.apache.batik.util.SVGConstants;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.events.DocumentEvent;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
import org.w3c.dom.svg.SVGSVGElement;
/**
* This class is the base class for SVG scripting.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
* @version $Id: BaseScriptingEnvironment.java,v 1.1 2002/03/06 17:14:44 tkormann
Exp $
*/
public class BaseScriptingEnvironment {
/**
* Tells whether the given SVG document is dynamic.
*/
public static boolean isDynamicDocument(Document doc) {
Element elt = doc.getDocumentElement();
if (elt.getNamespaceURI().equals(SVGConstants.SVG_NAMESPACE_URI)) {
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONABORT_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONERROR_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONRESIZE_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONUNLOAD_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONSCROLL_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONZOOM_ATTRIBUTE).length() > 0) {
return true;
}
return isDynamicElement(doc.getDocumentElement());
}
return false;
}
/**
* Tells whether the given SVG element is dynamic.
*/
public static boolean isDynamicElement(Element elt) {
if (elt.getNamespaceURI().equals(SVGConstants.SVG_NAMESPACE_URI)) {
String name = elt.getLocalName();
if (name.equals(SVGConstants.SVG_SCRIPT_TAG)) {
return true;
}
if (name.startsWith("animate") || name.equals("set")) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONERROR_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONACTIVATE_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONCLICK_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONFOCUSIN_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONFOCUSOUT_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONMOUSEDOWN_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONMOUSEMOVE_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONMOUSEOUT_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONMOUSEOVER_ATTRIBUTE).length() > 0) {
return true;
}
if (elt.getAttributeNS
(null, SVGConstants.SVG_ONMOUSEUP_ATTRIBUTE).length() > 0) {
return true;
}
for (Node n = elt.getFirstChild();
n != null;
n = n.getNextSibling()) {
if (n.getNodeType() == Node.ELEMENT_NODE) {
if (isDynamicElement((Element)n)) {
return true;
}
}
}
}
return false;
}
protected final static String EVENT_NAME = "event";
protected final static String ALTERNATE_EVENT_NAME = "evt";
/**
* The bridge context.
*/
protected BridgeContext bridgeContext;
/**
* The user-agent.
*/
protected UserAgent userAgent;
/**
* The document to manage.
*/
protected Document document;
/**
* Creates a new BaseScriptingEnvironment.
* @param ctx the bridge context
*/
public BaseScriptingEnvironment(BridgeContext ctx) {
bridgeContext = ctx;
document = ctx.getDocument();
userAgent = bridgeContext.getUserAgent();
}
/**
* Creates a new Window object.
*/
public org.apache.batik.script.Window createWindow
(Interpreter interp, String lang) {
return new Window(interp, lang);
}
/**
* Creates a new Window object.
*/
public org.apache.batik.script.Window createWindow() {
return createWindow(null, null);
}
/**
* Initializes the environment of the given interpreter.
*/
public void initializeEnvironment(Interpreter interp, String lang) {
interp.bindObject("window", createWindow(interp, lang));
}
/**
* Loads the scripts contained in the <script> elements.
*/
public void loadScripts() {
NodeList scripts = document.getElementsByTagNameNS
(SVGConstants.SVG_NAMESPACE_URI, SVGConstants.SVG_SCRIPT_TAG);
int len = scripts.getLength();
if (len == 0) {
return;
}
Set languages = new HashSet();
for (int i = 0; i < len; i++) {
Element script = (Element)scripts.item(i);
String type = script.getAttributeNS
(null, SVGConstants.SVG_TYPE_ATTRIBUTE);
Interpreter interpreter = bridgeContext.getInterpreter(type);
if (interpreter == null) {
UserAgent ua = bridgeContext.getUserAgent();
if (ua != null) {
ua.displayError(new Exception("Unknown language: "+type));
}
return;
}
if (!languages.contains(type)) {
languages.add(type);
initializeEnvironment(interpreter, type);
}
try {
String href = XLinkSupport.getXLinkHref(script);
Reader reader;
if (href.length() > 0) {
// External script.
URL url = new URL(((SVGOMDocument)document).getURLObject(),
href);
reader = new InputStreamReader(url.openStream());
} else {
// Inline script.
Node n = script.getFirstChild();
if (n != null) {
StringBuffer sb = new StringBuffer();
while (n != null) {
sb.append(n.getNodeValue());
n = n.getNextSibling();
}
reader = new StringReader(sb.toString());
} else {
continue;
}
}
interpreter.evaluate(reader);
} catch (IOException e) {
if (userAgent != null) {
userAgent.displayError(e);
}
return;
} catch (InterpreterException e) {
handleInterpreterException(e);
return;
}
}
}
/**
* Recursively dispatch the SVG 'onload' event.
*/
public void dispatchSVGLoadEvent() {
SVGSVGElement root =
(SVGSVGElement)document.getDocumentElement();
String lang = root.getContentScriptType();
Interpreter interp = bridgeContext.getInterpreter(lang);
if (interp == null) {
UserAgent ua = bridgeContext.getUserAgent();
if (ua != null) {
ua.displayError(new Exception("Unknown language: " + lang));
}
return;
}
dispatchSVGLoad(root, interp);
}
/**
* Auxiliary method for dispatchSVGLoad.
*/
protected void dispatchSVGLoad(Element elt, final Interpreter interp) {
for (Node n = elt.getFirstChild();
n != null;
n = n.getNextSibling()) {
if (n.getNodeType() == n.ELEMENT_NODE) {
dispatchSVGLoad((Element)n, interp);
}
}
Event ev;
DocumentEvent de = (DocumentEvent)elt.getOwnerDocument();
ev = de.createEvent("SVGEvents");
ev.initEvent("SVGLoad", false, false);
EventTarget t = (EventTarget)elt;
final String s =
elt.getAttributeNS(null, SVGConstants.SVG_ONLOAD_ATTRIBUTE);
EventListener l = null;
if (s.length() > 0) {
l = new EventListener() {
public void handleEvent(Event evt) {
try {
interp.bindObject(EVENT_NAME, evt);
interp.bindObject(ALTERNATE_EVENT_NAME, evt);
interp.evaluate(new StringReader(s));
} catch (IOException io) {
} catch (InterpreterException e) {
handleInterpreterException(e);
}
}
};
t.addEventListener("SVGLoad", l, false);
}
t.dispatchEvent(ev);
if (s.length() > 0) {
t.removeEventListener("SVGLoad", l, false);
}
}
/**
* Handles the given exception.
*/
protected void handleInterpreterException(InterpreterException ie) {
if (userAgent != null) {
Exception ex = ie.getException();
userAgent.displayError((ex == null) ? ie : ex);
}
}
/**
* Represents the window object of this environment.
*/
protected class Window implements org.apache.batik.script.Window {
/**
* The associated interpreter.
*/
protected Interpreter interpreter;
/**
* The associated language.
*/
protected String language;
/**
* Creates a new Window.
*/
public Window(Interpreter interp, String lang) {
interpreter = interp;
language = lang;
}
/**
* Implements {@link
* org.apache.batik.script.Window#setInterval(String,long)}.
*/
public Object setInterval(final String script, long interval) {
return null;
}
/**
* Implements {@link
* org.apache.batik.script.Window#setInterval(Runnable,long)}.
*/
public Object setInterval(final Runnable r, long interval) {
return null;
}
/**
* Implements {@link
* org.apache.batik.script.Window#clearInterval(Object)}.
*/
public void clearInterval(Object interval) {
}
/**
* Implements {@link
* org.apache.batik.script.Window#setTimeout(String,long)}.
*/
public Object setTimeout(final String script, long timeout) {
return null;
}
/**
* Implements {@link
* org.apache.batik.script.Window#setTimeout(Runnable,long)}.
*/
public Object setTimeout(final Runnable r, long timeout) {
return null;
}
/**
* Implements {@link
* org.apache.batik.script.Window#clearTimeout(Object)}.
*/
public void clearTimeout(Object timeout) {
}
/**
* Displays an alert dialog box.
*/
public void alert(String message) {
}
/**
* Displays a confirm dialog box.
*/
public boolean confirm(String message) {
return false;
}
/**
* Displays an input dialog box.
*/
public String prompt(String message) {
return null;
}
/**
* Displays an input dialog box, given the default value.
*/
public String prompt(String message, String defVal) {
return null;
}
/**
* Returns the associated interpreter.
*/
public Interpreter getInterpreter() {
return interpreter;
}
}
}
1.36 +41 -1
xml-batik/sources/org/apache/batik/transcoder/image/ImageTranscoder.java
Index: ImageTranscoder.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/transcoder/image/ImageTranscoder.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- ImageTranscoder.java 4 Mar 2002 08:38:43 -0000 1.35
+++ ImageTranscoder.java 6 Mar 2002 17:14:45 -0000 1.36
@@ -29,6 +29,7 @@
import java.util.Iterator;
import java.util.Set;
+import org.apache.batik.bridge.BaseScriptingEnvironment;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.BridgeException;
import org.apache.batik.bridge.BridgeExtension;
@@ -100,7 +101,7 @@
* millimeter conversion factor.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
- * @version $Id: ImageTranscoder.java,v 1.35 2002/03/04 08:38:43 tkormann Exp $
+ * @version $Id: ImageTranscoder.java,v 1.36 2002/03/06 17:14:45 tkormann Exp $
*/
public abstract class ImageTranscoder extends XMLAbstractTranscoder {
@@ -119,6 +120,8 @@
ExtensibleSVGDOMImplementation.getDOMImplementation());
hints.put(KEY_MEDIA,
"screen");
+ hints.put(KEY_EXECUTE_ONLOAD,
+ Boolean.FALSE);
}
/**
@@ -156,9 +159,22 @@
GVTBuilder builder = new GVTBuilder();
ImageRendererFactory rendFactory = new ConcreteImageRendererFactory();
BridgeContext ctx = new BridgeContext(userAgent);
+ // flag that indicates if the document is dynamic
+ boolean isDynamic =
+ (hints.containsKey(KEY_EXECUTE_ONLOAD) &&
+ ((Boolean)hints.get(KEY_EXECUTE_ONLOAD)).booleanValue() &&
+ BaseScriptingEnvironment.isDynamicDocument(svgDoc));
+ ctx.setDynamic(isDynamic);
+
GraphicsNode gvtRoot;
try {
gvtRoot = builder.build(ctx, svgDoc);
+ // dispatch an 'onload' event if needed
+ if (ctx.isDynamic()) {
+ BaseScriptingEnvironment se = new BaseScriptingEnvironment(ctx);
+ se.loadScripts();
+ se.dispatchSVGLoadEvent();
+ }
} catch (BridgeException ex) {
throw new TranscoderException(ex);
}
@@ -497,6 +513,30 @@
// --------------------------------------------------------------------
// Keys definition
// --------------------------------------------------------------------
+
+ /**
+ * The 'onload' execution key.
+ * <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Key: </TH>
+ * <TD VALIGN="TOP">KEY_EXECUTE_ONLOAD</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Value: </TH>
+ * <TD VALIGN="TOP">Boolean</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Default: </TH>
+ * <TD VALIGN="TOP">false</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Required: </TH>
+ * <TD VALIGN="TOP">No</TD></TR>
+ * <TR>
+ * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN="RIGHT">Description: </TH>
+ * <TD VALIGN="TOP">Specify if scripts added on the 'onload' event
+ * attribute must be invoked.</TD></TR>
+ * </TABLE>
+ */
+ public static final TranscodingHints.Key KEY_EXECUTE_ONLOAD
+ = new BooleanKey();
/**
* The image width key.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]