hillion 02/03/21 02:59:34
Modified: samples mines.svg
sources/org/apache/batik/bridge SVGImageElementBridge.java
sources/org/apache/batik/css/engine CSSEngine.java
Log:
- Broken images were broken...
- mines.svg used a Java-specific expression,
- XML presentation attributes update now works.
Revision Changes Path
1.3 +3 -3 xml-batik/samples/mines.svg
Index: mines.svg
===================================================================
RCS file: /home/cvs/xml-batik/samples/mines.svg,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- mines.svg 20 Mar 2002 20:31:26 -0000 1.2
+++ mines.svg 21 Mar 2002 10:59:34 -0000 1.3
@@ -11,10 +11,10 @@
<!-- ====================================================================== -->
<!-- ====================================================================== -->
-<!-- Defines the Batik Logo using an SVG font. -->
+<!-- Minesweeper in SVG -->
<!-- -->
<!-- @author [EMAIL PROTECTED] -->
-<!-- @version $Id: mines.svg,v 1.2 2002/03/20 20:31:26 deweese Exp $ -->
+<!-- @version $Id: mines.svg,v 1.3 2002/03/21 10:59:34 hillion Exp $ -->
<!-- ====================================================================== -->
<svg width="450" height="500" viewBox="0 0 450 500"
@@ -73,7 +73,7 @@
}
for (var i=0; i<numMines; i++) {
- var index = new Integer(Math.random()*(numDown*numAcross)).intValue();
+ var index = Math.round(Math.random()*(numDown*numAcross));
if ((index >= (numDown*numAcross)) ||
(boardArray[index]!=0)) {
i--;
1.43 +4 -2
xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java
Index: SVGImageElementBridge.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGImageElementBridge.java,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- SVGImageElementBridge.java 20 Mar 2002 16:34:43 -0000 1.42
+++ SVGImageElementBridge.java 21 Mar 2002 10:59:34 -0000 1.43
@@ -57,7 +57,7 @@
* Bridge class for the <image> element.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a>
- * @version $Id: SVGImageElementBridge.java,v 1.42 2002/03/20 16:34:43 tkormann Exp
$
+ * @version $Id: SVGImageElementBridge.java,v 1.43 2002/03/21 10:59:34 hillion Exp $
*/
public class SVGImageElementBridge extends AbstractGraphicsNodeBridge {
@@ -221,7 +221,9 @@
(SVGBrokenLinkProvider.SVG_BROKEN_LINK_DOCUMENT_PROPERTY);
if ((obj != null) && (obj instanceof SVGDocument)) {
// Ok so we are dealing with a broken link.
- return createSVGImageNode(ctx, e, (SVGDocument)obj);
+ SVGOMDocument doc = (SVGOMDocument)obj;
+ ctx.initializeDocument(doc);
+ return createSVGImageNode(ctx, e, doc);
}
node.setImage(img);
Rectangle2D imgBounds = img.getBounds2D();
1.4 +172 -64 xml-batik/sources/org/apache/batik/css/engine/CSSEngine.java
Index: CSSEngine.java
===================================================================
RCS file: /home/cvs/xml-batik/sources/org/apache/batik/css/engine/CSSEngine.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CSSEngine.java 20 Mar 2002 16:34:44 -0000 1.3
+++ CSSEngine.java 21 Mar 2002 10:59:34 -0000 1.4
@@ -58,7 +58,7 @@
* This is the base class for all the CSS engines.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a>
- * @version $Id: CSSEngine.java,v 1.3 2002/03/20 16:34:44 tkormann Exp $
+ * @version $Id: CSSEngine.java,v 1.4 2002/03/21 10:59:34 hillion Exp $
*/
public abstract class CSSEngine {
@@ -265,6 +265,11 @@
protected List listeners = Collections.synchronizedList(new LinkedList());
/**
+ * Used to fire a change event for all the properties.
+ */
+ protected final int[] ALL_PROPERTIES;
+
+ /**
* Creates a new CSSEngine.
* @param doc The associated document.
* @param uri The document URI.
@@ -348,6 +353,11 @@
styleDeclarationUpdateHandler =
new StyleDeclarationUpdateHandler();
}
+
+ ALL_PROPERTIES = new int[getNumberOfProperties()];
+ for (int i = getNumberOfProperties() - 1; i >= 0; --i) {
+ ALL_PROPERTIES[i] = i;
+ }
}
/**
@@ -1388,69 +1398,77 @@
}
if (removed) {
- // Invalidate the entire style map
+ // Invalidate all the values.
elt.setComputedStyleMap(null, null);
- }
- // Invalidate the relative values
- boolean fs = (fontSizeIndex == -1)
- ? false
- : updated[fontSizeIndex];
- boolean lh = (lineHeightIndex == -1)
- ? false
- : updated[lineHeightIndex];
- boolean cl = (colorIndex == -1)
- ? false
- : updated[colorIndex];
- int count = 0;
-
- for (int i = getNumberOfProperties() - 1; i >= 0; --i) {
- if (!updated[i]) {
- if (style.isComputed(i)) {
- if (fs && style.isFontSizeRelative(i)) {
- updated[i] = true;
+ firePropertiesChangedEvent(elt, ALL_PROPERTIES);
+
+ for (Node n = elt.getFirstChild();
+ n != null;
+ n = n.getNextSibling()) {
+ propagateChanges(n, ALL_PROPERTIES);
+ Node c = getImportedChild(n);
+ if (c != null) {
+ propagateChanges(c, ALL_PROPERTIES);
+ }
+ }
+ } else {
+ int count = 0;
+
+
+ // Invalidate the relative values
+ boolean fs = (fontSizeIndex == -1)
+ ? false
+ : updated[fontSizeIndex];
+ boolean lh = (lineHeightIndex == -1)
+ ? false
+ : updated[lineHeightIndex];
+ boolean cl = (colorIndex == -1)
+ ? false
+ : updated[colorIndex];
+
+ for (int i = getNumberOfProperties() - 1; i >= 0; --i) {
+ if (!updated[i]) {
+ if (style.isComputed(i)) {
+ if (fs && style.isFontSizeRelative(i)) {
+ updated[i] = true;
count++;
- if (!removed) {
- clearComputedValue(style, i);
- }
- }
- if (lh && style.isLineHeightRelative(i)) {
- updated[i] = true;
- count++;
- if (!removed) {
clearComputedValue(style, i);
}
- }
- if (cl && style.isColorRelative(i)) {
- updated[i] = true;
- count++;
- if (!removed) {
+ if (lh && style.isLineHeightRelative(i)) {
+ updated[i] = true;
+ count++;
+ clearComputedValue(style, i);
+ }
+ if (cl && style.isColorRelative(i)) {
+ updated[i] = true;
+ count++;
clearComputedValue(style, i);
}
}
+ } else {
+ count++;
}
- } else {
- count++;
}
- }
- if (count > 0) {
- int[] props = new int[count];
- count = 0;
- for (int i = getNumberOfProperties() - 1; i >= 0; --i) {
- if (updated[i]) {
- props[count++] = i;
+ if (count > 0) {
+ int[] props = new int[count];
+ count = 0;
+ for (int i = getNumberOfProperties() - 1; i >= 0; --i) {
+ if (updated[i]) {
+ props[count++] = i;
}
- }
- firePropertiesChangedEvent(elt, props);
-
- for (Node n = elt.getFirstChild();
- n != null;
- n = n.getNextSibling()) {
- propagateChanges(n, props);
- Node c = getImportedChild(n);
- if (c != null) {
- propagateChanges(c, props);
+ }
+ firePropertiesChangedEvent(elt, props);
+
+ for (Node n = elt.getFirstChild();
+ n != null;
+ n = n.getNextSibling()) {
+ propagateChanges(n, props);
+ Node c = getImportedChild(n);
+ if (c != null) {
+ propagateChanges(c, props);
+ }
}
}
}
@@ -1592,16 +1610,9 @@
value,
important);
} else {
- boolean vimp = styleMap.isImportant(i);
- if (important && vimp) {
- short vorig = styleMap.getOrigin(i);
- if (vorig == StyleMap.USER_ORIGIN) {
- // The previous value comes from the user and
- // is important, so it must not be updated.
- return;
- }
- }
- if (vimp && !important) {
+ if (styleMap.isImportant(i)) {
+ // The previous value is important, and a value
+ // from a style attribute cannot be important...
return;
}
@@ -1612,7 +1623,6 @@
Value v = valueManagers[i].createValue(value, CSSEngine.this);
styleMap.putMask(i, (short)0);
styleMap.putValue(i, v);
- styleMap.putImportant(i, important);
styleMap.putOrigin(i, StyleMap.INLINE_AUTHOR_ORIGIN);
}
}
@@ -1625,8 +1635,103 @@
StyleMap style,
String property,
MutationEvent evt) {
- System.out.println("NON-CSS HINT MODIFIED: Not supported");
+ int idx = getPropertyIndex(property);
+
+ if (style.isImportant(idx)) {
+ // The current value is important, and a value
+ // from an XML attribute cannot be important...
+ return;
+ }
+
+ switch (style.getOrigin(idx)) {
+ case StyleMap.AUTHOR_ORIGIN:
+ case StyleMap.INLINE_AUTHOR_ORIGIN:
+ // The current value has a greater priority
+ return;
+ }
+
+ boolean comp = style.isComputed(idx);
+
+ try {
+ LexicalUnit lu;
+ lu = parser.parsePropertyValue(evt.getNewValue());
+ ValueManager vm = valueManagers[idx];
+ Value v = vm.createValue(lu, CSSEngine.this);
+ style.putMask(idx, (short)0);
+ style.putValue(idx, v);
+ style.putOrigin(idx, StyleMap.NON_CSS_ORIGIN);
+ } catch (Exception e) {
+ e.printStackTrace();
+ String m = e.getMessage();
+ String s =
+ Messages.formatMessage("property.syntax.error.at",
+ new Object[] { documentURI.toString(),
+ property,
+ evt.getNewValue(),
+ (m == null) ? "" : m });
+ throw new DOMException(DOMException.SYNTAX_ERR, s);
+ }
+
+ if (!comp) {
+ // The previous value was not computed: nobody is
+ // interested by this property modifications
+ return;
+ }
+
+ boolean[] updated = styleDeclarationUpdateHandler.updatedProperties;
+ for (int i = getNumberOfProperties() - 1; i >= 0; --i) {
+ updated[i] = false;
+ }
+ updated[idx] = true;
+
+ // Invalidate the relative values
+ boolean fs = idx == fontSizeIndex;
+ boolean lh = idx == lineHeightIndex;
+ boolean cl = idx == colorIndex;
+ int count = 0;
+
+ for (int i = getNumberOfProperties() - 1; i >= 0; --i) {
+ if (!updated[i]) {
+ if (style.isComputed(i)) {
+ if (fs && style.isFontSizeRelative(i)) {
+ updated[i] = true;
+ count++;
+ clearComputedValue(style, i);
+ }
+ if (lh && style.isLineHeightRelative(i)) {
+ updated[i] = true;
+ count++;
+ clearComputedValue(style, i);
+ }
+ if (cl && style.isColorRelative(i)) {
+ updated[i] = true;
+ count++;
+ clearComputedValue(style, i);
+ }
+ }
+ } else {
+ count++;
+ }
+ }
+
+ int[] props = new int[count];
+ count = 0;
+ for (int i = getNumberOfProperties() - 1; i >= 0; --i) {
+ if (updated[i]) {
+ props[count++] = i;
+ }
+ }
+ firePropertiesChangedEvent(elt, props);
+ for (Node n = elt.getFirstChild();
+ n != null;
+ n = n.getNextSibling()) {
+ propagateChanges(n, props);
+ Node c = getImportedChild(n);
+ if (c != null) {
+ propagateChanges(c, props);
+ }
+ }
}
/**
@@ -1648,6 +1753,9 @@
// element, so it does not require an update...
return;
}
+
+ // !!! TODO: class mutation
+ // !!! TODO: id mutation
MutationEvent mevt = (MutationEvent)evt;
Node attr = mevt.getRelatedNode();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]