summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkitfox2010-10-04 03:48:24 +0200
committerkitfox2010-10-04 03:48:24 +0200
commit772dcb67eb2cfee63de8f36988f332d8ad31e12c (patch)
treebc176112ee0a7eaa4cee36357709ce397e14d90e
parentAdding <hkern> to source. (diff)
downloadsvg-salamander-core-772dcb67eb2cfee63de8f36988f332d8ad31e12c.tar.gz
svg-salamander-core-772dcb67eb2cfee63de8f36988f332d8ad31e12c.tar.xz
svg-salamander-core-772dcb67eb2cfee63de8f36988f332d8ad31e12c.zip
Fixing animation update for XML attributes.
git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@82 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b
-rw-r--r--src/main/java/com/kitfox/svg/Circle.java20
-rw-r--r--src/main/java/com/kitfox/svg/ClipPath.java16
-rw-r--r--src/main/java/com/kitfox/svg/Ellipse.java7
-rw-r--r--src/main/java/com/kitfox/svg/ImageSVG.java51
-rw-r--r--src/main/java/com/kitfox/svg/Line.java16
-rw-r--r--src/main/java/com/kitfox/svg/Path.java7
-rw-r--r--src/main/java/com/kitfox/svg/Polygon.java7
-rw-r--r--src/main/java/com/kitfox/svg/Polyline.java7
-rw-r--r--src/main/java/com/kitfox/svg/Rect.java21
-rw-r--r--src/main/java/com/kitfox/svg/SVGElement.java4
-rw-r--r--src/main/java/com/kitfox/svg/SVGRoot.java15
-rw-r--r--src/main/java/com/kitfox/svg/Text.java7
-rw-r--r--src/main/java/com/kitfox/svg/Use.java20
-rw-r--r--src/main/java/com/kitfox/svg/xml/NumberWithUnits.java59
14 files changed, 164 insertions, 93 deletions
diff --git a/src/main/java/com/kitfox/svg/Circle.java b/src/main/java/com/kitfox/svg/Circle.java
index 80daf35..93c576f 100644
--- a/src/main/java/com/kitfox/svg/Circle.java
+++ b/src/main/java/com/kitfox/svg/Circle.java
@@ -28,15 +28,10 @@
package com.kitfox.svg;
import com.kitfox.svg.xml.StyleAttribute;
-import com.kitfox.svg.xml.*;
-import com.kitfox.svg.animation.*;
-import org.xml.sax.*;
-
-import java.net.*;
-import java.io.*;
-import java.util.*;
-import java.awt.*;
-import java.awt.geom.*;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Rectangle2D;
/**
* @author Mark McKay
@@ -162,11 +157,12 @@ public class Circle extends ShapeElement
if (shapeChange)
{
- circle.setFrame(cx - r, cy - r, r * 2f, r * 2f);
- return true;
+ build();
+// circle.setFrame(cx - r, cy - r, r * 2f, r * 2f);
+// return true;
}
- return changeState;
+ return changeState || shapeChange;
}
}
diff --git a/src/main/java/com/kitfox/svg/ClipPath.java b/src/main/java/com/kitfox/svg/ClipPath.java
index 8354c03..993521c 100644
--- a/src/main/java/com/kitfox/svg/ClipPath.java
+++ b/src/main/java/com/kitfox/svg/ClipPath.java
@@ -28,12 +28,9 @@
package com.kitfox.svg;
import com.kitfox.svg.xml.StyleAttribute;
-import java.awt.*;
-import java.awt.geom.*;
-import java.util.*;
-
-import com.kitfox.svg.xml.*;
-import org.xml.sax.*;
+import java.awt.Shape;
+import java.awt.geom.Area;
+import java.util.Iterator;
/**
* @author Mark McKay
@@ -151,7 +148,12 @@ public class ClipPath extends SVGElement
shapeChange = true;
}
}
-
+
+ if (shapeChange)
+ {
+ build();
+ }
+
return shapeChange;
}
}
diff --git a/src/main/java/com/kitfox/svg/Ellipse.java b/src/main/java/com/kitfox/svg/Ellipse.java
index 1047930..30586e2 100644
--- a/src/main/java/com/kitfox/svg/Ellipse.java
+++ b/src/main/java/com/kitfox/svg/Ellipse.java
@@ -182,10 +182,11 @@ public class Ellipse extends ShapeElement {
if (shapeChange)
{
- ellipse.setFrame(cx - rx, cy - ry, rx * 2f, ry * 2f);
- return true;
+ build();
+// ellipse.setFrame(cx - rx, cy - ry, rx * 2f, ry * 2f);
+// return true;
}
- return changeState;
+ return changeState || shapeChange;
}
}
diff --git a/src/main/java/com/kitfox/svg/ImageSVG.java b/src/main/java/com/kitfox/svg/ImageSVG.java
index e2fb168..eb25586 100644
--- a/src/main/java/com/kitfox/svg/ImageSVG.java
+++ b/src/main/java/com/kitfox/svg/ImageSVG.java
@@ -275,33 +275,34 @@ public class ImageSVG extends RenderableElement
if (shapeChange)
{
- diagram.getUniverse().registerImage(imageSrc);
-
- //Set widths if not set
- BufferedImage img = diagram.getUniverse().getImage(imageSrc);
- if (img == null)
- {
- xform = new AffineTransform();
- bounds = new Rectangle2D.Float();
- }
- else
- {
- if (width == 0) width = img.getWidth();
- if (height == 0) height = img.getHeight();
-
- //Determine image xform
- xform = new AffineTransform();
-// xform.setToScale(this.width / img.getWidth(), this.height / img.getHeight());
+ build();
+// diagram.getUniverse().registerImage(imageSrc);
+//
+// //Set widths if not set
+// BufferedImage img = diagram.getUniverse().getImage(imageSrc);
+// if (img == null)
+// {
+// xform = new AffineTransform();
+// bounds = new Rectangle2D.Float();
+// }
+// else
+// {
+// if (width == 0) width = img.getWidth();
+// if (height == 0) height = img.getHeight();
+//
+// //Determine image xform
+// xform = new AffineTransform();
+//// xform.setToScale(this.width / img.getWidth(), this.height / img.getHeight());
+//// xform.translate(this.x, this.y);
// xform.translate(this.x, this.y);
- xform.translate(this.x, this.y);
- xform.scale(this.width / img.getWidth(), this.height / img.getHeight());
-
- bounds = new Rectangle2D.Float(this.x, this.y, this.width, this.height);
- }
-
- return true;
+// xform.scale(this.width / img.getWidth(), this.height / img.getHeight());
+//
+// bounds = new Rectangle2D.Float(this.x, this.y, this.width, this.height);
+// }
+//
+// return true;
}
- return changeState;
+ return changeState || shapeChange;
}
}
diff --git a/src/main/java/com/kitfox/svg/Line.java b/src/main/java/com/kitfox/svg/Line.java
index f52a9c8..bc318ff 100644
--- a/src/main/java/com/kitfox/svg/Line.java
+++ b/src/main/java/com/kitfox/svg/Line.java
@@ -28,11 +28,10 @@
package com.kitfox.svg;
import com.kitfox.svg.xml.StyleAttribute;
-import com.kitfox.svg.xml.*;
-import org.xml.sax.*;
-
-import java.awt.*;
-import java.awt.geom.*;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
/**
* @author Mark McKay
@@ -163,10 +162,11 @@ public class Line extends ShapeElement {
if (shapeChange)
{
- line = new Line2D.Float(x1, y1, x2, y2);
- return true;
+ build();
+// line = new Line2D.Float(x1, y1, x2, y2);
+// return true;
}
- return changeState;
+ return changeState || shapeChange;
}
}
diff --git a/src/main/java/com/kitfox/svg/Path.java b/src/main/java/com/kitfox/svg/Path.java
index 85feff3..a45ca14 100644
--- a/src/main/java/com/kitfox/svg/Path.java
+++ b/src/main/java/com/kitfox/svg/Path.java
@@ -144,10 +144,11 @@ public class Path extends ShapeElement {
if (shapeChange)
{
- path = buildPath(d, fillRule);
- return true;
+ build();
+// path = buildPath(d, fillRule);
+// return true;
}
- return changeState;
+ return changeState || shapeChange;
}
}
diff --git a/src/main/java/com/kitfox/svg/Polygon.java b/src/main/java/com/kitfox/svg/Polygon.java
index 56f2997..5be9795 100644
--- a/src/main/java/com/kitfox/svg/Polygon.java
+++ b/src/main/java/com/kitfox/svg/Polygon.java
@@ -168,10 +168,11 @@ public class Polygon extends ShapeElement {
if (shapeChange)
{
- buildPath();
- return true;
+ build();
+// buildPath();
+// return true;
}
- return changeState;
+ return changeState || shapeChange;
}
}
diff --git a/src/main/java/com/kitfox/svg/Polyline.java b/src/main/java/com/kitfox/svg/Polyline.java
index bf572f8..873657c 100644
--- a/src/main/java/com/kitfox/svg/Polyline.java
+++ b/src/main/java/com/kitfox/svg/Polyline.java
@@ -143,10 +143,11 @@ public class Polyline extends ShapeElement {
if (shapeChange)
{
- buildPath();
- return true;
+ build();
+// buildPath();
+// return true;
}
- return changeState;
+ return changeState || shapeChange;
}
}
diff --git a/src/main/java/com/kitfox/svg/Rect.java b/src/main/java/com/kitfox/svg/Rect.java
index 5104707..8fe56e3 100644
--- a/src/main/java/com/kitfox/svg/Rect.java
+++ b/src/main/java/com/kitfox/svg/Rect.java
@@ -251,17 +251,18 @@ public class Rect extends ShapeElement {
if (shapeChange)
{
- if (rx == 0f && ry == 0f)
- {
- rect = new Rectangle2D.Float(x, y, width, height);
- }
- else
- {
- rect = new RoundRectangle2D.Float(x, y, width, height, rx * 2, ry * 2);
- }
- return true;
+ build();
+// if (rx == 0f && ry == 0f)
+// {
+// rect = new Rectangle2D.Float(x, y, width, height);
+// }
+// else
+// {
+// rect = new RoundRectangle2D.Float(x, y, width, height, rx * 2, ry * 2);
+// }
+// return true;
}
- return changeState;
+ return changeState || shapeChange;
}
}
diff --git a/src/main/java/com/kitfox/svg/SVGElement.java b/src/main/java/com/kitfox/svg/SVGElement.java
index 7ff31e6..47ce1c3 100644
--- a/src/main/java/com/kitfox/svg/SVGElement.java
+++ b/src/main/java/com/kitfox/svg/SVGElement.java
@@ -102,7 +102,9 @@ abstract public class SVGElement implements Serializable
// protected SVGUniverse universe;
protected final TrackManager trackManager = new TrackManager();
-
+
+ boolean dirty = true;
+
// public static final Matcher adobeId = Pattern.compile("(.*)_1_").matcher("");
// static final String fpNumRe = "[-+]?((\\d+)|(\\d*\\.\\d+))([-+]?[eE]\\d+)?";
diff --git a/src/main/java/com/kitfox/svg/SVGRoot.java b/src/main/java/com/kitfox/svg/SVGRoot.java
index 7fea53a..daa211f 100644
--- a/src/main/java/com/kitfox/svg/SVGRoot.java
+++ b/src/main/java/com/kitfox/svg/SVGRoot.java
@@ -336,7 +336,7 @@ public class SVGRoot extends Group
if (getPres(sty.setName("x")))
{
NumberWithUnits newVal = sty.getNumberWithUnits();
- if (newVal != x)
+ if (!newVal.equals(x))
{
x = newVal;
shapeChange = true;
@@ -346,7 +346,7 @@ public class SVGRoot extends Group
if (getPres(sty.setName("y")))
{
NumberWithUnits newVal = sty.getNumberWithUnits();
- if (newVal != y)
+ if (!newVal.equals(y))
{
y = newVal;
shapeChange = true;
@@ -356,7 +356,7 @@ public class SVGRoot extends Group
if (getPres(sty.setName("width")))
{
NumberWithUnits newVal = sty.getNumberWithUnits();
- if (newVal != width)
+ if (!newVal.equals(width))
{
width = newVal;
shapeChange = true;
@@ -366,7 +366,7 @@ public class SVGRoot extends Group
if (getPres(sty.setName("height")))
{
NumberWithUnits newVal = sty.getNumberWithUnits();
- if (newVal != height)
+ if (!newVal.equals(height))
{
height = newVal;
shapeChange = true;
@@ -384,7 +384,12 @@ public class SVGRoot extends Group
}
}
- return changeState;
+ if (shapeChange)
+ {
+ build();
+ }
+
+ return changeState || shapeChange;
}
}
diff --git a/src/main/java/com/kitfox/svg/Text.java b/src/main/java/com/kitfox/svg/Text.java
index 1256419..e107d79 100644
--- a/src/main/java/com/kitfox/svg/Text.java
+++ b/src/main/java/com/kitfox/svg/Text.java
@@ -530,10 +530,11 @@ public class Text extends ShapeElement
if (shapeChange)
{
- buildFont();
- return true;
+ build();
+// buildFont();
+// return true;
}
- return changeState;
+ return changeState || shapeChange;
}
}
diff --git a/src/main/java/com/kitfox/svg/Use.java b/src/main/java/com/kitfox/svg/Use.java
index 00d05ff..3229482 100644
--- a/src/main/java/com/kitfox/svg/Use.java
+++ b/src/main/java/com/kitfox/svg/Use.java
@@ -28,12 +28,11 @@
package com.kitfox.svg;
import com.kitfox.svg.xml.StyleAttribute;
-import com.kitfox.svg.xml.*;
-import org.xml.sax.*;
-
-import java.net.*;
-import java.awt.*;
-import java.awt.geom.*;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.net.URI;
/**
* @author Mark McKay
@@ -244,12 +243,13 @@ public class Use extends ShapeElement {
*/
if (shapeChange)
{
+ build();
//Determine use offset/scale
- refXform.setToTranslation(this.x, this.y);
- refXform.scale(this.width, this.height);
- return true;
+// refXform.setToTranslation(this.x, this.y);
+// refXform.scale(this.width, this.height);
+// return true;
}
- return changeState;
+ return changeState || shapeChange;
}
}
diff --git a/src/main/java/com/kitfox/svg/xml/NumberWithUnits.java b/src/main/java/com/kitfox/svg/xml/NumberWithUnits.java
index 77bb895..d319fb2 100644
--- a/src/main/java/com/kitfox/svg/xml/NumberWithUnits.java
+++ b/src/main/java/com/kitfox/svg/xml/NumberWithUnits.java
@@ -86,4 +86,63 @@ public class NumberWithUnits implements Serializable
if (value.indexOf("%") != -1) { unitType = UT_PERCENT; return; }
}
+ public static String unitsAsString(int unitIdx)
+ {
+ switch (unitIdx)
+ {
+ default:
+ return "";
+ case UT_PX:
+ return "px";
+ case UT_CM:
+ return "cm";
+ case UT_MM:
+ return "mm";
+ case UT_IN:
+ return "in";
+ case UT_EM:
+ return "em";
+ case UT_EX:
+ return "ex";
+ case UT_PT:
+ return "pt";
+ case UT_PC:
+ return "pc";
+ case UT_PERCENT:
+ return "%";
+ }
+ }
+
+ public String toString()
+ {
+ return "" + value + unitsAsString(unitType);
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final NumberWithUnits other = (NumberWithUnits) obj;
+ if (Float.floatToIntBits(this.value) != Float.floatToIntBits(other.value)) {
+ return false;
+ }
+ if (this.unitType != other.unitType) {
+ return false;
+ }
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int hash = 5;
+ hash = 37 * hash + Float.floatToIntBits(this.value);
+ hash = 37 * hash + this.unitType;
+ return hash;
+ }
+
+
}