You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2013/10/08 16:03:23 UTC
[08/62] [abbrv] [partial] Merged Apache Flex 4.9.0 release branch
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ScriptingEnvironment.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ScriptingEnvironment.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ScriptingEnvironment.java
index 9eaa54a..ee7baf9 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ScriptingEnvironment.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/ScriptingEnvironment.java
@@ -1,10 +1,11 @@
/*
- Copyright 2002-2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -18,37 +19,39 @@
package org.apache.flex.forks.batik.bridge;
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
-
import java.net.URL;
import java.net.URLConnection;
-
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
-import java.util.zip.GZIPOutputStream;
import java.util.zip.DeflaterOutputStream;
+import java.util.zip.GZIPOutputStream;
import org.apache.flex.forks.batik.dom.GenericDOMImplementation;
+import org.apache.flex.forks.batik.dom.events.NodeEventTarget;
import org.apache.flex.forks.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.flex.forks.batik.dom.svg.SVGOMDocument;
+import org.apache.flex.forks.batik.dom.util.DOMUtilities;
import org.apache.flex.forks.batik.dom.util.SAXDocumentFactory;
import org.apache.flex.forks.batik.dom.util.XLinkSupport;
import org.apache.flex.forks.batik.script.Interpreter;
import org.apache.flex.forks.batik.script.InterpreterException;
+import org.apache.flex.forks.batik.script.ScriptEventWrapper;
import org.apache.flex.forks.batik.util.EncodingUtilities;
import org.apache.flex.forks.batik.util.ParsedURL;
import org.apache.flex.forks.batik.util.RunnableQueue;
import org.apache.flex.forks.batik.util.SVGConstants;
+import org.apache.flex.forks.batik.util.XMLConstants;
import org.apache.flex.forks.batik.util.XMLResourceDescriptor;
import org.w3c.dom.Document;
@@ -56,44 +59,30 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
-import org.w3c.dom.events.EventTarget;
import org.w3c.dom.events.MutationEvent;
-import org.w3c.flex.forks.dom.svg.SVGDocument;
+import org.w3c.dom.svg.SVGDocument;
/**
* This class contains the informations needed by the SVG scripting.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: ScriptingEnvironment.java,v 1.49 2005/04/02 14:26:09 deweese Exp $
+ * @version $Id: ScriptingEnvironment.java 594367 2007-11-13 00:40:53Z cam $
*/
public class ScriptingEnvironment extends BaseScriptingEnvironment {
- /**
- * Used in 'parseXML()'.
- */
- protected final static String FRAGMENT_PREFIX =
- "<svg xmlns='" +
- SVGConstants.SVG_NAMESPACE_URI +
- "' xmlns:xlink='" +
- XLinkSupport.XLINK_NAMESPACE_URI +
- "'>";
-
- protected final static String FRAGMENT_SUFFIX =
- "</svg>";
-
- public final static String [] SVG_EVENT_ATTRS = {
+ public static final String [] SVG_EVENT_ATTRS = {
"onabort", // SVG element
"onerror", // SVG element
"onresize", // SVG element
"onscroll", // SVG element
"onunload", // SVG element
"onzoom", // SVG element
-
+
"onbegin", // SMIL
"onend", // SMIL
"onrepeat", // SMIL
- "onfocusin", // UI Events
+ "onfocusin", // UI Events
"onfocusout", // UI Events
"onactivate", // UI Events
"onclick", // UI Events
@@ -106,22 +95,22 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
"onkeypress", // UI Events
"onkeydown", // UI Events
- "onkeyup" // UI Events
+ "onkeyup" // UI Events
};
- public final static String [] SVG_DOM_EVENT = {
+ public static final String [] SVG_DOM_EVENT = {
"SVGAbort", // SVG element
"SVGError", // SVG element
"SVGResize", // SVG element
"SVGScroll", // SVG element
"SVGUnload", // SVG element
"SVGZoom", // SVG element
-
+
"beginEvent", // SMIL
"endEvent", // SMIL
"repeatEvent", // SMIL
- "DOMFocusIn", // UI Events
+ "DOMFocusIn", // UI Events
"DOMFocusOut", // UI Events
"DOMActivate", // UI Events
"click", // UI Events
@@ -132,7 +121,7 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
"mousemove", // UI Events
"keypress", // UI Events
"keydown", // UI Events
- "keyup" // UI Events
+ "keyup" // UI Events
};
/**
@@ -153,20 +142,17 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
/**
* The DOMNodeInserted event listener.
*/
- protected EventListener domNodeInsertedListener
- = new DOMNodeInsertedListener();
+ protected EventListener domNodeInsertedListener;
/**
* The DOMNodeRemoved event listener.
*/
- protected EventListener domNodeRemovedListener
- = new DOMNodeRemovedListener();
+ protected EventListener domNodeRemovedListener;
/**
* The DOMAttrModified event listener.
*/
- protected EventListener domAttrModifiedListener
- = new DOMAttrModifiedListener();
+ protected EventListener domAttrModifiedListener;
/**
* The SVGAbort event listener.
@@ -294,7 +280,7 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
protected EventListener keyupListener =
new ScriptingEventListener("onkeyup");
-
+
protected EventListener [] listeners = {
svgAbortListener,
svgErrorListener,
@@ -340,21 +326,47 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
super(ctx);
updateManager = ctx.getUpdateManager();
updateRunnableQueue = updateManager.getUpdateRunnableQueue();
-
+
// Add the scripting listeners.
addScriptingListeners(document.getDocumentElement());
// Add the listeners responsible of updating the event attributes
- EventTarget et = (EventTarget)document;
- et.addEventListener("DOMNodeInserted",
- domNodeInsertedListener,
- false);
- et.addEventListener("DOMNodeRemoved",
- domNodeRemovedListener,
- false);
- et.addEventListener("DOMAttrModified",
- domAttrModifiedListener,
- false);
+ addDocumentListeners();
+ }
+
+ /**
+ * Adds DOM listeners to the document.
+ */
+ protected void addDocumentListeners() {
+ domNodeInsertedListener = new DOMNodeInsertedListener();
+ domNodeRemovedListener = new DOMNodeRemovedListener();
+ domAttrModifiedListener = new DOMAttrModifiedListener();
+ NodeEventTarget et = (NodeEventTarget) document;
+ et.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeInserted",
+ domNodeInsertedListener, false, null);
+ et.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeRemoved",
+ domNodeRemovedListener, false, null);
+ et.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMAttrModified",
+ domAttrModifiedListener, false, null);
+ }
+
+ /**
+ * Removes DOM listeners from the document.
+ */
+ protected void removeDocumentListeners() {
+ NodeEventTarget et = (NodeEventTarget) document;
+ et.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeInserted",
+ domNodeInsertedListener, false);
+ et.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMNodeRemoved",
+ domNodeRemovedListener, false);
+ et.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMAttrModified",
+ domAttrModifiedListener, false);
}
/**
@@ -368,7 +380,7 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
/**
* Runs an event handler.
*/
- public void runEventHandler(String script, Event evt,
+ public void runEventHandler(String script, Event evt,
String lang, String desc) {
Interpreter interpreter = getInterpreter(lang);
if (interpreter == null)
@@ -377,8 +389,14 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
try {
checkCompatibleScriptURL(lang, docPURL);
- interpreter.bindObject(EVENT_NAME, evt);
- interpreter.bindObject(ALTERNATE_EVENT_NAME, evt);
+ Object event;
+ if (evt instanceof ScriptEventWrapper) {
+ event = ((ScriptEventWrapper) evt).getEventObject();
+ } else {
+ event = evt;
+ }
+ interpreter.bindObject(EVENT_NAME, event);
+ interpreter.bindObject(ALTERNATE_EVENT_NAME, event);
interpreter.evaluate(new StringReader(script), desc);
} catch (IOException ioe) {
// Do nothing, can't really happen with StringReader
@@ -398,117 +416,16 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
removeScriptingListeners(document.getDocumentElement());
// Remove the listeners responsible of updating the event attributes
- EventTarget et = (EventTarget)document;
- et.removeEventListener("DOMNodeInserted",
- domNodeInsertedListener,
- false);
- et.removeEventListener("DOMNodeRemoved",
- domNodeRemovedListener,
- false);
- et.removeEventListener("DOMAttrModified",
- domAttrModifiedListener,
- false);
+ removeDocumentListeners();
}
/**
- * Adds the scripting listeners to the given element.
+ * Adds the scripting listeners to the given element and all of
+ * its descendants.
*/
- protected void addScriptingListeners(Node node) {
+ public void addScriptingListeners(Node node) {
if (node.getNodeType() == Node.ELEMENT_NODE) {
- // Attach the listeners
- Element elt = (Element)node;
- EventTarget target = (EventTarget)elt;
- if (SVGConstants.SVG_NAMESPACE_URI.equals(elt.getNamespaceURI())) {
- if (SVGConstants.SVG_SVG_TAG.equals(elt.getLocalName())) {
- // <svg> listeners
- if (elt.hasAttributeNS(null, "onabort")) {
- target.addEventListener("SVGAbort",
- svgAbortListener, false);
- }
- if (elt.hasAttributeNS(null, "onerror")) {
- target.addEventListener("SVGError",
- svgErrorListener, false);
- }
- if (elt.hasAttributeNS(null, "onresize")) {
- target.addEventListener("SVGResize",
- svgResizeListener, false);
- }
- if (elt.hasAttributeNS(null, "onscroll")) {
- target.addEventListener("SVGScroll",
- svgScrollListener, false);
- }
- if (elt.hasAttributeNS(null, "onunload")) {
- target.addEventListener("SVGUnload",
- svgUnloadListener, false);
- }
- if (elt.hasAttributeNS(null, "onzoom")) {
- target.addEventListener("SVGZoom",
- svgZoomListener, false);
- }
- } else {
- String name = elt.getLocalName();
- if (name.equals(SVGConstants.SVG_SET_TAG) ||
- name.startsWith("animate")) {
- // animation listeners
- if (elt.hasAttributeNS(null, "onbegin")) {
- target.addEventListener("beginEvent",
- beginListener ,
- false);
- }
- if (elt.hasAttributeNS(null, "onend")) {
- target.addEventListener("endEvent",
- endListener,
- false);
- }
- if (elt.hasAttributeNS(null, "onrepeat")) {
- target.addEventListener("repeatEvent",
- repeatListener ,
- false);
- }
- return;
- }
- }
- }
-
- // UI listeners
- if (elt.hasAttributeNS(null, "onfocusin")) {
- target.addEventListener("DOMFocusIn", focusinListener, false);
- }
- if (elt.hasAttributeNS(null, "onfocusout")) {
- target.addEventListener("DOMFocusOut", focusoutListener,
- false);
- }
- if (elt.hasAttributeNS(null, "onactivate")) {
- target.addEventListener("DOMActivate", activateListener,
- false);
- }
- if (elt.hasAttributeNS(null, "onclick")) {
- target.addEventListener("click", clickListener, false);
- }
- if (elt.hasAttributeNS(null, "onmousedown")) {
- target.addEventListener("mousedown", mousedownListener, false);
- }
- if (elt.hasAttributeNS(null, "onmouseup")) {
- target.addEventListener("mouseup", mouseupListener, false);
- }
- if (elt.hasAttributeNS(null, "onmouseover")) {
- target.addEventListener("mouseover", mouseoverListener, false);
- }
- if (elt.hasAttributeNS(null, "onmouseout")) {
- target.addEventListener("mouseout", mouseoutListener, false);
- }
- if (elt.hasAttributeNS(null, "onmousemove")) {
- target.addEventListener("mousemove", mousemoveListener, false);
- }
- if (elt.hasAttributeNS(null, "onkeypress")) {
- target.addEventListener("keypress", keypressListener, false);
- }
- if (elt.hasAttributeNS(null, "onkeydown")) {
- target.addEventListener("keydown", keydownListener, false);
- }
- if (elt.hasAttributeNS(null, "onkeyup")) {
- target.addEventListener("keyup", keyupListener, false);
- }
+ addScriptingListenersOn((Element) node);
}
// Adds the listeners to the children
@@ -520,60 +437,140 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
}
/**
- * Removes the scripting listeners from the given element.
+ * Adds the scripting listeners to the given element.
*/
- protected void removeScriptingListeners(Node node) {
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- // Detach the listeners
- Element elt = (Element)node;
- EventTarget target = (EventTarget)elt;
- if (SVGConstants.SVG_NAMESPACE_URI.equals(elt.getNamespaceURI())) {
- if (SVGConstants.SVG_SVG_TAG.equals(elt.getLocalName())) {
- // <svg> listeners
- target.removeEventListener("SVGAbort",
- svgAbortListener, false);
- target.removeEventListener("SVGError",
- svgErrorListener, false);
- target.removeEventListener("SVGResize",
- svgResizeListener, false);
- target.removeEventListener("SVGScroll",
- svgScrollListener, false);
- target.removeEventListener("SVGUnload",
- svgUnloadListener, false);
- target.removeEventListener("SVGZoom",
- svgZoomListener, false);
- } else {
- String name = elt.getLocalName();
- if (name.equals(SVGConstants.SVG_SET_TAG) ||
- name.startsWith("animate")) {
- // animation listeners
- target.removeEventListener("beginEvent",
- beginListener ,
- false);
- target.removeEventListener("endEvent",
- endListener,
- false);
- target.removeEventListener("repeatEvent",
- repeatListener ,
- false);
- return;
+ protected void addScriptingListenersOn(Element elt) {
+ // Attach the listeners
+ NodeEventTarget target = (NodeEventTarget)elt;
+ if (SVGConstants.SVG_NAMESPACE_URI.equals(elt.getNamespaceURI())) {
+ if (SVGConstants.SVG_SVG_TAG.equals(elt.getLocalName())) {
+ // <svg> listeners
+ if (elt.hasAttributeNS(null, "onabort")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "SVGAbort",
+ svgAbortListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onerror")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "SVGError",
+ svgErrorListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onresize")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "SVGResize",
+ svgResizeListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onscroll")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "SVGScroll",
+ svgScrollListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onunload")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "SVGUnload",
+ svgUnloadListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onzoom")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "SVGZoom",
+ svgZoomListener, false, null);
+ }
+ } else {
+ String name = elt.getLocalName();
+ if (name.equals(SVGConstants.SVG_SET_TAG) ||
+ name.startsWith("animate")) {
+ // animation listeners
+ if (elt.hasAttributeNS(null, "onbegin")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "beginEvent",
+ beginListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onend")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "endEvent",
+ endListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onrepeat")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "repeatEvent",
+ repeatListener, false, null);
}
+ return;
}
}
+ }
- // UI listeners
- target.removeEventListener("DOMFocusIn", focusinListener, false);
- target.removeEventListener("DOMFocusOut", focusoutListener, false);
- target.removeEventListener("DOMActivate", activateListener, false);
- target.removeEventListener("click", clickListener, false);
- target.removeEventListener("mousedown", mousedownListener, false);
- target.removeEventListener("mouseup", mouseupListener, false);
- target.removeEventListener("mouseover", mouseoverListener, false);
- target.removeEventListener("mouseout", mouseoutListener, false);
- target.removeEventListener("mousemove", mousemoveListener, false);
- target.removeEventListener("keypress", keypressListener, false);
- target.removeEventListener("keydown", keydownListener, false);
- target.removeEventListener("keyup", keyupListener, false);
+ // UI listeners
+ if (elt.hasAttributeNS(null, "onfocusin")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMFocusIn",
+ focusinListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onfocusout")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMFocusOut",
+ focusoutListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onactivate")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMActivate",
+ activateListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onclick")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "click",
+ clickListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onmousedown")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "mousedown",
+ mousedownListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onmouseup")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "mouseup",
+ mouseupListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onmouseover")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "mouseover",
+ mouseoverListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onmouseout")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "mouseout",
+ mouseoutListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onmousemove")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "mousemove",
+ mousemoveListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onkeypress")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "keypress",
+ keypressListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onkeydown")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "keydown",
+ keydownListener, false, null);
+ }
+ if (elt.hasAttributeNS(null, "onkeyup")) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "keyup",
+ keyupListener, false, null);
+ }
+ }
+
+ /**
+ * Removes the scripting listeners from the given element and all
+ * of its descendants.
+ */
+ protected void removeScriptingListeners(Node node) {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ // Detach the listeners
+ removeScriptingListenersOn((Element) node);
}
// Removes the listeners from the children
@@ -585,19 +582,110 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
}
/**
+ * Removes the scripting listeners from the given element.
+ */
+ protected void removeScriptingListenersOn(Element elt) {
+ NodeEventTarget target = (NodeEventTarget)elt;
+ if (SVGConstants.SVG_NAMESPACE_URI.equals(elt.getNamespaceURI())) {
+ if (SVGConstants.SVG_SVG_TAG.equals(elt.getLocalName())) {
+ // <svg> listeners
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "SVGAbort",
+ svgAbortListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "SVGError",
+ svgErrorListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "SVGResize",
+ svgResizeListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "SVGScroll",
+ svgScrollListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "SVGUnload",
+ svgUnloadListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "SVGZoom",
+ svgZoomListener, false);
+ } else {
+ String name = elt.getLocalName();
+ if (name.equals(SVGConstants.SVG_SET_TAG) ||
+ name.startsWith("animate")) {
+ // animation listeners
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "beginEvent",
+ beginListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "endEvent",
+ endListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "repeatEvent",
+ repeatListener , false);
+ return;
+ }
+ }
+ }
+
+ // UI listeners
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMFocusIn",
+ focusinListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMFocusOut",
+ focusoutListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "DOMActivate",
+ activateListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "click",
+ clickListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "mousedown",
+ mousedownListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "mouseup",
+ mouseupListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "mouseover",
+ mouseoverListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "mouseout",
+ mouseoutListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "mousemove",
+ mousemoveListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "keypress",
+ keypressListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "keydown",
+ keydownListener, false);
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, "keyup",
+ keyupListener, false);
+ }
+
+ /**
* Updates the registration of a listener on the given element.
*/
protected void updateScriptingListeners(Element elt, String attr) {
- String domEvt = (String) attrToDOMEvent.get(attr);
- if (domEvt == null) return; // Not an event attr.
- EventListener listener = (EventListener)attrToListener.get(attr);
- EventTarget target = (EventTarget) elt;
- if (elt.hasAttributeNS(null, attr))
- target.addEventListener(domEvt, listener, false);
- else
- target.removeEventListener(domEvt, listener, false);
+ String domEvt = (String) attrToDOMEvent.get(attr);
+ if (domEvt == null) {
+ return; // Not an event attr.
+ }
+ EventListener listener = (EventListener) attrToListener.get(attr);
+ NodeEventTarget target = (NodeEventTarget) elt;
+ if (elt.hasAttributeNS(null, attr)) {
+ target.addEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, domEvt,
+ listener, false, null);
+ } else {
+ target.removeEventListenerNS
+ (XMLConstants.XML_EVENTS_NAMESPACE_URI, domEvt,
+ listener, false);
+ }
}
-
+
/**
* To interpret a script.
@@ -690,7 +778,7 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
} else {
e.printStackTrace(); // No UA so just output...
}
- synchronized (this) {
+ synchronized (this) {
error = true;
}
}
@@ -773,7 +861,7 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
}
}
};
-
+
timer.schedule(tt, interval, interval);
return tt;
}
@@ -842,32 +930,23 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
* org.apache.flex.forks.batik.script.Window#parseXML(String,Document)}.
*/
public Node parseXML(String text, Document doc) {
- // System.err.println("Text: " + text);
// Try and parse it as an SVGDocument
SAXSVGDocumentFactory df = new SAXSVGDocumentFactory
(XMLResourceDescriptor.getXMLParserClassName());
URL urlObj = null;
- if ((doc != null) && (doc instanceof SVGOMDocument))
- urlObj = ((SVGOMDocument)doc).getURLObject();
+ if (doc instanceof SVGOMDocument) {
+ urlObj = ((SVGOMDocument) doc).getURLObject();
+ }
if (urlObj == null) {
- urlObj = ((SVGOMDocument)bridgeContext.getDocument()).
- getURLObject();
+ urlObj = ((SVGOMDocument) bridgeContext.getDocument())
+ .getURLObject();
}
- String uri = (urlObj==null)?"":urlObj.toString();
- try {
- Document d = df.createDocument(uri, new StringReader(text));
- if (doc == null)
- return d;
-
- Node result = doc.createDocumentFragment();
- result.appendChild(doc.importNode(d.getDocumentElement(),
- true));
- return result;
- } catch (Exception ex) {
- /* nothing */
+ String uri = (urlObj == null) ? "" : urlObj.toString();
+ Node res = DOMUtilities.parseXML(text, doc, uri, null, null, df);
+ if (res != null) {
+ return res;
}
-
- if ((doc != null) && (doc instanceof SVGOMDocument)) {
+ if (doc instanceof SVGOMDocument) {
// Try and parse with an 'svg' element wrapper - for
// things like '<rect ../>' - ensure that rect ends up
// in SVG namespace - xlink namespace is declared etc...
@@ -875,60 +954,28 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
// Only do this when generating a doc fragment, since
// a 'rect' element can not be root of SVG Document
// (only an svg element can be).
- StringBuffer sb = new StringBuffer(FRAGMENT_PREFIX.length() +
- text.length() +
- FRAGMENT_SUFFIX.length());
- sb.append(FRAGMENT_PREFIX);
- sb.append(text);
- sb.append(FRAGMENT_SUFFIX);
- String newText = sb.toString();
- try {
- Document d = df.createDocument
- (uri, new StringReader(newText));
- // No document given so make doc fragment from our
- // new Document.
- if (doc == null) doc = d;
- for (Node n = d.getDocumentElement().getFirstChild();
- n != null;
- n = n.getNextSibling()) {
- if (n.getNodeType() == Node.ELEMENT_NODE) {
- n = doc.importNode(n, true);
- Node result = doc.createDocumentFragment();
- result.appendChild(n);
- return result;
- }
- }
- } catch (Exception exc) {
- /* nothing - try something else*/
+ Map prefixes = new HashMap();
+ prefixes.put(XMLConstants.XMLNS_PREFIX,
+ XMLConstants.XMLNS_NAMESPACE_URI);
+ prefixes.put(XMLConstants.XMLNS_PREFIX + ':'
+ + XMLConstants.XLINK_PREFIX,
+ XLinkSupport.XLINK_NAMESPACE_URI);
+ res = DOMUtilities.parseXML(text, doc, uri, prefixes,
+ SVGConstants.SVG_SVG_TAG, df);
+ if (res != null) {
+ return res;
}
}
-
// Parse as a generic XML document.
SAXDocumentFactory sdf;
if (doc != null) {
- sdf = new SAXDocumentFactory
- (doc.getImplementation(),
- XMLResourceDescriptor.getXMLParserClassName());
+ sdf = new SAXDocumentFactory(doc.getImplementation(),
+ XMLResourceDescriptor.getXMLParserClassName());
} else {
- sdf = new SAXDocumentFactory
- (new GenericDOMImplementation(),
- XMLResourceDescriptor.getXMLParserClassName());
+ sdf = new SAXDocumentFactory(new GenericDOMImplementation(),
+ XMLResourceDescriptor.getXMLParserClassName());
}
- try {
- Document d = sdf.createDocument(uri, new StringReader(text));
- if (doc == null)
- return d;
-
- Node result = doc.createDocumentFragment();
- result.appendChild(doc.importNode(d.getDocumentElement(),
- true));
- return result;
- } catch (Exception ext) {
- if (userAgent != null)
- userAgent.displayError(ext);
- }
-
- return null;
+ return DOMUtilities.parseXML(text, doc, uri, null, null, sdf);
}
/**
@@ -939,9 +986,9 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
getURL(uri, h, null);
}
- final static String DEFLATE="deflate";
- final static String GZIP ="gzip";
- final static String UTF_8 ="UTF-8";
+ static final String DEFLATE="deflate";
+ static final String GZIP ="gzip";
+ static final String UTF_8 ="UTF-8";
/**
* Implements {@link
* org.apache.flex.forks.batik.script.Window#getURL(String,org.apache.flex.forks.batik.script.Window.URLResponseHandler,String)}.
@@ -952,8 +999,8 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
Thread t = new Thread() {
public void run() {
try {
- URL burl;
- burl = ((SVGOMDocument)document).getURLObject();
+ ParsedURL burl;
+ burl = ((SVGOMDocument)document).getParsedURL();
final ParsedURL purl = new ParsedURL(burl, uri);
String e = null;
if (enc != null) {
@@ -1020,37 +1067,40 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
}
- public void postURL(String uri, String content,
+ public void postURL(String uri, String content,
org.apache.flex.forks.batik.script.Window.URLResponseHandler h) {
postURL(uri, content, h, "text/plain", null);
}
- public void postURL(String uri, String content,
- org.apache.flex.forks.batik.script.Window.URLResponseHandler h,
+ public void postURL(String uri, String content,
+ org.apache.flex.forks.batik.script.Window.URLResponseHandler h,
String mimeType) {
postURL(uri, content, h, mimeType, null);
}
- public void postURL(final String uri,
- final String content,
- final org.apache.flex.forks.batik.script.Window.URLResponseHandler h,
- final String mimeType,
+ public void postURL(final String uri,
+ final String content,
+ final org.apache.flex.forks.batik.script.Window.URLResponseHandler h,
+ final String mimeType,
final String fEnc) {
Thread t = new Thread() {
public void run() {
try {
- URL burl;
- burl = ((SVGOMDocument)document).getURLObject();
+ String base =
+ ((SVGOMDocument)document).getDocumentURI();
URL url;
- if (burl != null)
- url = new URL(burl, uri);
- else url = new URL(uri);
+ if (base == null) {
+ url = new URL(uri);
+ } else {
+ url = new URL(new URL(base), uri);
+ }
+ // TODO: Change this to use ParsedURL for the POST?
final URLConnection conn = url.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setRequestProperty("Content-Type", mimeType);
-
+
OutputStream os = conn.getOutputStream();
String e=null, enc = fEnc;
if (enc != null) {
@@ -1075,13 +1125,13 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
}
if (enc.length() != 0) {
e = EncodingUtilities.javaEncoding(enc);
- if (e == null) e = UTF_8;
+ if (e == null) e = UTF_8;
} else {
e = UTF_8;
}
}
Writer w;
- if (e == null)
+ if (e == null)
w = new OutputStreamWriter(os);
else
w = new OutputStreamWriter(os, e);
@@ -1093,7 +1143,7 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
InputStream is = conn.getInputStream();
Reader r;
e = UTF_8;
- if (e == null)
+ if (e == null)
r = new InputStreamReader(is);
else
r = new InputStreamReader(is, e);
@@ -1233,7 +1283,7 @@ public class ScriptingEnvironment extends BaseScriptingEnvironment {
* The script attribute.
*/
protected String attribute;
-
+
/**
* Creates a new ScriptingEventListener.
*/
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/StyleReference.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/StyleReference.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/StyleReference.java
index 9779784..adba6a4 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/StyleReference.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/StyleReference.java
@@ -1,10 +1,11 @@
/*
- Copyright 2000-2001,2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -26,7 +27,7 @@ import org.apache.flex.forks.batik.gvt.GraphicsNode;
* filter) changes due to a modification of the DOM.
*
* @author <a href="mailto:etissandier@ilog.fr">Emmanuel Tissandier</a>
- * @version $Id: StyleReference.java,v 1.6 2004/08/18 07:12:36 vhardy Exp $
+ * @version $Id: StyleReference.java 475477 2006-11-15 22:44:28Z cam $
*/
public class StyleReference {
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/TextUtilities.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/TextUtilities.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/TextUtilities.java
index cddc796..219ec1b 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/TextUtilities.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/TextUtilities.java
@@ -1,10 +1,11 @@
/*
- Copyright 2001-2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -34,7 +35,7 @@ import org.w3c.dom.css.CSSPrimitiveValue;
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
* @author <a href="mailto:bill.haneman@ireland.sun.com">Bill Haneman</a>
- * @version $Id: TextUtilities.java,v 1.10 2005/03/27 08:58:30 cam Exp $
+ * @version $Id: TextUtilities.java 501922 2007-01-31 17:47:47Z dvholten $
*/
public abstract class TextUtilities implements CSSConstants, ErrorConstants {
@@ -125,9 +126,9 @@ public abstract class TextUtilities implements CSSConstants, ErrorConstants {
values.add
(new Float(Math.toRadians
(SVGUtilities.convertSVGNumber(s))));
- } catch (NumberFormatException ex) {
+ } catch (NumberFormatException nfEx ) {
throw new BridgeException
- (element, ERR_ATTRIBUTE_VALUE_MALFORMED,
+ (ctx, element, nfEx, ERR_ATTRIBUTE_VALUE_MALFORMED,
new Object [] {attrName, valueStr});
}
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/URIResolver.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/URIResolver.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/URIResolver.java
index 6ad8e86..412f9a0 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/URIResolver.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/URIResolver.java
@@ -1,10 +1,11 @@
/*
- Copyright 2001-2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -20,19 +21,19 @@ package org.apache.flex.forks.batik.bridge;
import java.io.IOException;
import java.net.MalformedURLException;
+import org.apache.flex.forks.batik.dom.AbstractNode;
import org.apache.flex.forks.batik.dom.svg.SVGOMDocument;
-import org.apache.flex.forks.batik.dom.svg.XMLBaseSupport;
import org.apache.flex.forks.batik.util.ParsedURL;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.flex.forks.dom.svg.SVGDocument;
+import org.w3c.dom.svg.SVGDocument;
/**
* This class is used to resolve the URI that can be found in a SVG document.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: URIResolver.java,v 1.28 2005/02/22 09:12:57 cam Exp $
+ * @version $Id: URIResolver.java 475477 2006-11-15 22:44:28Z cam $
*/
public class URIResolver {
/**
@@ -92,12 +93,12 @@ public class URIResolver {
public Node getNode(String uri, Element ref)
throws MalformedURLException, IOException, SecurityException {
- String baseURI = XMLBaseSupport.getCascadedXMLBase(ref);
+ String baseURI = getRefererBaseURI(ref);
// System.err.println("baseURI: " + baseURI);
// System.err.println("URI: " + uri);
- if ((baseURI == null) &&
- (uri.startsWith("#")))
- return document.getElementById(uri.substring(1));
+ if (baseURI == null && uri.charAt(0) == '#') {
+ return getNodeByFragment(uri.substring(1), ref);
+ }
ParsedURL purl = new ParsedURL(baseURI, uri);
// System.err.println("PURL: " + purl);
@@ -137,4 +138,22 @@ public class URIResolver {
return doc.getElementById(frag);
return doc;
}
+
+ /**
+ * Returns the base URI of the referer element.
+ */
+ protected String getRefererBaseURI(Element ref) {
+ return ((AbstractNode) ref).getBaseURI();
+ }
+
+ /**
+ * Returns the node referenced by the given fragment identifier.
+ * This is called when the whole URI just contains a fragment identifier
+ * and there is no XML Base URI in effect.
+ * @param frag the URI fragment
+ * @param ref the context element from which to resolve the URI fragment
+ */
+ protected Node getNodeByFragment(String frag, Element ref) {
+ return ref.getOwnerDocument().getElementById(frag);
+ }
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UnitProcessor.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UnitProcessor.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UnitProcessor.java
index 024acd4..34ed891 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UnitProcessor.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UnitProcessor.java
@@ -1,10 +1,11 @@
/*
- Copyright 2001-2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -27,17 +28,12 @@ import org.w3c.dom.Element;
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
* @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: UnitProcessor.java,v 1.14 2004/08/18 07:12:36 vhardy Exp $
+ * @version $Id: UnitProcessor.java 501922 2007-01-31 17:47:47Z dvholten $
*/
public abstract class UnitProcessor
extends org.apache.flex.forks.batik.parser.UnitProcessor {
/**
- * No instance of this class is required.
- */
- protected UnitProcessor() { }
-
- /**
* Creates a context for the specified element.
*
* @param ctx the bridge context that contains the user agent and
@@ -157,7 +153,7 @@ public abstract class UnitProcessor
Context ctx) {
float v = svgToObjectBoundingBox(s, attr, d, ctx);
if (v < 0) {
- throw new BridgeException(ctx.getElement(),
+ throw new BridgeException(getBridgeContext(ctx), ctx.getElement(),
ErrorConstants.ERR_LENGTH_NEGATIVE,
new Object[] {attr, s});
}
@@ -180,10 +176,11 @@ public abstract class UnitProcessor
try {
return org.apache.flex.forks.batik.parser.UnitProcessor.
svgToObjectBoundingBox(s, attr, d, ctx);
- } catch (ParseException ex) {
- throw new BridgeException(ctx.getElement(),
- ErrorConstants.ERR_ATTRIBUTE_VALUE_MALFORMED,
- new Object[] {attr, s, ex});
+ } catch (ParseException pEx ) {
+ throw new BridgeException
+ (getBridgeContext(ctx), ctx.getElement(),
+ pEx, ErrorConstants.ERR_ATTRIBUTE_VALUE_MALFORMED,
+ new Object[] {attr, s, pEx });
}
}
@@ -288,7 +285,7 @@ public abstract class UnitProcessor
Context ctx) {
float v = svgToUserSpace(s, attr, d, ctx);
if (v < 0) {
- throw new BridgeException(ctx.getElement(),
+ throw new BridgeException(getBridgeContext(ctx), ctx.getElement(),
ErrorConstants.ERR_LENGTH_NEGATIVE,
new Object[] {attr, s});
} else {
@@ -312,25 +309,45 @@ public abstract class UnitProcessor
try {
return org.apache.flex.forks.batik.parser.UnitProcessor.
svgToUserSpace(s, attr, d, ctx);
- } catch (ParseException ex) {
- throw new BridgeException(ctx.getElement(),
- ErrorConstants.ERR_ATTRIBUTE_VALUE_MALFORMED,
- new Object[] {attr, s, ex});
+ } catch (ParseException pEx ) {
+ throw new BridgeException
+ (getBridgeContext(ctx), ctx.getElement(),
+ pEx, ErrorConstants.ERR_ATTRIBUTE_VALUE_MALFORMED,
+ new Object[] {attr, s, pEx, });
+ }
+ }
+
+ /**
+ * Returns the {@link BridgeContext} from the given {@link Context}
+ * if it is a {@link DefaultContext}, or null otherwise.
+ */
+ protected static BridgeContext getBridgeContext(Context ctx) {
+ if (ctx instanceof DefaultContext) {
+ return ((DefaultContext) ctx).ctx;
}
+ return null;
}
/**
- * This class is the default context for a particular
- * element. Informations not available on the element are get from
- * the bridge context (such as the viewport or the pixel to
- * millimeter factor.
+ * This class is the default context for a particular element. Information
+ * not available on the element are obtained from the bridge context (such
+ * as the viewport or the pixel to millimeter factor).
*/
public static class DefaultContext implements Context {
- /** The element. */
+ /**
+ * The element.
+ */
protected Element e;
+
+ /**
+ * The bridge context.
+ */
protected BridgeContext ctx;
+ /**
+ * Creates a new DefaultContext.
+ */
public DefaultContext(BridgeContext ctx, Element e) {
this.ctx = ctx;
this.e = e;
@@ -357,7 +374,7 @@ public abstract class UnitProcessor
*/
public float getPixelToMM() {
return getPixelUnitToMillimeter();
-
+
}
/**
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManager.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManager.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManager.java
index 94dd638..99e1b14 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManager.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManager.java
@@ -1,10 +1,11 @@
/*
- Copyright 2001-2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -25,34 +26,41 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.apache.flex.forks.batik.bridge.svg12.DefaultXBLManager;
+import org.apache.flex.forks.batik.bridge.svg12.SVG12BridgeContext;
+import org.apache.flex.forks.batik.bridge.svg12.SVG12ScriptingEnvironment;
+import org.apache.flex.forks.batik.dom.events.AbstractEvent;
+import org.apache.flex.forks.batik.dom.svg.SVGOMDocument;
import org.apache.flex.forks.batik.gvt.GraphicsNode;
import org.apache.flex.forks.batik.gvt.RootGraphicsNode;
import org.apache.flex.forks.batik.gvt.UpdateTracker;
import org.apache.flex.forks.batik.gvt.renderer.ImageRenderer;
import org.apache.flex.forks.batik.util.EventDispatcher;
+import org.apache.flex.forks.batik.util.XMLConstants;
import org.apache.flex.forks.batik.util.EventDispatcher.Dispatcher;
import org.apache.flex.forks.batik.util.RunnableQueue;
import org.w3c.dom.Document;
import org.w3c.dom.events.DocumentEvent;
-import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventTarget;
/**
* This class provides features to manage the update of an SVG document.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: UpdateManager.java,v 1.38 2005/03/27 08:58:30 cam Exp $
+ * @version $Id: UpdateManager.java 501843 2007-01-31 13:52:12Z deweese $
*/
public class UpdateManager {
- static final long MIN_REPAINT_TIME;
+ static final int MIN_REPAINT_TIME;
static {
- long value = 20;
+ int value = 20;
try {
String s = System.getProperty
("org.apache.flex.forks.batik.min_repaint_time", "20");
- value = Long.parseLong(s);
+ value = Integer.parseInt(s);
} catch (SecurityException se) {
} catch (NumberFormatException nfe){
} finally {
@@ -64,7 +72,7 @@ public class UpdateManager {
* The bridge context.
*/
protected BridgeContext bridgeContext;
-
+
/**
* The document to manage.
*/
@@ -83,12 +91,12 @@ public class UpdateManager {
/**
* Whether the update manager is running.
*/
- protected boolean running;
+ protected volatile boolean running;
/**
* Whether the suspend() method was called.
*/
- protected boolean suspendCalled;
+ protected volatile boolean suspendCalled;
/**
* The listeners.
@@ -121,6 +129,22 @@ public class UpdateManager {
protected boolean started;
/**
+ * Array of resource documents' BridgeContexts.
+ */
+ protected BridgeContext[] secondaryBridgeContexts;
+
+ /**
+ * Array of resource documents' ScriptingEnvironments that should
+ * have their SVGLoad event dispatched.
+ */
+ protected ScriptingEnvironment[] secondaryScriptingEnvironments;
+
+ /**
+ * The current minRepaintTime
+ */
+ protected int minRepaintTime;
+
+ /**
* Creates a new update manager.
* @param ctx The bridge context.
* @param gn GraphicsNode whose updates are to be tracked.
@@ -140,16 +164,84 @@ public class UpdateManager {
graphicsNode = gn;
- scriptingEnvironment = new ScriptingEnvironment(ctx);
+ scriptingEnvironment = initializeScriptingEnvironment(bridgeContext);
+
+ // Any BridgeContexts for resource documents that exist
+ // when initializing the scripting environment for the
+ // primary document also need to have their scripting
+ // environments initialized.
+ secondaryBridgeContexts =
+ (BridgeContext[]) ctx.getChildContexts().clone();
+ secondaryScriptingEnvironments =
+ new ScriptingEnvironment[secondaryBridgeContexts.length];
+ for (int i = 0; i < secondaryBridgeContexts.length; i++) {
+ BridgeContext resCtx = secondaryBridgeContexts[i];
+ if (!((SVGOMDocument) resCtx.getDocument()).isSVG12()) {
+ continue;
+ }
+ resCtx.setUpdateManager(this);
+ ScriptingEnvironment se = initializeScriptingEnvironment(resCtx);
+ secondaryScriptingEnvironments[i] = se;
+ }
+ minRepaintTime = MIN_REPAINT_TIME;
+ }
+
+ public int getMinRepaintTime() {
+ return minRepaintTime;
+ }
+
+ public void setMinRepaintTime(int minRepaintTime) {
+ this.minRepaintTime = minRepaintTime;
+ }
+
+ /**
+ * Creates an appropriate ScriptingEnvironment and XBL manager for
+ * the given document.
+ */
+ protected ScriptingEnvironment initializeScriptingEnvironment
+ (BridgeContext ctx) {
+ SVGOMDocument d = (SVGOMDocument) ctx.getDocument();
+ ScriptingEnvironment se;
+ if (d.isSVG12()) {
+ se = new SVG12ScriptingEnvironment(ctx);
+ ctx.xblManager = new DefaultXBLManager(d, ctx);
+ d.setXBLManager(ctx.xblManager);
+ } else {
+ se = new ScriptingEnvironment(ctx);
+ }
+ return se;
}
/**
* Dispatches an 'SVGLoad' event to the document.
*/
public synchronized void dispatchSVGLoadEvent()
- throws InterruptedException {
- scriptingEnvironment.loadScripts();
- scriptingEnvironment.dispatchSVGLoadEvent();
+ throws InterruptedException {
+ dispatchSVGLoadEvent(bridgeContext, scriptingEnvironment);
+ for (int i = 0; i < secondaryScriptingEnvironments.length; i++) {
+ BridgeContext ctx = secondaryBridgeContexts[i];
+ if (!((SVGOMDocument) ctx.getDocument()).isSVG12()) {
+ continue;
+ }
+ ScriptingEnvironment se = secondaryScriptingEnvironments[i];
+ dispatchSVGLoadEvent(ctx, se);
+ }
+ secondaryBridgeContexts = null;
+ secondaryScriptingEnvironments = null;
+ }
+
+ /**
+ * Dispatches an 'SVGLoad' event to the document.
+ */
+ protected void dispatchSVGLoadEvent(BridgeContext ctx,
+ ScriptingEnvironment se) {
+ se.loadScripts();
+ se.dispatchSVGLoadEvent();
+ if (ctx.isSVG12() && ctx.xblManager != null) {
+ SVG12BridgeContext ctx12 = (SVG12BridgeContext) ctx;
+ ctx12.addBindingListener();
+ ctx12.xblManager.startProcessing();
+ }
}
/**
@@ -184,7 +276,7 @@ public class UpdateManager {
public void run() {
synchronized (UpdateManager.this) {
running = true;
-
+
updateTracker = new UpdateTracker();
RootGraphicsNode root = graphicsNode.getRoot();
if (root != null){
@@ -276,7 +368,7 @@ public class UpdateManager {
// UpdateManagerEvent ev = new UpdateManagerEvent
// (this, null, null);
// // FIXX: Must happen in a different thread!
- // fireEvent(suspendedDispatcher, ev);
+ // fireEvent(suspendedDispatcher, ev);
// fireEvent(resumedDispatcher, ev);
// }
if (updateRunnableQueue.getQueueState() != RunnableQueue.RUNNING) {
@@ -287,12 +379,8 @@ public class UpdateManager {
/**
* Interrupts the manager tasks.
*/
- public synchronized void interrupt() {
- if (updateRunnableQueue.getThread() == null)
- return;
-
- // Preempt to cancel the pending tasks
- updateRunnableQueue.preemptLater(new Runnable() {
+ public void interrupt() {
+ Runnable r = new Runnable() {
public void run() {
synchronized (UpdateManager.this) {
if (started) {
@@ -304,8 +392,15 @@ public class UpdateManager {
}
}
}
- });
- resume();
+ };
+ try {
+ // Preempt to cancel the pending tasks
+ updateRunnableQueue.preemptLater(r);
+ updateRunnableQueue.resumeExecution(); // ensure runnable runs...
+ } catch (IllegalStateException ise) {
+ // Not running, which is probably ok since that's what we
+ // wanted. Might be an issue if SVGUnload wasn't issued...
+ }
}
/**
@@ -322,15 +417,24 @@ public class UpdateManager {
updateRunnableQueue.preemptLater(new Runnable() {
public void run() {
synchronized (UpdateManager.this) {
- Event evt =
+ AbstractEvent evt = (AbstractEvent)
((DocumentEvent)document).createEvent("SVGEvents");
- evt.initEvent("SVGUnload", false, false);
+ String type;
+ if (bridgeContext.isSVG12()) {
+ type = "unload";
+ } else {
+ type = "SVGUnload";
+ }
+ evt.initEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI,
+ type,
+ false, // canBubbleArg
+ false); // cancelableArg
((EventTarget)(document.getDocumentElement())).
dispatchEvent(evt);
running = false;
// Now shut everything down and disconnect
- // everything before we send the
+ // everything before we send the
// UpdateMangerStopped event.
scriptingEnvironment.interrupt();
updateRunnableQueue.getThread().halt();
@@ -395,7 +499,7 @@ public class UpdateManager {
* @param clearPaintingTransform Indicates if the painting transform
* should be cleared as a result of this update.
*/
- protected void updateRendering(List areas,
+ protected void updateRendering(List areas,
boolean clearPaintingTransform) {
try {
UpdateManagerEvent ev = new UpdateManagerEvent
@@ -406,7 +510,7 @@ public class UpdateManager {
List l = new ArrayList(c);
ev = new UpdateManagerEvent
- (this, repaintManager.getOffScreen(),
+ (this, repaintManager.getOffScreen(),
l, clearPaintingTransform);
fireEvent(updateCompletedDispatcher, ev);
} catch (ThreadDeath td) {
@@ -431,24 +535,37 @@ public class UpdateManager {
* Repaints the dirty areas, if needed.
*/
protected void repaint() {
- if (!updateTracker.hasChanged())
+ if (!updateTracker.hasChanged()) {
+ // No changes, nothing to repaint.
+ outOfDateTime = 0;
return;
+ }
+
long ctime = System.currentTimeMillis();
- if (ctime-outOfDateTime < MIN_REPAINT_TIME) {
- // We very recently did a repaint check if other
+ if (ctime < allResumeTime) {
+ createRepaintTimer();
+ return;
+ }
+ if (allResumeTime > 0) {
+ // All suspendRedraw requests have expired.
+ releaseAllRedrawSuspension();
+ }
+
+ if (ctime-outOfDateTime < minRepaintTime) {
+ // We very recently did a repaint check if other
// repaint runnables are pending.
synchronized (updateRunnableQueue.getIteratorLock()) {
Iterator i = updateRunnableQueue.iterator();
while (i.hasNext())
if (!(i.next() instanceof NoRepaintRunnable))
// have a pending repaint runnable so we
- // will skip this repaint and we will let
+ // will skip this repaint and we will let
// the next one pick it up.
return;
-
+
}
}
-
+
List dirtyAreas = updateTracker.getDirtyAreas();
updateTracker.clear();
if (dirtyAreas != null) {
@@ -457,6 +574,169 @@ public class UpdateManager {
outOfDateTime = 0;
}
+ /**
+ * Users of Batik should essentially never call
+ * this directly from Java. If the Canvas is not
+ * updating when you change the SVG Document it is almost
+ * certainly because you are not making your changes
+ * in the RunnableQueue (getUpdateRunnableQueue()).
+ * You will have problems if you are not making all
+ * changes to the document in the UpdateManager's
+ * RunnableQueue.
+ *
+ * This method exists to implement the
+ * 'SVGSVGElement.forceRedraw()' method.
+ */
+ public void forceRepaint() {
+ if (!updateTracker.hasChanged()) {
+ // No changes, nothing to repaint.
+ outOfDateTime = 0;
+ return;
+ }
+
+ List dirtyAreas = updateTracker.getDirtyAreas();
+ updateTracker.clear();
+ if (dirtyAreas != null) {
+ updateRendering(dirtyAreas, false);
+ }
+ outOfDateTime = 0;
+ }
+
+ protected class SuspensionInfo {
+ /**
+ * The index of this redraw suspension
+ */
+ int index;
+ /**
+ * The system time in millisec that this suspension
+ * will expire and redraws can resume (at least for
+ * this suspension.
+ */
+ long resumeMilli;
+ public SuspensionInfo(int index, long resumeMilli) {
+ this.index = index;
+ this.resumeMilli = resumeMilli;
+ }
+ public int getIndex() { return index; }
+ public long getResumeMilli() { return resumeMilli; }
+ }
+
+ protected class RepaintTimerTask extends TimerTask {
+ UpdateManager um;
+ RepaintTimerTask(UpdateManager um) {
+ this.um = um;
+ }
+ public void run() {
+ RunnableQueue rq = um.getUpdateRunnableQueue();
+ if (rq == null) return;
+ rq.invokeLater(new Runnable() {
+ public void run() { }
+ });
+ }
+ }
+
+ List suspensionList = new ArrayList();
+ int nextSuspensionIndex = 1;
+ long allResumeTime = -1;
+ Timer repaintTriggerTimer = null;
+ TimerTask repaintTimerTask = null;
+
+ void createRepaintTimer() {
+ if (repaintTimerTask != null) return;
+ if (allResumeTime < 0) return;
+ if (repaintTriggerTimer == null)
+ repaintTriggerTimer = new Timer(true);
+
+ long delay = allResumeTime - System.currentTimeMillis();
+ if (delay < 0) delay = 0;
+ repaintTimerTask = new RepaintTimerTask(this);
+ repaintTriggerTimer.schedule(repaintTimerTask, delay);
+ // System.err.println("CTimer delay: " + delay);
+ }
+ /**
+ * Sets up a timer that will trigger a repaint
+ * when it fires.
+ * If create is true it will construct a timer even
+ * if one
+ */
+ void resetRepaintTimer() {
+ if (repaintTimerTask == null) return;
+ if (allResumeTime < 0) return;
+ if (repaintTriggerTimer == null)
+ repaintTriggerTimer = new Timer(true);
+
+ long delay = allResumeTime - System.currentTimeMillis();
+ if (delay < 0) delay = 0;
+ repaintTimerTask = new RepaintTimerTask(this);
+ repaintTriggerTimer.schedule(repaintTimerTask, delay);
+ // System.err.println("Timer delay: " + delay);
+ }
+
+ int addRedrawSuspension(int max_wait_milliseconds) {
+ long resumeTime = System.currentTimeMillis() + max_wait_milliseconds;
+ SuspensionInfo si = new SuspensionInfo(nextSuspensionIndex++,
+ resumeTime);
+ if (resumeTime > allResumeTime) {
+ allResumeTime = resumeTime;
+ // System.err.println("Added AllRes Time: " + allResumeTime);
+ resetRepaintTimer();
+ }
+ suspensionList.add(si);
+ return si.getIndex();
+ }
+
+ void releaseAllRedrawSuspension() {
+ suspensionList.clear();
+ allResumeTime = -1;
+ resetRepaintTimer();
+ }
+
+ boolean releaseRedrawSuspension(int index) {
+ if (index > nextSuspensionIndex) return false;
+ if (suspensionList.size() == 0) return true;
+
+ int lo = 0, hi=suspensionList.size()-1;
+ while (lo < hi) {
+ int mid = (lo+hi)>>1;
+ SuspensionInfo si = (SuspensionInfo)suspensionList.get(mid);
+ int idx = si.getIndex();
+ if (idx == index) { lo = hi = mid; }
+ else if (idx < index) { lo = mid+1; }
+ else { hi = mid-1; }
+ }
+
+ SuspensionInfo si = (SuspensionInfo)suspensionList.get(lo);
+ int idx = si.getIndex();
+ if (idx != index)
+ return true; // currently not in list but was at some point...
+
+ suspensionList.remove(lo);
+ if (suspensionList.size() == 0) {
+ // No more active suspensions
+ allResumeTime = -1;
+ resetRepaintTimer();
+ } else {
+ // Check if we need to find a new 'bounding' suspension.
+ long resumeTime = si.getResumeMilli();
+ if (resumeTime == allResumeTime) {
+ allResumeTime = findNewAllResumeTime();
+ // System.err.println("New AllRes Time: " + allResumeTime);
+ resetRepaintTimer();
+ }
+ }
+ return true;
+ }
+
+ long findNewAllResumeTime() {
+ long ret = -1;
+ Iterator i = suspensionList.iterator();
+ while (i.hasNext()) {
+ SuspensionInfo si = (SuspensionInfo)i.next();
+ long t = si.getResumeMilli();
+ if (t > ret) ret = t;
+ }
+ return ret;
+ }
/**
* Adds a UpdateManagerListener to this UpdateManager.
@@ -568,10 +848,10 @@ public class UpdateManager {
return new UpdateManagerRunHander();
}
- protected class UpdateManagerRunHander
+ protected class UpdateManagerRunHander
extends RunnableQueue.RunHandlerAdapter {
- public void runnableStart(RunnableQueue rq, Runnable r) {
+ public void runnableStart(RunnableQueue rq, Runnable r) {
if (running && !(r instanceof NoRepaintRunnable)) {
// Mark the document as updated when the
// runnable starts.
@@ -579,7 +859,7 @@ public class UpdateManager {
outOfDateTime = System.currentTimeMillis();
}
}
-
+
/**
* Called when the given Runnable has just been invoked and
@@ -590,7 +870,7 @@ public class UpdateManager {
repaint();
}
}
-
+
/**
* Called when the execution of the queue has been suspended.
*/
@@ -605,13 +885,13 @@ public class UpdateManager {
}
}
}
-
+
/**
* Called when the execution of the queue has been resumed.
*/
public void executionResumed(RunnableQueue rq) {
synchronized (UpdateManager.this) {
- // System.err.println("Resumed: " + suspendCalled +
+ // System.err.println("Resumed: " + suspendCalled +
// " : " + running);
if (suspendCalled && !running) {
running = true;
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerAdapter.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerAdapter.java
index 95a648d..6c497e1 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerAdapter.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerAdapter.java
@@ -1,10 +1,11 @@
/*
- Copyright 2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -22,7 +23,7 @@ package org.apache.flex.forks.batik.bridge;
* It's methods do nothing.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: UpdateManagerAdapter.java,v 1.2 2004/08/18 07:12:36 vhardy Exp $
+ * @version $Id: UpdateManagerAdapter.java 475477 2006-11-15 22:44:28Z cam $
*/
public class UpdateManagerAdapter implements UpdateManagerListener {
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerEvent.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerEvent.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerEvent.java
index 02fd4a2..3a29629 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerEvent.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerEvent.java
@@ -1,10 +1,11 @@
/*
- Copyright 2001-2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -26,7 +27,7 @@ import java.util.List;
* from a UpdateManager instance.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: UpdateManagerEvent.java,v 1.7 2005/03/27 08:58:30 cam Exp $
+ * @version $Id: UpdateManagerEvent.java 475477 2006-11-15 22:44:28Z cam $
*/
public class UpdateManagerEvent extends EventObject {
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerListener.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerListener.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerListener.java
index db71e63..9b96060 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerListener.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UpdateManagerListener.java
@@ -1,10 +1,11 @@
/*
- Copyright 2001 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -21,7 +22,7 @@ package org.apache.flex.forks.batik.bridge;
* This interface represents a listener to the UpdateManagerEvent events.
*
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: UpdateManagerListener.java,v 1.3 2004/08/18 07:12:36 vhardy Exp $
+ * @version $Id: UpdateManagerListener.java 475477 2006-11-15 22:44:28Z cam $
*/
public interface UpdateManagerListener {
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgent.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgent.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgent.java
index 59e9083..94c29e0 100644
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgent.java
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/bridge/UserAgent.java
@@ -1,10 +1,11 @@
/*
- Copyright 2000-2004 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@@ -26,7 +27,8 @@ import org.apache.flex.forks.batik.gvt.event.EventDispatcher;
import org.apache.flex.forks.batik.gvt.text.Mark;
import org.apache.flex.forks.batik.util.ParsedURL;
import org.w3c.dom.Element;
-import org.w3c.flex.forks.dom.svg.SVGAElement;
+import org.w3c.dom.svg.SVGAElement;
+import org.w3c.dom.svg.SVGDocument;
/**
* An interface that provides access to the User Agent informations
@@ -34,7 +36,7 @@ import org.w3c.flex.forks.dom.svg.SVGAElement;
*
* @author <a href="mailto:cjolif@ilog.fr">Christophe Jolif</a>
* @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: UserAgent.java,v 1.32 2005/03/27 08:58:30 cam Exp $
+ * @version $Id: UserAgent.java 475477 2006-11-15 22:44:28Z cam $
*/
public interface UserAgent {
@@ -285,4 +287,16 @@ public interface UserAgent {
void checkLoadExternalResource(ParsedURL resourceURL,
ParsedURL docURL) throws SecurityException;
+
+ /**
+ * This method should return an image to be displayed when an image
+ * can't be loaded. If it returns 'null' then a BridgeException will
+ * be thrown.
+ *
+ * @param e The <image> element that can't be loaded.
+ * @param url The resolved url that can't be loaded.
+ * @param message As best as can be determined the reason it can't be
+ * loaded (not available, corrupt, unknown format, ...).
+ */
+ SVGDocument getBrokenLinkDocument(Element e, String url, String message);
}