From 71d652c248ea25c91281e127ddde85c6ff7e7683 Mon Sep 17 00:00:00 2001 From: kitfox Date: Thu, 23 Apr 2009 21:44:56 +0000 Subject: Added rebuild() to AnimateElement that will allow the user to change the xml values of animation elements. git-svn-id: https://svn.java.net/svn/svgsalamander~svn/trunk/svg-core@64 7dc7fa77-23fb-e6ad-8e2e-c86bd48ed22b --- .../com/kitfox/svg/animation/AnimationElement.java | 86 +++++++++++++++++++++- 1 file changed, 82 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/kitfox/svg/animation/AnimationElement.java') diff --git a/src/main/java/com/kitfox/svg/animation/AnimationElement.java b/src/main/java/com/kitfox/svg/animation/AnimationElement.java index e1c7cd9..7387bca 100644 --- a/src/main/java/com/kitfox/svg/animation/AnimationElement.java +++ b/src/main/java/com/kitfox/svg/animation/AnimationElement.java @@ -26,10 +26,16 @@ package com.kitfox.svg.animation; -import java.io.*; -import org.xml.sax.*; +import com.kitfox.svg.SVGElement; +import com.kitfox.svg.SVGException; +import com.kitfox.svg.SVGLoaderHelper; +import com.kitfox.svg.animation.parser.AnimTimeParser; +import com.kitfox.svg.animation.parser.ParseException; +import com.kitfox.svg.xml.StyleAttribute; +import java.io.StringReader; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; -import com.kitfox.svg.*; /** * @author Mark McKay @@ -333,4 +339,76 @@ public abstract class AnimationElement extends SVGElement { //Animation elements to not change with time return false; - }} + } + + public void rebuild() throws SVGException + { + AnimTimeParser animTimeParser = new AnimTimeParser(new StringReader("")); + + rebuild(animTimeParser); + } + + protected void rebuild(AnimTimeParser animTimeParser) throws SVGException + { + StyleAttribute sty = new StyleAttribute(); + + if (getPres(sty.setName("begin"))) + { + String newVal = sty.getStringValue(); + animTimeParser.ReInit(new StringReader(newVal)); + try { + this.beginTime = animTimeParser.Expr(); + } catch (ParseException ex) { + ex.printStackTrace(); + } + } + + if (getPres(sty.setName("dur"))) + { + String newVal = sty.getStringValue(); + animTimeParser.ReInit(new StringReader(newVal)); + try { + this.durTime = animTimeParser.Expr(); + } catch (ParseException ex) { + ex.printStackTrace(); + } + } + + if (getPres(sty.setName("end"))) + { + String newVal = sty.getStringValue(); + animTimeParser.ReInit(new StringReader(newVal)); + try { + this.endTime = animTimeParser.Expr(); + } catch (ParseException ex) { + ex.printStackTrace(); + } + } + + if (getPres(sty.setName("fill"))) + { + String newVal = sty.getStringValue(); + if (newVal.equals("remove")) this.fillType = FT_REMOVE; + if (newVal.equals("freeze")) this.fillType = FT_FREEZE; + if (newVal.equals("hold")) this.fillType = FT_HOLD; + if (newVal.equals("transiton")) this.fillType = FT_TRANSITION; + if (newVal.equals("auto")) this.fillType = FT_AUTO; + if (newVal.equals("default")) this.fillType = FT_DEFAULT; + } + + if (getPres(sty.setName("additive"))) + { + String newVal = sty.getStringValue(); + if (newVal.equals("replace")) this.additiveType = AD_REPLACE; + if (newVal.equals("sum")) this.additiveType = AD_SUM; + } + + if (getPres(sty.setName("accumulate"))) + { + String newVal = sty.getStringValue(); + if (newVal.equals("replace")) this.accumulateType = AC_REPLACE; + if (newVal.equals("sum")) this.accumulateType = AC_SUM; + } + + } +} -- cgit v1.2.3-55-g7522