diff options
author | kitfox | 2014-02-06 09:52:58 +0100 |
---|---|---|
committer | kitfox | 2014-02-06 09:52:58 +0100 |
commit | ddd29c1524f3f77691be48f9778de7cabc26f52d (patch) | |
tree | 427d18c868a26a075bc3f1a0377b27129a473b9f | |
parent | Fixing radial gradients where center and focal point are coincident. (diff) | |
download | svg-salamander-core-ddd29c1524f3f77691be48f9778de7cabc26f52d.tar.gz svg-salamander-core-ddd29c1524f3f77691be48f9778de7cabc26f52d.tar.xz svg-salamander-core-ddd29c1524f3f77691be48f9778de7cabc26f52d.zip |
Fixing SVGSALAMANDER-30. Animation elements with a 'to' but not a 'from' will now get their from value from their parent element.
git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@164 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b
-rw-r--r-- | src/main/java/com/kitfox/svg/SVGElement.java | 30 | ||||
-rw-r--r-- | src/main/java/com/kitfox/svg/SVGUniverse.java | 2 | ||||
-rw-r--r-- | src/main/java/com/kitfox/svg/animation/Animate.java | 18 |
3 files changed, 39 insertions, 11 deletions
diff --git a/src/main/java/com/kitfox/svg/SVGElement.java b/src/main/java/com/kitfox/svg/SVGElement.java index 269a717..62c7ef3 100644 --- a/src/main/java/com/kitfox/svg/SVGElement.java +++ b/src/main/java/com/kitfox/svg/SVGElement.java @@ -579,6 +579,11 @@ abstract public class SVGElement implements Serializable styAttr.setStringValue(value);
}
+ public boolean getStyle(StyleAttribute attrib, boolean recursive) throws SVGException
+ {
+ return getStyle(attrib, recursive, true);
+ }
+
/**
* Copies the current style into the passed style attribute. Checks for
* inline styles first, then internal and extranal style sheets, and finally
@@ -590,7 +595,8 @@ abstract public class SVGElement implements Serializable * style attribute, checks attributes of parents back to root until one
* found.
*/
- public boolean getStyle(StyleAttribute attrib, boolean recursive) throws SVGException
+ public boolean getStyle(StyleAttribute attrib, boolean recursive, boolean evalAnimation)
+ throws SVGException
{
String styName = attrib.getName();
@@ -600,11 +606,14 @@ abstract public class SVGElement implements Serializable attrib.setStringValue(styAttr == null ? "" : styAttr.getStringValue());
//Evalutate coresponding track, if one exists
- TrackBase track = trackManager.getTrack(styName, AnimationElement.AT_CSS);
- if (track != null)
+ if (evalAnimation)
{
- track.getValue(attrib, diagram.getUniverse().getCurTime());
- return true;
+ TrackBase track = trackManager.getTrack(styName, AnimationElement.AT_CSS);
+ if (track != null)
+ {
+ track.getValue(attrib, diagram.getUniverse().getCurTime());
+ return true;
+ }
}
//Return if we've found a non animated style
@@ -620,11 +629,14 @@ abstract public class SVGElement implements Serializable attrib.setStringValue(presAttr == null ? "" : presAttr.getStringValue());
//Evalutate coresponding track, if one exists
- track = trackManager.getTrack(styName, AnimationElement.AT_XML);
- if (track != null)
+ if (evalAnimation)
{
- track.getValue(attrib, diagram.getUniverse().getCurTime());
- return true;
+ TrackBase track = trackManager.getTrack(styName, AnimationElement.AT_XML);
+ if (track != null)
+ {
+ track.getValue(attrib, diagram.getUniverse().getCurTime());
+ return true;
+ }
}
//Return if we've found a presentation attribute instead
diff --git a/src/main/java/com/kitfox/svg/SVGUniverse.java b/src/main/java/com/kitfox/svg/SVGUniverse.java index a8e5f76..b6859b9 100644 --- a/src/main/java/com/kitfox/svg/SVGUniverse.java +++ b/src/main/java/com/kitfox/svg/SVGUniverse.java @@ -54,8 +54,6 @@ import java.net.MalformedURLException; import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLStreamHandler;
import java.util.HashMap;
import java.util.Iterator;
import java.util.logging.Level;
diff --git a/src/main/java/com/kitfox/svg/animation/Animate.java b/src/main/java/com/kitfox/svg/animation/Animate.java index 3ef5287..0ac491e 100644 --- a/src/main/java/com/kitfox/svg/animation/Animate.java +++ b/src/main/java/com/kitfox/svg/animation/Animate.java @@ -36,6 +36,7 @@ package com.kitfox.svg.animation;
+import com.kitfox.svg.SVGConst;
import com.kitfox.svg.SVGElement;
import com.kitfox.svg.SVGException;
import com.kitfox.svg.SVGLoaderHelper;
@@ -47,6 +48,8 @@ import java.awt.Color; import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.geom.PathIterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@@ -197,6 +200,21 @@ public class Animate extends AnimateBase implements AnimateColorIface {
return byValue * interp;
}
+ else if (toExists)
+ {
+ StyleAttribute style = new StyleAttribute(getAttribName());
+ try
+ {
+ getParent().getStyle(style, true, false);
+ }
+ catch (SVGException ex)
+ {
+ Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
+ "Could not get from value", ex);
+ }
+ double from = style.getDoubleValue();
+ return toValue * interp + from * (1.0 - interp);
+ }
//Should not reach this line
throw new RuntimeException("Animate tag could not be evalutated - insufficient arguements");
|