Index: sources/org/apache/batik/swing/svg/JSVGComponent.java
===================================================================
--- sources/org/apache/batik/swing/svg/JSVGComponent.java (revision 712020)
+++ sources/org/apache/batik/swing/svg/JSVGComponent.java (working copy)
@@ -3082,6 +3082,15 @@
} catch (Exception e) {
}
}
+
+ /**
+ * This method should load a new document described by the supplied URL.
+ *
+ * @param url The url to be loaded as a string.
+ */
+ public void loadDocument(String url) {
+ userAgent.loadDocument(url);
+ }
}
/**
@@ -3677,6 +3686,15 @@
}
return doc;
}
+
+ /**
+ * This method should load a new document described by the supplied URL.
+ *
+ * @param url The url to be loaded as a string.
+ */
+ public void loadDocument(String url) {
+ JSVGComponent.this.loadSVGDocument(url);
+ }
}
protected static final Set FEATURES = new HashSet();
Index: sources/org/apache/batik/bridge/BaseScriptingEnvironment.java
===================================================================
--- sources/org/apache/batik/bridge/BaseScriptingEnvironment.java (revision 712020)
+++ sources/org/apache/batik/bridge/BaseScriptingEnvironment.java (working copy)
@@ -920,5 +920,19 @@
return interpreter;
}
+ /**
+ * Returns the Location.
+ */
+ public Location getLocation() {
+ return null;
+ }
+
+ /**
+ * Returns the parent Window object.
+ */
+ public Window getParent() {
+ return null;
+ }
+
}
}
Index: sources/org/apache/batik/bridge/Location.java
===================================================================
--- sources/org/apache/batik/bridge/Location.java (revision 0)
+++ sources/org/apache/batik/bridge/Location.java (revision 0)
@@ -0,0 +1,72 @@
+/*
+
+ 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
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.batik.bridge;
+
+import java.net.URL;
+import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.dom.svg.SVGOMDocument;
+import org.apache.batik.dom.AbstractDocument;
+
+/**
+ * This class implements the org.w3c.dom.Location interface for Batik
+ *
+ * @author G. Wade Johnson
+ * @version $Id: Location.java$
+ */
+public class Location implements org.w3c.dom.Location {
+ private BridgeContext bridgeContext;
+
+ /**
+ * Creates a new Location.
+ * @param ctx the bridge context
+ */
+ public Location(BridgeContext ctx) {
+ bridgeContext = ctx;
+ }
+
+
+ /**
+ * Invocation of this method causes the user agent to navigate to the
+ * supplied location.
+ *
+ * @param url A string containing the URL where the user agent should
+ * navigate to.
+ */
+ public void assign(String url) {
+ ((UserAgent)bridgeContext.getUserAgent()).loadDocument(url);
+ }
+
+ /**
+ * The user agent reloads the current document.
+ */
+ public void reload() {
+ String url = ((AbstractDocument) bridgeContext.getDocument())
+ .getDocumentURI();
+ ((UserAgent)bridgeContext.getUserAgent()).loadDocument(url);
+ }
+
+ /**
+ * Returns the URL of this location as a String.
+ */
+ public String toString() {
+ return ((AbstractDocument) bridgeContext.getDocument())
+ .getDocumentURI();
+ }
+}
+
Index: sources/org/apache/batik/bridge/UserAgent.java
===================================================================
--- sources/org/apache/batik/bridge/UserAgent.java (revision 712020)
+++ sources/org/apache/batik/bridge/UserAgent.java (working copy)
@@ -299,4 +299,11 @@
* loaded (not available, corrupt, unknown format, ...).
*/
SVGDocument getBrokenLinkDocument(Element e, String url, String message);
+
+ /**
+ * This method should load a new document described by the supplied URL.
+ *
+ * @param url The url to be loaded as a string.
+ */
+ void loadDocument(String url);
}
Index: sources/org/apache/batik/bridge/UserAgentAdapter.java
===================================================================
--- sources/org/apache/batik/bridge/UserAgentAdapter.java (revision 712020)
+++ sources/org/apache/batik/bridge/UserAgentAdapter.java (working copy)
@@ -449,4 +449,13 @@
throw new BridgeException(ctx, e, ErrorConstants.ERR_URI_IMAGE_BROKEN,
new Object[] {url, message });
}
+
+ /**
+ * This method should load a new document described by the supplied URL.
+ *
+ * @param url The url to be loaded as a string.
+ */
+ public void loadDocument(String url) {
+ // Do nothing.
+ }
}
Index: sources/org/apache/batik/bridge/ScriptingEnvironment.java
===================================================================
--- sources/org/apache/batik/bridge/ScriptingEnvironment.java (revision 712020)
+++ sources/org/apache/batik/bridge/ScriptingEnvironment.java (working copy)
@@ -49,6 +49,7 @@
import org.apache.batik.dom.util.DOMUtilities;
import org.apache.batik.dom.util.SAXDocumentFactory;
import org.apache.batik.dom.util.XLinkSupport;
+import org.apache.batik.bridge.Location;
import org.apache.batik.script.Interpreter;
import org.apache.batik.script.InterpreterException;
import org.apache.batik.script.ScriptEventWrapper;
@@ -917,6 +918,11 @@
protected String language;
/**
+ * The Location object
+ */
+ protected Location location;
+
+ /**
* Creates a new Window for the given language.
*/
public Window(Interpreter interp, String lang) {
@@ -1316,6 +1322,23 @@
public Interpreter getInterpreter() {
return interpreter;
}
+
+ /**
+ * Returns a Window object representing the parent of this Window.
+ */
+ public Window getParent() {
+ return null;
+ }
+
+ /**
+ * Returns a Location object representing this Window.
+ */
+ public Location getLocation() {
+ if (location == null) {
+ location = new Location(bridgeContext);
+ }
+ return location;
+ }
}
/**
Index: sources/org/apache/batik/script/rhino/WindowWrapper.java
===================================================================
--- sources/org/apache/batik/script/rhino/WindowWrapper.java (revision 712020)
+++ sources/org/apache/batik/script/rhino/WindowWrapper.java (working copy)
@@ -33,6 +33,7 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;
+import org.w3c.dom.Location;
/**
* This class wraps a Window object to expose it to the interpreter.
@@ -66,6 +67,8 @@
"postURL", "alert", "confirm", "prompt" };
this.defineFunctionProperties(names, WindowWrapper.class,
ScriptableObject.DONTENUM);
+ this.defineProperty("location", WindowWrapper.class,
+ ScriptableObject.PERMANENT);
}
public String getClassName() {
@@ -188,7 +191,7 @@
Object ret;
// If acc is null we are running in an Applet (or some other
- // restrictive environment) so don't sweat security it's
+ // restrictive environment) so don't sweat security it's
// the "Browsers" problem...
if (acc != null) ret = AccessController.doPrivileged(pa , acc);
else ret = AccessController.doPrivileged(pa);
@@ -406,6 +409,21 @@
}
/**
+ * Return the Location for this Window.
+ */
+ public Location getLocation() {
+ return window.getLocation();
+ }
+
+ /**
+ * Return the Location for this Window.
+ */
+ public void setLocation(Object val) {
+ String url = (String)Context.jsToJava(val, String.class);
+ window.getLocation().assign(url);
+ }
+
+ /**
* To wrap a function in an handler.
*/
protected static class FunctionWrapper implements Runnable {
Index: sources/org/apache/batik/script/Window.java
===================================================================
--- sources/org/apache/batik/script/Window.java (revision 712020)
+++ sources/org/apache/batik/script/Window.java (working copy)
@@ -30,7 +30,7 @@
* @author Stephane Hillion
* @version $Id$
*/
-public interface Window {
+public interface Window extends org.w3c.dom.Window {
/**
* Evaluates the given string repeatedly after the given amount of
* time. This method does not stall the script: the evaluation is
Index: sources/org/w3c/dom/Window.java
===================================================================
--- sources/org/w3c/dom/Window.java (revision 0)
+++ sources/org/w3c/dom/Window.java (revision 0)
@@ -0,0 +1,24 @@
+/*
+
+ 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
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.w3c.dom;
+
+public interface Window {
+ Window getParent();
+ Location getLocation();
+}
Index: sources/org/w3c/dom/Location.java
===================================================================
--- sources/org/w3c/dom/Location.java (revision 0)
+++ sources/org/w3c/dom/Location.java (revision 0)
@@ -0,0 +1,35 @@
+/*
+
+ 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
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.w3c.dom;
+
+public interface Location {
+ /**
+ * Invocation of this method causes the user agent to navigate to the
+ * supplied location.
+ *
+ * @param url A string containing the URL where the user agent should
+ * navigate to.
+ */
+ void assign(String url);
+
+ /**
+ * The user agent reloads the current document.
+ */
+ void reload();
+}