--- sources/org/apache/batik/swing/svg/JSVGComponent.java (revision 708070)
+++ 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);
+ }
}
/**
@@ -3126,7 +3135,7 @@
if (svgUserAgent != null) {
svgUserAgent.displayError(ex);
}
- }
+ }
/**
* Displays a message in the User Agent interface.
@@ -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();
--- sources/org/apache/batik/bridge/Location.java (revision 0)
+++ sources/org/apache/batik/bridge/Location.java (revision 0)
@@ -0,0 +1,63 @@
+/*
+
+ 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;
+
+/**
+ * This class implements the org.w3c.dom.Location interface for Batik
+ *
+ * @author G. Wade Johnson
+ * @version $Id: Loaction.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.
+ */
+ public void assign(String url) {
+ ((UserAgent)bridgeContext.getUserAgent()).loadDocument( url );
+ }
+
+ /**
+ * The user agent reloads the current document.
+ */
+ public void reload() {
+ URL url = ((SVGOMDocument) bridgeContext.getDocument())
+ .getURLObject();
+ ((UserAgent)bridgeContext.getUserAgent()).loadDocument( url.toString() );
+ }
+}
+
--- sources/org/apache/batik/bridge/UserAgent.java (revision 708070)
+++ 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);
}
--- sources/org/apache/batik/bridge/ScriptingEnvironment.java (revision 708070)
+++ 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,11 +918,17 @@
protected String language;
/**
+ * The Location object
+ */
+ protected Location location;
+
+ /**
* Creates a new Window for the given language.
*/
public Window(Interpreter interp, String lang) {
interpreter = interp;
language = lang;
+ location = null;
}
/**
@@ -1316,6 +1323,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( null == location ) {
+ location = new Location( bridgeContext );
+ }
+ return location;
+ }
}
/**
--- sources/org/apache/batik/script/rhino/WindowWrapper.java (revision 708070)
+++ 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() {
@@ -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 {
--- sources/org/apache/batik/script/Window.java (revision 708070)
+++ sources/org/apache/batik/script/Window.java (working copy)
@@ -22,6 +22,7 @@
import org.apache.batik.bridge.BridgeContext;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
+import org.w3c.dom.Location;
/**
* This interface represents the 'window' object defined in the global
@@ -30,7 +31,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
--- 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();
+}
--- 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.
+ */
+ void assign(String url);
+
+ /**
+ * The user agent reloads the current document.
+ */
+ void reload();
+}