You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2006/03/23 05:56:19 UTC
svn commit: r388037 - in
/xmlgraphics/batik/branches/webapi/sources/org/apache/batik:
bridge/BaseScriptingEnvironment.java bridge/ScriptingEnvironment.java
dom/svg/SVGOMDocument.java dom/svg/ViewCSSProxy.java
Author: cam
Date: Wed Mar 22 20:56:17 2006
New Revision: 388037
URL: http://svn.apache.org/viewcvs?rev=388037&view=rev
Log:
1. Rejigged the document's default view object so that the Window is the
one returned from document.getDefaultView().
Added:
xmlgraphics/batik/branches/webapi/sources/org/apache/batik/dom/svg/ViewCSSProxy.java (with props)
Modified:
xmlgraphics/batik/branches/webapi/sources/org/apache/batik/bridge/BaseScriptingEnvironment.java
xmlgraphics/batik/branches/webapi/sources/org/apache/batik/bridge/ScriptingEnvironment.java
xmlgraphics/batik/branches/webapi/sources/org/apache/batik/dom/svg/SVGOMDocument.java
Modified: xmlgraphics/batik/branches/webapi/sources/org/apache/batik/bridge/BaseScriptingEnvironment.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/webapi/sources/org/apache/batik/bridge/BaseScriptingEnvironment.java?rev=388037&r1=388036&r2=388037&view=diff
==============================================================================
--- xmlgraphics/batik/branches/webapi/sources/org/apache/batik/bridge/BaseScriptingEnvironment.java (original)
+++ xmlgraphics/batik/branches/webapi/sources/org/apache/batik/bridge/BaseScriptingEnvironment.java Wed Mar 22 20:56:17 2006
@@ -264,6 +264,21 @@
}
/**
+ * Initializes the environment of the given interpreter.
+ */
+ public void initializeEnvironment(Interpreter interp, String lang) {
+ org.apache.batik.script.Window window = createWindow(interp, lang);
+ interp.bindObject("window", window);
+ registerWindowObject(window);
+ }
+
+ /**
+ * Registers a newly created Window object with the document.
+ */
+ protected void registerWindowObject(org.apache.batik.script.Window window) {
+ }
+
+ /**
* Returns the default Interpreter for this document.
*/
public Interpreter getInterpreter() {
@@ -296,13 +311,6 @@
}
/**
- * 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() {
@@ -362,6 +370,7 @@
if (window == null) {
window = createWindow();
+ registerWindowObject(window);
}
h.run(document, window);
@@ -376,6 +385,7 @@
if (window == null) {
window = createWindow();
+ registerWindowObject(window);
}
initializer.initializeEventListeners((SVGDocument)document);
Modified: xmlgraphics/batik/branches/webapi/sources/org/apache/batik/bridge/ScriptingEnvironment.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/webapi/sources/org/apache/batik/bridge/ScriptingEnvironment.java?rev=388037&r1=388036&r2=388037&view=diff
==============================================================================
--- xmlgraphics/batik/branches/webapi/sources/org/apache/batik/bridge/ScriptingEnvironment.java (original)
+++ xmlgraphics/batik/branches/webapi/sources/org/apache/batik/bridge/ScriptingEnvironment.java Wed Mar 22 20:56:17 2006
@@ -38,10 +38,13 @@
import java.util.zip.GZIPOutputStream;
import java.util.zip.DeflaterOutputStream;
+import org.apache.batik.dom.AbstractStylableDocument;
+import org.apache.batik.dom.ExtensibleDOMImplementation;
import org.apache.batik.dom.GenericDOMImplementation;
import org.apache.batik.dom.events.NodeEventTarget;
import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.dom.svg.SVGOMDocument;
+import org.apache.batik.dom.svg.ViewCSSProxy;
import org.apache.batik.dom.util.SAXDocumentFactory;
import org.apache.batik.dom.util.XLinkSupport;
import org.apache.batik.script.Interpreter;
@@ -57,6 +60,8 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.w3c.dom.css.CSSStyleDeclaration;
+import org.w3c.dom.css.ViewCSS;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.MutationEvent;
@@ -392,15 +397,13 @@
}
/**
- * Initializes the environment of the given interpreter.
+ * Registers a newly created Window object with the document.
*/
- public void initializeEnvironment(Interpreter interp, String lang) {
- org.w3c.dom.window.Window window =
- (org.w3c.dom.window.Window) createWindow(interp, lang);
- interp.bindObject("window", window);
- Object doc = window.getDocument();
+ protected void registerWindowObject(org.apache.batik.script.Window window) {
+ org.w3c.dom.window.Window w = (org.w3c.dom.window.Window) window;
+ Object doc = w.getDocument();
if (doc instanceof SVGOMDocument) {
- ((SVGOMDocument) doc).setWindow(window);
+ ((SVGOMDocument) doc).setDefaultView(w);
}
}
@@ -816,7 +819,9 @@
* Represents the window object of this environment.
*/
protected class Window implements org.apache.batik.script.Window,
- org.w3c.dom.window.Window {
+ org.w3c.dom.window.Window,
+ ViewCSS,
+ ViewCSSProxy {
/**
* The associated interpreter.
@@ -829,6 +834,11 @@
protected String language;
/**
+ * The ViewCSS this Window object is proxying.
+ */
+ protected ViewCSS viewCSS;
+
+ /**
* Creates a new Window for the given language.
*/
public Window(Interpreter interp, String lang) {
@@ -1335,6 +1345,32 @@
*/
public org.w3c.dom.window.Window getSelf() {
return this;
+ }
+
+ // ViewCSS ///////////////////////////////////////////////////////////
+
+ /**
+ * <b>DOM</b>: Implements {@link
+ * org.w3c.dom.css.ViewCSS#getComputedStyle(Element,String)}.
+ */
+ public CSSStyleDeclaration getComputedStyle(Element elt,
+ String pseudoElt) {
+ if (viewCSS == null) {
+ ExtensibleDOMImplementation impl =
+ (ExtensibleDOMImplementation) document.getImplementation();
+ viewCSS = impl.createViewCSS
+ ((AbstractStylableDocument) document);
+ }
+ return viewCSS.getComputedStyle(elt, pseudoElt);
+ }
+
+ // ViewCSSProxy //////////////////////////////////////////////////////
+
+ /**
+ * Invalidates the current ViewCSS object.
+ */
+ public void clearViewCSS() {
+ viewCSS = null;
}
}
Modified: xmlgraphics/batik/branches/webapi/sources/org/apache/batik/dom/svg/SVGOMDocument.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/webapi/sources/org/apache/batik/dom/svg/SVGOMDocument.java?rev=388037&r1=388036&r2=388037&view=diff
==============================================================================
--- xmlgraphics/batik/branches/webapi/sources/org/apache/batik/dom/svg/SVGOMDocument.java (original)
+++ xmlgraphics/batik/branches/webapi/sources/org/apache/batik/dom/svg/SVGOMDocument.java Wed Mar 22 20:56:17 2006
@@ -612,13 +612,6 @@
// ViewCSS ///////////////////////////////////////////////////////////////
/**
- * Creates the default view for this document.
- */
- protected AbstractView createDefaultView() {
- return new DefaultView();
- }
-
- /**
* Clears the view CSS.
*/
public void clearViewCSS() {
@@ -626,97 +619,18 @@
cssEngine.dispose();
}
cssEngine = null;
- ((DefaultView) defaultView).clearViewCSS();
+ if (defaultView instanceof ViewCSSProxy) {
+ ((ViewCSSProxy) defaultView).clearViewCSS();
+ } else {
+ defaultView = null;
+ }
}
/**
* Sets the Window object to be used by the default view.
*/
- public void setWindow(Window window) {
- DefaultView defaultView = (DefaultView) getDefaultView();
- defaultView.setWindow(window);
- }
-
- /**
- * The default view for this document.
- */
- protected class DefaultView implements ViewCSS, Window {
-
- /**
- * The proxied ViewCSS object.
- */
- protected ViewCSS viewCSS;
-
- /**
- * The proxied Window object.
- */
- protected Window window;
-
- /**
- * Clears the proxied ViewCSS object in response to a change
- * of CSSEngine on the document.
- */
- public void clearViewCSS() {
- viewCSS = null;
- }
-
- /**
- * Sets the Window object to be proxied by this default view.
- */
- public void setWindow(Window window) {
- this.window = window;
- }
-
- /**
- * Creates a proxied ViewCSS object.
- */
- protected void createViewCSS() {
- ExtensibleDOMImplementation impl =
- (ExtensibleDOMImplementation) implementation;
- viewCSS = impl.createViewCSS(SVGOMDocument.this);
- }
-
- // AbstractView //////////////////////////////////////////////////////
-
- /**
- * The source <code>DocumentView</code> of which this is an
- * <code>AbstractView</code>.
- */
- public DocumentView getDocument() {
- return (DocumentView) SVGOMDocument.this;
- }
-
- // ViewCSS ///////////////////////////////////////////////////////////
-
- /**
- * <b>DOM</b>: Implements {@link
- * org.w3c.dom.css.ViewCSS#getComputedStyle(Element,String)}.
- */
- public CSSStyleDeclaration getComputedStyle(Element elt,
- String pseudoElt) {
- if (viewCSS == null) {
- createViewCSS();
- }
- return viewCSS.getComputedStyle(elt, pseudoElt);
- }
-
- // Window ////////////////////////////////////////////////////////////
-
- /**
- * <b>DOM</b>: Implements
- * {@link org.w3c.dom.window.Window#getWindow()}.
- */
- public Window getWindow() {
- return window.getWindow();
- }
-
- /**
- * <b>DOM</b>: Implements
- * {@link org.w3c.dom.window.Window#getSelf()}.
- */
- public Window getSelf() {
- return window.getSelf();
- }
+ public void setDefaultView(AbstractView defaultView) {
+ this.defaultView = defaultView;
}
// DocumentCSS ////////////////////////////////////////////////////////////
Added: xmlgraphics/batik/branches/webapi/sources/org/apache/batik/dom/svg/ViewCSSProxy.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/webapi/sources/org/apache/batik/dom/svg/ViewCSSProxy.java?rev=388037&view=auto
==============================================================================
--- xmlgraphics/batik/branches/webapi/sources/org/apache/batik/dom/svg/ViewCSSProxy.java (added)
+++ xmlgraphics/batik/branches/webapi/sources/org/apache/batik/dom/svg/ViewCSSProxy.java Wed Mar 22 20:56:17 2006
@@ -0,0 +1,35 @@
+/*
+
+ Copyright 2006 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
+
+ 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.dom.svg;
+
+import org.w3c.dom.css.ViewCSS;
+
+/**
+ * An interface for an object that implements {@link ViewCSS} by proxying
+ * to another object.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public interface ViewCSSProxy extends ViewCSS {
+
+ /**
+ * Invalidates the current ViewCSS object.
+ */
+ void clearViewCSS();
+}
Propchange: xmlgraphics/batik/branches/webapi/sources/org/apache/batik/dom/svg/ViewCSSProxy.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision