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/08 00:06:13 UTC
svn commit: r384048 - in /xmlgraphics/batik/trunk:
sources/org/apache/batik/bridge/ sources/org/apache/batik/css/dom/
sources/org/apache/batik/css/engine/ sources/org/apache/batik/dom/
sources/org/apache/batik/dom/svg/ sources/org/apache/batik/extensio...
Author: cam
Date: Tue Mar 7 15:06:11 2006
New Revision: 384048
URL: http://svn.apache.org/viewcvs?rev=384048&view=rev
Log:
1. Override style declaration support.
Added:
xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMStoredStyleDeclaration.java (with props)
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/StyleDeclarationProvider.java (with props)
Modified:
xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/UserAgent.java
xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMSVGStyleDeclaration.java
xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMStyleDeclaration.java
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSEngine.java
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSNavigableDocumentListener.java
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSStylableElement.java
xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/StyleMap.java
xmlgraphics/batik/trunk/sources/org/apache/batik/dom/AbstractStylableDocument.java
xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMDocument.java
xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMTransform.java
xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGStylableElement.java
xmlgraphics/batik/trunk/sources/org/apache/batik/extension/StylableExtensionElement.java
xmlgraphics/batik/trunk/test-resources/org/apache/batik/bridge/unitTesting.xml
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/UserAgent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/UserAgent.java?rev=384048&r1=384047&r2=384048&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/UserAgent.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/bridge/UserAgent.java Tue Mar 7 15:06:11 2006
@@ -292,10 +292,10 @@
* 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 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,...).
+ * loaded (not available, corrupt, unknown format, ...).
*/
SVGDocument getBrokenLinkDocument(Element e, String url, String message);
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMSVGStyleDeclaration.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMSVGStyleDeclaration.java?rev=384048&r1=384047&r2=384048&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMSVGStyleDeclaration.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMSVGStyleDeclaration.java Tue Mar 7 15:06:11 2006
@@ -171,5 +171,4 @@
}
}
-
}
Added: xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMStoredStyleDeclaration.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMStoredStyleDeclaration.java?rev=384048&view=auto
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMStoredStyleDeclaration.java (added)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMStoredStyleDeclaration.java Tue Mar 7 15:06:11 2006
@@ -0,0 +1,97 @@
+package org.apache.batik.css.dom;
+
+import org.apache.batik.css.engine.CSSEngine;
+import org.apache.batik.css.engine.StyleDeclaration;
+import org.apache.batik.css.engine.StyleDeclarationProvider;
+import org.apache.batik.css.engine.value.Value;
+
+/**
+ * A class for SVG style declarations that store their properties in a
+ * {@link org.apache.batik.css.engine.StyleDeclaration}.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public abstract class CSSOMStoredStyleDeclaration
+ extends CSSOMSVGStyleDeclaration
+ implements CSSOMStyleDeclaration.ValueProvider,
+ CSSOMStyleDeclaration.ModificationHandler,
+ StyleDeclarationProvider {
+
+ /**
+ * The object storing the properties.
+ */
+ protected StyleDeclaration declaration;
+
+ /**
+ * Creates a new CSSOMStoredStyleDeclaration.
+ */
+ public CSSOMStoredStyleDeclaration(CSSEngine eng) {
+ super(null, null, eng);
+ valueProvider = this;
+ setModificationHandler(this);
+ }
+
+ /**
+ * Returns the object storing the properties of this style declaration.
+ */
+ public StyleDeclaration getStyleDeclaration() {
+ return declaration;
+ }
+
+ /**
+ * Sets the object storing the properties of this style declaration.
+ */
+ public void setStyleDeclaration(StyleDeclaration sd) {
+ declaration = sd;
+ }
+
+ // ValueProvider /////////////////////////////////////////////////////////
+
+ /**
+ * Returns the current value associated with this object.
+ */
+ public Value getValue(String name) {
+ int idx = cssEngine.getPropertyIndex(name);
+ for (int i = 0; i < declaration.size(); i++) {
+ if (idx == declaration.getIndex(i)) {
+ return declaration.getValue(i);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Tells whether the given property is important.
+ */
+ public boolean isImportant(String name) {
+ int idx = cssEngine.getPropertyIndex(name);
+ for (int i = 0; i < declaration.size(); i++) {
+ if (idx == declaration.getIndex(i)) {
+ return declaration.getPriority(i);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns the text of the declaration.
+ */
+ public String getText() {
+ return declaration.toString(cssEngine);
+ }
+
+ /**
+ * Returns the length of the declaration.
+ */
+ public int getLength() {
+ return declaration.size();
+ }
+
+ /**
+ * Returns the value at the given.
+ */
+ public String item(int idx) {
+ return cssEngine.getPropertyName(declaration.getIndex(idx));
+ }
+}
Propchange: xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMStoredStyleDeclaration.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMStyleDeclaration.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMStyleDeclaration.java?rev=384048&r1=384047&r2=384048&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMStyleDeclaration.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/css/dom/CSSOMStyleDeclaration.java Tue Mar 7 15:06:11 2006
@@ -235,7 +235,6 @@
* Returns the value at the given.
*/
String item(int idx);
-
}
/**
@@ -258,7 +257,6 @@
*/
void propertyChanged(String name, String value, String prio)
throws DOMException;
-
}
/**
@@ -307,6 +305,5 @@
public Value getValue() {
return CSSOMStyleDeclaration.this.valueProvider.getValue(property);
}
-
}
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSEngine.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSEngine.java?rev=384048&r1=384047&r2=384048&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSEngine.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSEngine.java Tue Mar 7 15:06:11 2006
@@ -821,6 +821,24 @@
}
}
}
+
+ // Apply the override rules to the result.
+ StyleDeclarationProvider p =
+ elt.getOverrideStyleDeclarationProvider();
+ StyleDeclaration over = p.getStyleDeclaration();
+ if (over != null) {
+ int ol = over.size();
+ for (int i = 0; i < ol; i++) {
+ int idx = over.getIndex(i);
+ Value value = over.getValue(i);
+ boolean important = over.getPriority(i);
+ if (!result.isImportant(idx) || important) {
+ result.putValue(idx, value);
+ result.putImportant(idx, important);
+ result.putOrigin(idx, StyleMap.OVERRIDE_ORIGIN);
+ }
+ }
+ }
} finally {
element = null;
cssBaseURI = null;
@@ -951,6 +969,7 @@
* set. Shorthand properties will be expanded "automatically".
*/
public interface MainPropertyReceiver {
+
/**
* Called with a non-shorthand property name and it's value.
*/
@@ -1259,6 +1278,9 @@
case StyleMap.AUTHOR_ORIGIN:
cond = !dimp || imp;
break;
+ case StyleMap.OVERRIDE_ORIGIN:
+ cond = false;
+ break;
default:
cond = true;
}
@@ -1856,13 +1878,14 @@
if (prevValue != null && prevValue.length() > 0) {
// Check if the style map has cascaded styles which
- // come from the inline style attribute.
+ // come from the inline style attribute or override style.
for (int i = getNumberOfProperties() - 1; i >= 0; --i) {
- if (style.isComputed(i) &&
- style.getOrigin(i) == StyleMap.INLINE_AUTHOR_ORIGIN &&
- !updated[i]) {
- removed = true;
- updated[i] = true;
+ if (style.isComputed(i) && !updated[i]) {
+ short origin = style.getOrigin(i);
+ if (origin >= StyleMap.INLINE_AUTHOR_ORIGIN) {
+ removed = true;
+ updated[i] = true;
+ }
}
}
}
@@ -2166,9 +2189,7 @@
return;
}
- switch (style.getOrigin(idx)) {
- case StyleMap.AUTHOR_ORIGIN:
- case StyleMap.INLINE_AUTHOR_ORIGIN:
+ if (style.getOrigin(idx) >= StyleMap.AUTHOR_ORIGIN) {
// The current value has a greater priority
return;
}
@@ -2313,7 +2334,19 @@
* To handle mutations of a CSSNavigableDocument.
*/
protected class CSSNavigableDocumentHandler
- implements CSSNavigableDocumentListener {
+ implements CSSNavigableDocumentListener,
+ MainPropertyReceiver {
+
+ /**
+ * Array to hold which properties have been changed by a call to
+ * setMainProperties.
+ */
+ protected boolean[] mainPropertiesChanged;
+
+ /**
+ * The StyleDeclaration to use from the MainPropertyReceiver.
+ */
+ protected StyleDeclaration declaration;
/**
* A node has been inserted into the CSSNavigableDocument tree.
@@ -2399,6 +2432,93 @@
String prevValue,
String newValue) {
handleAttrModified(e, attr, attrChange, prevValue, newValue);
+ }
+
+ /**
+ * The text of the override style declaration for this element has been
+ * modified.
+ */
+ public void overrideStyleTextChanged(CSSStylableElement elt,
+ String text) {
+ StyleDeclarationProvider p =
+ elt.getOverrideStyleDeclarationProvider();
+ StyleDeclaration declaration = p.getStyleDeclaration();
+ int ds = declaration.size();
+ boolean[] updated = new boolean[getNumberOfProperties()];
+ for (int i = 0; i < ds; i++) {
+ updated[declaration.getIndex(i)] = true;
+ }
+ declaration = parseStyleDeclaration(elt, text);
+ p.setStyleDeclaration(declaration);
+ ds = declaration.size();
+ for (int i = 0; i < ds; i++) {
+ updated[declaration.getIndex(i)] = true;
+ }
+ invalidateProperties(elt, null, updated, true);
+ }
+
+ /**
+ * A property in the override style declaration has been removed.
+ */
+ public void overrideStylePropertyRemoved(CSSStylableElement elt,
+ String name) {
+ StyleDeclarationProvider p =
+ elt.getOverrideStyleDeclarationProvider();
+ StyleDeclaration declaration = p.getStyleDeclaration();
+ int idx = getPropertyIndex(name);
+ int ds = declaration.size();
+ for (int i = 0; i < ds; i++) {
+ if (idx == declaration.getIndex(i)) {
+ declaration.remove(i);
+ StyleMap style = elt.getComputedStyleMap(null);
+ if (style.getOrigin(idx) == StyleMap.OVERRIDE_ORIGIN
+ && style.isComputed(idx)) {
+ invalidateProperties
+ (elt, new int[] { idx }, null, true);
+ }
+ break;
+ }
+ }
+ }
+
+ /**
+ * A property in the override style declaration has been changed.
+ */
+ public void overrideStylePropertyChanged(CSSStylableElement elt,
+ String name, String val,
+ String prio) {
+ boolean important = prio != null && prio.length() != 0;
+ StyleDeclarationProvider p =
+ elt.getOverrideStyleDeclarationProvider();
+ declaration = p.getStyleDeclaration();
+ setMainProperties(elt, this, name, val, important);
+ declaration = null;
+ invalidateProperties(elt, null, mainPropertiesChanged, true);
+ }
+
+ // MainPropertyReceiver //////////////////////////////////////////////
+
+ /**
+ * Sets a main property value in response to a shorthand property
+ * being set.
+ */
+ public void setMainProperty(String name, Value v, boolean important) {
+ int idx = getPropertyIndex(name);
+ if (idx == -1) {
+ return; // unknown property
+ }
+
+ int i;
+ for (i = 0; i < declaration.size(); i++) {
+ if (idx == declaration.getIndex(i)) {
+ break;
+ }
+ }
+ if (i < declaration.size()) {
+ declaration.put(i, v, idx, important);
+ } else {
+ declaration.append(v, idx, important);
+ }
}
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSNavigableDocumentListener.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSNavigableDocumentListener.java?rev=384048&r1=384047&r2=384048&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSNavigableDocumentListener.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSNavigableDocumentListener.java Tue Mar 7 15:06:11 2006
@@ -57,4 +57,21 @@
*/
void attrModified(Element e, Attr attr, short attrChange,
String prevValue, String newValue);
+
+ /**
+ * The text of the override style declaration for this element has been
+ * modified.
+ */
+ void overrideStyleTextChanged(CSSStylableElement e, String text);
+
+ /**
+ * A property in the override style declaration has been removed.
+ */
+ void overrideStylePropertyRemoved(CSSStylableElement e, String name);
+
+ /**
+ * A property in the override style declaration has been changed.
+ */
+ void overrideStylePropertyChanged(CSSStylableElement e, String name,
+ String val, String prio);
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSStylableElement.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSStylableElement.java?rev=384048&r1=384047&r2=384048&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSStylableElement.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/CSSStylableElement.java Tue Mar 7 15:06:11 2006
@@ -60,4 +60,10 @@
* class.
*/
boolean isPseudoInstanceOf(String pseudoClass);
+
+ /**
+ * Returns the object that gives access to the underlying
+ * {@link StyleDeclaration} for the override style of this element.
+ */
+ StyleDeclarationProvider getOverrideStyleDeclarationProvider();
}
Added: xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/StyleDeclarationProvider.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/StyleDeclarationProvider.java?rev=384048&view=auto
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/StyleDeclarationProvider.java (added)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/StyleDeclarationProvider.java Tue Mar 7 15:06:11 2006
@@ -0,0 +1,19 @@
+package org.apache.batik.css.engine;
+
+/**
+ * An interface for {@link org.w3c.dom.css.CSSStyleDeclaration} objects to
+ * expose their underlying {@link StyleDeclaration} objects storing the
+ * properties.
+ */
+public interface StyleDeclarationProvider {
+
+ /**
+ * Returns the object storing the properties of this style declaration.
+ */
+ StyleDeclaration getStyleDeclaration();
+
+ /**
+ * Sets the object storing the properties of this style declaration.
+ */
+ void setStyleDeclaration(StyleDeclaration sd);
+}
Propchange: xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/StyleDeclarationProvider.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/StyleMap.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/StyleMap.java?rev=384048&r1=384047&r2=384048&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/StyleMap.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/css/engine/StyleMap.java Tue Mar 7 15:06:11 2006
@@ -54,6 +54,7 @@
public final static short NON_CSS_ORIGIN = 0x4000; // 0100
public final static short AUTHOR_ORIGIN = 0x6000; // 0110
public final static short INLINE_AUTHOR_ORIGIN = (short)0x8000; // 1000
+ public final static short OVERRIDE_ORIGIN = (short)0xA000; // 1010
/**
* The values.
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/dom/AbstractStylableDocument.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/dom/AbstractStylableDocument.java?rev=384048&r1=384047&r2=384048&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/dom/AbstractStylableDocument.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/dom/AbstractStylableDocument.java Tue Mar 7 15:06:11 2006
@@ -121,5 +121,4 @@
String pseudoElt) {
throw new RuntimeException(" !!! Not implemented");
}
-
};
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMDocument.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMDocument.java?rev=384048&r1=384047&r2=384048&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMDocument.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMDocument.java Tue Mar 7 15:06:11 2006
@@ -22,11 +22,13 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Locale;
import java.util.MissingResourceException;
import org.apache.batik.css.engine.CSSNavigableDocument;
import org.apache.batik.css.engine.CSSNavigableDocumentListener;
+import org.apache.batik.css.engine.CSSStylableElement;
import org.apache.batik.dom.AbstractStylableDocument;
import org.apache.batik.dom.GenericAttr;
import org.apache.batik.dom.GenericAttrNS;
@@ -56,6 +58,7 @@
import org.w3c.dom.Node;
import org.w3c.dom.ProcessingInstruction;
import org.w3c.dom.Text;
+import org.w3c.dom.css.CSSStyleDeclaration;
import org.w3c.dom.events.Event;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.MutationEvent;
@@ -422,6 +425,45 @@
}
/**
+ * The text of the override style declaration for this element has been
+ * modified.
+ */
+ protected void overrideStyleTextChanged(CSSStylableElement e, String text) {
+ Iterator i = cssNavigableDocumentListeners.keySet().iterator();
+ while (i.hasNext()) {
+ CSSNavigableDocumentListener l =
+ (CSSNavigableDocumentListener) i.next();
+ l.overrideStyleTextChanged(e, text);
+ }
+ }
+
+ /**
+ * A property in the override style declaration has been removed.
+ */
+ protected void overrideStylePropertyRemoved(CSSStylableElement e,
+ String name) {
+ Iterator i = cssNavigableDocumentListeners.keySet().iterator();
+ while (i.hasNext()) {
+ CSSNavigableDocumentListener l =
+ (CSSNavigableDocumentListener) i.next();
+ l.overrideStylePropertyRemoved(e, name);
+ }
+ }
+
+ /**
+ * A property in the override style declaration has been changed.
+ */
+ protected void overrideStylePropertyChanged
+ (CSSStylableElement e, String name, String value, String prio) {
+ Iterator i = cssNavigableDocumentListeners.keySet().iterator();
+ while (i.hasNext()) {
+ CSSNavigableDocumentListener l =
+ (CSSNavigableDocumentListener) i.next();
+ l.overrideStylePropertyChanged(e, name, value, prio);
+ }
+ }
+
+ /**
* DOM node inserted listener wrapper.
*/
protected class DOMNodeInsertedListenerWrapper implements EventListener {
@@ -559,6 +601,20 @@
}
}
+ // DocumentCSS ////////////////////////////////////////////////////////////
+
+ /**
+ * <b>DOM</b>: Implements
+ * {@link DocumentCSS#getOverrideStyle(Element,String)}.
+ */
+ public CSSStyleDeclaration getOverrideStyle(Element elt,
+ String pseudoElt) {
+ if (elt instanceof SVGStylableElement && pseudoElt == null) {
+ return ((SVGStylableElement) elt).getOverrideStyle();
+ }
+ return null;
+ }
+
// AbstractDocument ///////////////////////////////////////////////
/**
@@ -587,13 +643,13 @@
* @param n a node of the type of this.
*/
protected Node copyInto(Node n) {
- super.copyInto(n);
- SVGOMDocument sd = (SVGOMDocument)n;
+ super.copyInto(n);
+ SVGOMDocument sd = (SVGOMDocument)n;
sd.localizableSupport = new LocalizableSupport
(RESOURCES, getClass().getClassLoader());
sd.referrer = referrer;
sd.url = url;
- return n;
+ return n;
}
/**
@@ -601,13 +657,13 @@
* @param n a node of the type of this.
*/
protected Node deepCopyInto(Node n) {
- super.deepCopyInto(n);
+ super.deepCopyInto(n);
SVGOMDocument sd = (SVGOMDocument)n;
sd.localizableSupport = new LocalizableSupport
(RESOURCES, getClass().getClassLoader());
sd.referrer = referrer;
sd.url = url;
- return n;
+ return n;
}
// Serialization //////////////////////////////////////////////////////
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMTransform.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMTransform.java?rev=384048&r1=384047&r2=384048&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMTransform.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGOMTransform.java Tue Mar 7 15:06:11 2006
@@ -23,52 +23,52 @@
import org.w3c.dom.svg.SVGMatrix;
/**
- * This class is the implementation of
- * the SVGTransform interface.
- *
- * Create an identity SVGTransform
+ * This class is the implementation of the SVGTransform interface.
*
* @author <a href="mailto:nicolas.socheleau@bitflash.com">Nicolas Socheleau</a>
* @version $Id$
*/
public class SVGOMTransform extends AbstractSVGTransform {
-
- public SVGOMTransform(){
- super();
+ /**
+ * Creates a new SVGOMTransform.
+ */
+ public SVGOMTransform() {
affineTransform = new AffineTransform();
}
- protected SVGMatrix createMatrix(){
- return new AbstractSVGMatrix(){
- protected AffineTransform getAffineTransform(){
- return SVGOMTransform.this.affineTransform;
- }
-
- public void setA(float a) throws DOMException {
- SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
- super.setA(a);
- }
- public void setB(float b) throws DOMException {
- SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
- super.setB(b);
- }
- public void setC(float c) throws DOMException {
- SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
- super.setC(c);
- }
- public void setD(float d) throws DOMException {
- SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
- super.setD(d);
- }
- public void setE(float e) throws DOMException {
- SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
- super.setE(e);
- }
- public void setF(float f) throws DOMException {
- SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
- super.setF(f);
- }
- };
+ /**
+ * Creates a new, modifiable SVGMatrix.
+ */
+ protected SVGMatrix createMatrix() {
+ return new AbstractSVGMatrix() {
+ protected AffineTransform getAffineTransform() {
+ return SVGOMTransform.this.affineTransform;
+ }
+ public void setA(float a) throws DOMException {
+ SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
+ super.setA(a);
+ }
+ public void setB(float b) throws DOMException {
+ SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
+ super.setB(b);
+ }
+ public void setC(float c) throws DOMException {
+ SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
+ super.setC(c);
+ }
+ public void setD(float d) throws DOMException {
+ SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
+ super.setD(d);
+ }
+ public void setE(float e) throws DOMException {
+ SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
+ super.setE(e);
+ }
+ public void setF(float f) throws DOMException {
+ SVGOMTransform.this.setType(SVG_TRANSFORM_MATRIX);
+ super.setF(f);
+ }
+ };
}
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGStylableElement.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGStylableElement.java?rev=384048&r1=384047&r2=384048&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGStylableElement.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/dom/svg/SVGStylableElement.java Tue Mar 7 15:06:11 2006
@@ -22,16 +22,18 @@
import org.apache.batik.css.dom.CSSOMSVGColor;
import org.apache.batik.css.dom.CSSOMSVGPaint;
-import org.apache.batik.css.dom.CSSOMSVGStyleDeclaration;
+import org.apache.batik.css.dom.CSSOMStoredStyleDeclaration;
import org.apache.batik.css.dom.CSSOMValue;
import org.apache.batik.css.engine.CSSEngine;
import org.apache.batik.css.engine.CSSStylableElement;
import org.apache.batik.css.engine.SVGCSSEngine;
+import org.apache.batik.css.engine.StyleDeclarationProvider;
import org.apache.batik.css.engine.StyleMap;
import org.apache.batik.css.engine.value.Value;
import org.apache.batik.css.engine.value.svg.SVGColorManager;
import org.apache.batik.css.engine.value.svg.SVGPaintManager;
import org.apache.batik.dom.AbstractDocument;
+
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
@@ -56,6 +58,11 @@
protected StyleMap computedStyleMap;
/**
+ * The override style declaration for this element.
+ */
+ protected OverrideStyleDeclaration overrideStyleDeclaration;
+
+ /**
* Creates a new SVGStylableElement object.
*/
protected SVGStylableElement() {
@@ -70,6 +77,17 @@
super(prefix, owner);
}
+ /**
+ * Returns the override style declaration for this element.
+ */
+ public CSSStyleDeclaration getOverrideStyle() {
+ if (overrideStyleDeclaration == null) {
+ CSSEngine eng = ((SVGOMDocument) getOwnerDocument()).getCSSEngine();
+ overrideStyleDeclaration = new OverrideStyleDeclaration(eng);
+ }
+ return overrideStyleDeclaration;
+ }
+
// CSSStylableElement //////////////////////////////////////////
/**
@@ -135,6 +153,15 @@
return false;
}
+ /**
+ * Returns the object that gives access to the underlying
+ * {@link org.apache.batik.css.engine.StyleDeclaration} for the override
+ * style of this element.
+ */
+ public StyleDeclarationProvider getOverrideStyleDeclarationProvider() {
+ return (StyleDeclarationProvider) getOverrideStyle();
+ }
+
// SVGStylable support ///////////////////////////////////////////////////
/**
@@ -509,18 +536,11 @@
* This class represents the 'style' attribute.
*/
public class StyleDeclaration
- extends CSSOMSVGStyleDeclaration
+ extends CSSOMStoredStyleDeclaration
implements LiveAttributeValue,
- CSSOMSVGStyleDeclaration.ValueProvider,
- CSSOMSVGStyleDeclaration.ModificationHandler,
CSSEngine.MainPropertyReceiver {
/**
- * The associated CSS object.
- */
- protected org.apache.batik.css.engine.StyleDeclaration declaration;
-
- /**
* Whether the mutation comes from this object.
*/
protected boolean mutate;
@@ -529,64 +549,13 @@
* Creates a new StyleDeclaration.
*/
public StyleDeclaration(CSSEngine eng) {
- super(null, null, eng);
- valueProvider = this;
- setModificationHandler(this);
+ super(eng);
declaration = cssEngine.parseStyleDeclaration
(SVGStylableElement.this,
getAttributeNS(null, SVG_STYLE_ATTRIBUTE));
}
- // ValueProvider ////////////////////////////////////////
-
- /**
- * Returns the current value associated with this object.
- */
- public Value getValue(String name) {
- int idx = cssEngine.getPropertyIndex(name);
- for (int i = 0; i < declaration.size(); i++) {
- if (idx == declaration.getIndex(i)) {
- return declaration.getValue(i);
- }
- }
- return null;
- }
-
- /**
- * Tells whether the given property is important.
- */
- public boolean isImportant(String name) {
- int idx = cssEngine.getPropertyIndex(name);
- for (int i = 0; i < declaration.size(); i++) {
- if (idx == declaration.getIndex(i)) {
- return declaration.getPriority(i);
- }
- }
- return false;
- }
-
- /**
- * Returns the text of the declaration.
- */
- public String getText() {
- return declaration.toString(cssEngine);
- }
-
- /**
- * Returns the length of the declaration.
- */
- public int getLength() {
- return declaration.size();
- }
-
- /**
- * Returns the value at the given.
- */
- public String item(int idx) {
- return cssEngine.getPropertyName(declaration.getIndex(idx));
- }
-
// LiveAttributeValue //////////////////////////////////////
/**
@@ -649,13 +618,33 @@
}
}
+ /**
+ * Called when a property was changed.
+ */
+ public void propertyChanged(String name, String value, String prio)
+ throws DOMException {
+ boolean important = prio != null && prio.length() > 0;
+ cssEngine.setMainProperties(SVGStylableElement.this,
+ this, name, value, important);
+ mutate = true;
+ setAttributeNS(null, SVG_STYLE_ATTRIBUTE,
+ declaration.toString(cssEngine));
+ mutate = false;
+ }
+
+ // MainPropertyReceiver //////////////////////////////////////////////
+
+ /**
+ * Sets a main property value in response to a shorthand property
+ * being set.
+ */
public void setMainProperty(String name, Value v, boolean important) {
int idx = cssEngine.getPropertyIndex(name);
if (idx == -1)
return; // unknown property
- int i=0;
- for (; i < declaration.size(); i++) {
+ int i;
+ for (i = 0; i < declaration.size(); i++) {
if (idx == declaration.getIndex(i))
break;
}
@@ -664,19 +653,48 @@
else
declaration.append(v, idx, important);
}
+ }
+
+ /**
+ * This class is a CSSStyleDeclaration for the override style of
+ * the element.
+ */
+ protected class OverrideStyleDeclaration
+ extends CSSOMStoredStyleDeclaration {
+
+ /**
+ * Creates a new OverrideStyleDeclaration.
+ */
+ public OverrideStyleDeclaration(CSSEngine eng) {
+ super(eng);
+ declaration = new org.apache.batik.css.engine.StyleDeclaration();
+ }
+
+ // ModificationHandler ///////////////////////////////////////////////
+
+ /**
+ * Called when the value text has changed.
+ */
+ public void textChanged(String text) throws DOMException {
+ ((SVGOMDocument) ownerDocument).overrideStyleTextChanged
+ (SVGStylableElement.this, text);
+ }
+
+ /**
+ * Called when a property was removed.
+ */
+ public void propertyRemoved(String name) throws DOMException {
+ ((SVGOMDocument) ownerDocument).overrideStylePropertyRemoved
+ (SVGStylableElement.this, name);
+ }
/**
* Called when a property was changed.
*/
public void propertyChanged(String name, String value, String prio)
- throws DOMException {
- boolean important = ((prio != null) && (prio.length() >0));
- cssEngine.setMainProperties(SVGStylableElement.this,
- this, name, value, important);
- mutate = true;
- setAttributeNS(null, SVG_STYLE_ATTRIBUTE,
- declaration.toString(cssEngine));
- mutate = false;
+ throws DOMException {
+ ((SVGOMDocument) ownerDocument).overrideStylePropertyChanged
+ (SVGStylableElement.this, name, value, prio);
}
}
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/extension/StylableExtensionElement.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/sources/org/apache/batik/extension/StylableExtensionElement.java?rev=384048&r1=384047&r2=384048&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/extension/StylableExtensionElement.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/extension/StylableExtensionElement.java Tue Mar 7 15:06:11 2006
@@ -22,6 +22,7 @@
import java.net.URL;
import org.apache.batik.css.engine.CSSStylableElement;
+import org.apache.batik.css.engine.StyleDeclarationProvider;
import org.apache.batik.css.engine.StyleMap;
import org.apache.batik.dom.AbstractDocument;
import org.w3c.dom.Node;
@@ -132,6 +133,15 @@
return n == null;
}
return false;
+ }
+
+ /**
+ * Returns the object that gives access to the underlying
+ * {@link org.apache.batik.css.engine.StyleDeclaration} for the override
+ * style of this element.
+ */
+ public StyleDeclarationProvider getOverrideStyleDeclarationProvider() {
+ return null;
}
// SVGStylable //////////////////////////////////////////////////
Modified: xmlgraphics/batik/trunk/test-resources/org/apache/batik/bridge/unitTesting.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/trunk/test-resources/org/apache/batik/bridge/unitTesting.xml?rev=384048&r1=384047&r2=384048&view=diff
==============================================================================
--- xmlgraphics/batik/trunk/test-resources/org/apache/batik/bridge/unitTesting.xml (original)
+++ xmlgraphics/batik/trunk/test-resources/org/apache/batik/bridge/unitTesting.xml Tue Mar 7 15:06:11 2006
@@ -179,7 +179,7 @@
<property name="ExpectedErrorCode" class="java.lang.String"
value="css.uri.badTarget" />
</test>
- <!-- No longer generats exception - just user warning
+ <!-- No longer generates exception - just user warning
<test id="bridge/error/css-invalid">
<property name="ExpectedExceptionClass" class="java.lang.String"
value="org.w3c.dom.DOMException" />