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/15 08:20:47 UTC
svn commit: r385986 [1/2] - in
/xmlgraphics/batik/branches/anim/sources/org/apache/batik: anim/
anim/timing/ anim/values/ bridge/ css/engine/value/ css/engine/value/svg/
dom/ dom/events/ dom/svg/ parser/ transcoder/wmf/tosvg/ util/
Author: cam
Date: Tue Mar 14 23:20:42 2006
New Revision: 385986
URL: http://svn.apache.org/viewcvs?rev=385986&view=rev
Log:
1. Interpolation now occurs without unnecessarily creating new objects.
2. Tiny amount of animation supported: 'set' and 'animation' elements
honouring only timing attributes and from/to/additive, and only animating
CSS length or paint properties.
3. Changes to RunnableQueue to allow a default Runnable to run when no other
Runnables are queued up (used for animation ticking).
4. DOM time events.
Added:
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AbstractAnimation.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimatableElement.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationEngine.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationTarget.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationTargetListener.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/ColorAnimation.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/MotionAnimation.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/SetAnimation.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/SimpleAnimation.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/TransformAnimation.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthOrIdentValue.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimatableGenericSVGBridge.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimatableSVGBridge.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/AnimationSupport.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimateElementBridge.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimationElementBridge.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGAnimationEngine.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGSetElementBridge.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/events/DOMTimeEvent.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/ExtendedTraitAccess.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/IdContainer.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/TraitAccess.java (with props)
xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGTypes.java (with props)
Modified:
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/MediaMarkerTimingSpecifier.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/SyncbaseTimingSpecifier.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedDocumentRoot.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedElement.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimingSpecifier.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableColorValue.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableIntegerValue.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthListValue.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthValue.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableNumberListValue.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableNumberValue.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePaintValue.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePercentageValue.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePointListValue.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableValue.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/RepaintManager.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/bridge/SVGBridgeExtension.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/LengthManager.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/StrokeWidthManager.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/css/engine/value/svg/TextRenderingManager.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/GenericElementNS.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/SVGDOMImplementation.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/dom/svg/SVGOMAnimationElement.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingParser.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierListParser.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/parser/TimingSpecifierParser.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/transcoder/wmf/tosvg/WMFPainter.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/RunnableQueue.java
xmlgraphics/batik/branches/anim/sources/org/apache/batik/util/SVGConstants.java
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AbstractAnimation.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AbstractAnimation.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AbstractAnimation.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AbstractAnimation.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,173 @@
+/*
+
+ Copyright 2006 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.batik.anim;
+
+import org.apache.batik.anim.timing.TimedElement;
+import org.apache.batik.anim.values.AnimatableValue;
+
+/**
+ * An abstract base class for the different types of animation.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public abstract class AbstractAnimation {
+
+ // Constants for calcMode.
+ public final static int CALC_MODE_DISCRETE = 0;
+ public final static int CALC_MODE_LINEAR = 1;
+ public final static int CALC_MODE_PACED = 2;
+ public final static int CALC_MODE_SPLINE = 3;
+
+ /**
+ * The TimedElement that controls the timing of this animation.
+ */
+ protected TimedElement timedElement;
+
+ /**
+ * The AnimatableElement that gives access to underlying values in the
+ * document.
+ */
+ protected AnimatableElement animatableElement;
+
+ /**
+ * The animation that is lower in the sandwich.
+ */
+ protected AbstractAnimation lowerAnimation;
+
+ /**
+ * The animation that is higher in the sandwich.
+ */
+ protected AbstractAnimation higherAnimation;
+
+ /**
+ * Whether this animation needs recomputing.
+ */
+ protected boolean isDirty;
+
+ /**
+ * Whether this animation is active.
+ */
+ protected boolean isActive;
+
+ /**
+ * Whether this animation is frozen.
+ */
+ protected boolean isFrozen;
+
+ /**
+ * The value of this animation.
+ */
+ protected AnimatableValue value;
+
+ /**
+ * The value of this animation composed with any others.
+ */
+ protected AnimatableValue composedValue;
+
+ /**
+ * Creates a new Animation.
+ */
+ protected AbstractAnimation(TimedElement timedElement,
+ AnimatableElement animatableElement) {
+ this.timedElement = timedElement;
+ this.animatableElement = animatableElement;
+ }
+
+ /**
+ * Returns the TimedElement for this animation.
+ */
+ public TimedElement getTimedElement() {
+ return timedElement;
+ }
+
+ /**
+ * Returns the value of this animation, or null if it isn't active.
+ */
+ public AnimatableValue getValue() {
+ if (!isActive && !isFrozen) {
+ return null;
+ }
+ return value;
+ }
+
+ /**
+ * Returns the composed value of this animation, or null if it isn't active.
+ */
+ public AnimatableValue getComposedValue() {
+ if (!isActive && !isFrozen) {
+ return null;
+ }
+ if (isDirty) {
+ if (!willReplace()) {
+ AnimatableValue lowerValue;
+ if (lowerAnimation == null) {
+ lowerValue = animatableElement.getUnderlyingValue();
+ } else {
+ lowerValue = lowerAnimation.getComposedValue();
+ }
+ if (lowerValue != null) {
+ composedValue =
+ lowerValue.interpolate(composedValue, null, 0f, value);
+ } else {
+ composedValue =
+ value.interpolate(composedValue, null, 0f, null);
+ }
+ } else {
+ composedValue =
+ value.interpolate(composedValue, null, 0f, null);
+ }
+ isDirty = false;
+ }
+ return composedValue;
+ }
+
+ /**
+ * Returns whether this animation will replace values on animations
+ * lower in the sandwich.
+ */
+ protected boolean willReplace() {
+ return true;
+ }
+
+ /**
+ * Marks this animation and any animation that depends on it
+ * as dirty.
+ */
+ protected void markDirty() {
+ isDirty = true;
+ if (higherAnimation != null
+ && !higherAnimation.willReplace()
+ && !higherAnimation.isDirty) {
+ higherAnimation.markDirty();
+ }
+ }
+
+ /**
+ * Called when the element is sampled for its "last" value.
+ */
+ protected void sampledLastValue(int repeatIteration) {
+ }
+
+ /**
+ * Called when the element is sampled at the given time. This updates
+ * the {@link #value} of the animation if active.
+ */
+ protected abstract void sampledAt(float simpleTime, float simpleDur,
+ int repeatIteration);
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AbstractAnimation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimatableElement.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimatableElement.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimatableElement.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimatableElement.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,19 @@
+package org.apache.batik.anim;
+
+import org.apache.batik.anim.values.AnimatableValue;
+
+/**
+ * An interface for animatable elements to expose their underlying values
+ * to the compositing functions in {@link AbstractAnimation}.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public interface AnimatableElement {
+
+ /**
+ * Returns the underlying value of the animated attribute. Used for
+ * composition of additive animations.
+ */
+ AnimatableValue getUnderlyingValue();
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimatableElement.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationEngine.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationEngine.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationEngine.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationEngine.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,396 @@
+/*
+
+ Copyright 2006 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.batik.anim;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.batik.anim.timing.TimedDocumentRoot;
+import org.apache.batik.anim.values.AnimatableValue;
+import org.apache.batik.dom.util.DoublyIndexedTable;
+
+import org.w3c.dom.Document;
+
+/**
+ * A abstract base class for managing animation in a document.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id$
+ */
+public abstract class AnimationEngine {
+
+ /**
+ * The document this AnimationEngine is managing animation for.
+ */
+ protected Document document;
+
+ /**
+ * The root time container for the document.
+ */
+ protected TimedDocumentRoot timedDocumentRoot;
+
+ /**
+ * Map of AnimationTargets to TargetInfo objects.
+ */
+ protected HashMap targets = new HashMap();
+
+ /**
+ * Map of AbstractAnimations to AnimationInfo objects.
+ */
+ protected HashMap animations = new HashMap();
+
+ /**
+ * Creates a new AnimationEngine for the given document.
+ */
+ public AnimationEngine(Document doc) {
+ this.document = doc;
+ timedDocumentRoot = createDocumentRoot();
+ }
+
+ /**
+ * Adds an animation to the document.
+ */
+ public void addCSSAnimation(AnimationTarget target, String pn,
+ AbstractAnimation anim) {
+ timedDocumentRoot.addChild(anim.getTimedElement());
+
+ AnimationInfo animInfo = getInfo(anim);
+ animInfo.isCSS = true;
+ animInfo.attributeNamespaceURI = null;
+ animInfo.attributeLocalName = pn;
+ animInfo.target = target;
+ animations.put(anim, animInfo);
+
+ getSandwich(target, pn);
+ TargetInfo targetInfo = getInfo(target);
+ Sandwich sandwich = (Sandwich) targetInfo.cssAnimations.get(pn);
+ if (sandwich.animation == null) {
+ anim.lowerAnimation = null;
+ anim.higherAnimation = null;
+ } else {
+ sandwich.animation.higherAnimation = anim;
+ anim.lowerAnimation = sandwich.animation;
+ anim.higherAnimation = null;
+ }
+ sandwich.animation = anim;
+ }
+
+ /**
+ * Returns the Sandwich for the given CSS property and animation target.
+ */
+ protected Sandwich getSandwich(AnimationTarget target, String pn) {
+ TargetInfo info = getInfo(target);
+ Sandwich sandwich = (Sandwich) info.cssAnimations.get(pn);
+ if (sandwich == null) {
+ sandwich = new Sandwich();
+ info.cssAnimations.put(pn, sandwich);
+ }
+ return sandwich;
+ }
+
+ /**
+ * Returns the Sandwich for the given XML attribute and animation target.
+ */
+ protected Sandwich getSandwich(AnimationTarget target, String ns, String ln) {
+ TargetInfo info = getInfo(target);
+ Sandwich sandwich = (Sandwich) info.xmlAnimations.get(ns, ln);
+ if (sandwich == null) {
+ sandwich = new Sandwich();
+ info.xmlAnimations.put(ns, ln, sandwich);
+ }
+ return sandwich;
+ }
+
+ /**
+ * Returns the TargetInfo for the given AnimationTarget.
+ */
+ protected TargetInfo getInfo(AnimationTarget target) {
+ TargetInfo info = (TargetInfo) targets.get(target);
+ if (info == null) {
+ info = new TargetInfo();
+ targets.put(target, info);
+ }
+ return info;
+ }
+
+ /**
+ * Returns the AnimationInfo for the given AbstractAnimation.
+ */
+ protected AnimationInfo getInfo(AbstractAnimation anim) {
+ AnimationInfo info = (AnimationInfo) animations.get(anim);
+ if (info == null) {
+ info = new AnimationInfo();
+ animations.put(anim, info);
+ }
+ return info;
+ }
+
+ /**
+ * Updates the animations in the document to the given document time.
+ */
+ protected void tick(float time) {
+ timedDocumentRoot.seekTo(time);
+ Iterator i = targets.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry e = (Map.Entry) i.next();
+ AnimationTarget target = (AnimationTarget) e.getKey();
+ TargetInfo info = (TargetInfo) e.getValue();
+ // XXX xml animations too
+ Iterator j = info.cssAnimations.entrySet().iterator();
+ while (j.hasNext()) {
+ Map.Entry e2 = (Map.Entry) j.next();
+ String propertyName = (String) e2.getKey();
+ Sandwich sandwich = (Sandwich) e2.getValue();
+ if (sandwich.shouldUpdate || sandwich.animation.isDirty) {
+ boolean hasAdditive = true; // XXX
+ if (hasAdditive) {
+ target.updatePropertyValue(propertyName, null);
+ }
+ AnimatableValue av = sandwich.animation.getComposedValue();
+ if (!(hasAdditive && av == null)) {
+ target.updatePropertyValue(propertyName, av);
+ }
+ sandwich.shouldUpdate = false;
+ sandwich.animation.isDirty = false;
+ }
+ }
+ }
+ }
+
+ /**
+ * Invoked to indicate an animation became active at the specified time.
+ *
+ * @param anim the animation
+ * @param begin the time the element became active, in document simple time
+ */
+ public void toActive(AbstractAnimation anim, float begin) {
+ // XXX move anim to the right position in the sandwich
+ // XXX also handle XML attributes
+ // XXX is this the right amount of dirty marking?
+ moveToTop(anim);
+ anim.isActive = true;
+ anim.isFrozen = false;
+ anim.markDirty();
+ }
+
+ /**
+ * Invoked to indicate that this timed element became inactive.
+ *
+ * @param anim the animation
+ * @param isFrozen whether the element is frozen or not
+ */
+ public void toInactive(AbstractAnimation anim, boolean isFrozen) {
+ // XXX move anim to the bottom of the sandwich if not frozen?
+ anim.isActive = false;
+ anim.isFrozen = isFrozen;
+ if (!isFrozen) {
+ anim.value = null;
+ }
+ anim.markDirty();
+ if (!isFrozen) {
+ moveToBottom(anim);
+ }
+ }
+
+ /**
+ * Invoked to indicate that this timed element has had its fill removed.
+ */
+ public void removeFill(AbstractAnimation anim) {
+ // XXX move anim to the bottom of the sandwich?
+ anim.isActive = false;
+ anim.isFrozen = false;
+ anim.value = null;
+ anim.markDirty();
+ moveToBottom(anim);
+ }
+
+ /**
+ * Moves the given animation to the top of the sandwich.
+ */
+ protected void moveToTop(AbstractAnimation anim) {
+ AnimationInfo animInfo = getInfo(anim);
+ Sandwich sandwich;
+ if (animInfo.isCSS) {
+ sandwich = getSandwich(animInfo.target, animInfo.attributeLocalName);
+ } else {
+ sandwich = getSandwich(animInfo.target,
+ animInfo.attributeNamespaceURI,
+ animInfo.attributeLocalName);
+ }
+ sandwich.shouldUpdate = true;
+ if (anim.higherAnimation == null) {
+ return;
+ }
+ if (anim.lowerAnimation != null) {
+ anim.lowerAnimation.higherAnimation = anim.higherAnimation;
+ }
+ anim.higherAnimation.lowerAnimation = anim.lowerAnimation;
+ if (sandwich.animation != null) {
+ sandwich.animation.higherAnimation = anim;
+ }
+ anim.lowerAnimation = sandwich.animation;
+ anim.higherAnimation = null;
+ sandwich.animation = anim;
+ }
+
+ /**
+ * Moves the given animation to the bottom of the sandwich.
+ */
+ protected void moveToBottom(AbstractAnimation anim) {
+ if (anim.lowerAnimation == null) {
+ return;
+ }
+ AnimationInfo animInfo = getInfo(anim);
+ Sandwich sandwich;
+ if (animInfo.isCSS) {
+ sandwich = getSandwich(animInfo.target,
+ animInfo.attributeLocalName);
+ } else {
+ sandwich = getSandwich(animInfo.target,
+ animInfo.attributeNamespaceURI,
+ animInfo.attributeLocalName);
+ }
+ AbstractAnimation nextLower = anim.lowerAnimation;
+ nextLower.markDirty();
+ anim.lowerAnimation.higherAnimation = anim.higherAnimation;
+ if (anim.higherAnimation != null) {
+ anim.higherAnimation.lowerAnimation = anim.lowerAnimation;
+ } else {
+ sandwich.animation = nextLower;
+ sandwich.shouldUpdate = true;
+ }
+ AbstractAnimation last = nextLower;
+ while (last.lowerAnimation != null) {
+ last = last.lowerAnimation;
+ }
+ last.lowerAnimation = anim;
+ anim.higherAnimation = last;
+ anim.lowerAnimation = null;
+ if (sandwich.animation.isDirty) {
+ sandwich.shouldUpdate = true;
+ }
+ }
+
+ /**
+ * Invoked to indicate that this timed element has been sampled at the given
+ * time.
+ *
+ * @param anim the animation
+ * @param simpleTime the sample time in local simple time
+ * @param simpleDur the simple duration of the element
+ * @param repeatIteration the repeat iteration during which the element was
+ * sampled
+ */
+ public void sampledAt(AbstractAnimation anim, float simpleTime,
+ float simpleDur, int repeatIteration) {
+ anim.sampledAt(simpleTime, simpleDur, repeatIteration);
+ }
+
+ /**
+ * Invoked to indicate that this timed element has been sampled at the end
+ * of its active time, at an integer multiple of the simple duration. This
+ * is the "last" value that will be used for filling, which cannot be
+ * sampled normally.
+ */
+ public void sampledLastValue(AbstractAnimation anim, int repeatIteration) {
+ anim.sampledLastValue(repeatIteration);
+ }
+
+ /**
+ * Adds an animation to the document.
+ */
+ public void addXMLAnimation(AnimationTarget target, String ns, String ln,
+ AbstractAnimation anim) {
+ // XXX
+ }
+
+ /**
+ * Parses an AnimatableValue.
+ */
+ public abstract AnimatableValue parseAnimatableValue
+ (AnimationTarget target, int type, String s);
+
+ /**
+ * Creates a new returns a new TimedDocumentRoot object for the document.
+ */
+ protected abstract TimedDocumentRoot createDocumentRoot();
+
+ /**
+ * Class to hold XML and CSS animations for a target element.
+ */
+ protected static class TargetInfo {
+
+ /**
+ * Map of XML attribute names to AbstractAnimation at the top of the
+ * sandwich.
+ */
+ public DoublyIndexedTable xmlAnimations = new DoublyIndexedTable();
+
+ /**
+ * Map of CSS attribute names to AbstractAnimation at the top of the
+ * sandwich.
+ */
+ public HashMap cssAnimations = new HashMap();
+ }
+
+ /**
+ * Class to hold an animation sandwich for a particular attribute.
+ */
+ protected static class Sandwich {
+
+ /**
+ * The top-most animation in the sandwich.
+ */
+ public AbstractAnimation animation;
+
+ /**
+ * Whether the animation needs to have its value copied into the
+ * document.
+ */
+ public boolean shouldUpdate;
+ }
+
+ /**
+ * Class to hold target information of an animation.
+ */
+ protected static class AnimationInfo {
+
+ /**
+ * The target of the animation.
+ */
+ public AnimationTarget target;
+
+ /**
+ * Whether the animation is for a CSS property or an XML attribute.
+ */
+ public boolean isCSS;
+
+ /**
+ * The namespace URI of the attribute to animate, if this is an XML
+ * attribute animation.
+ */
+ public String attributeNamespaceURI;
+
+ /**
+ * The local name of the attribute or the name of the CSS property to
+ * animate.
+ */
+ public String attributeLocalName;
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationEngine.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationTarget.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationTarget.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationTarget.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationTarget.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,65 @@
+package org.apache.batik.anim;
+
+import org.apache.batik.anim.values.AnimatableValue;
+
+import org.w3c.dom.Element;
+
+/**
+ * An interface for targets of animation to provide context information.
+ */
+public interface AnimationTarget {
+
+ // Constants for percentage interpretation.
+ static final int PERCENTAGE_FONT_SIZE = 0;
+ static final int PERCENTAGE_VIEWPORT_WIDTH = 1;
+ static final int PERCENTAGE_VIEWPORT_HEIGHT = 2;
+ static final int PERCENTAGE_VIEWPORT_SIZE = 3;
+
+ /**
+ * Returns the element.
+ */
+ Element getElement();
+
+ /**
+ * Updates a property value in this target.
+ */
+ void updatePropertyValue(String pn, AnimatableValue val);
+
+ /**
+ * Updates an attribute value in this target.
+ */
+ void updateAttributeValue(String ns, String ln, AnimatableValue val);
+
+ /**
+ * Gets how percentage values are interpreted by the given attribute
+ * or property.
+ */
+ int getPercentageInterpretation(String ns, String an, boolean isCSS);
+
+ /**
+ * Returns whether color interpolations should be done in linear RGB
+ * color space rather than sRGB.
+ */
+ boolean useLinearRGBColorInterpolation();
+
+ /**
+ * Converts a length from one unit to another. The {@code fromType}
+ * and {@code toType} parameters should be one of the constants defined
+ * in {@link org.w3c.dom.svg.SVGLength}.
+ */
+ float convertLength(int fromType, float value, int toType);
+
+ // Listeners
+
+ /**
+ * Adds a listener for changes to the given attribute value.
+ */
+ void addTargetListener(String attributeName, boolean isCSS,
+ AnimationTargetListener l);
+
+ /**
+ * Removes a listener for changes to the given attribute value.
+ */
+ void removeTargetListener(String attributeName, boolean isCSS,
+ AnimationTargetListener l);
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationTarget.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationTargetListener.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationTargetListener.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationTargetListener.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationTargetListener.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,5 @@
+package org.apache.batik.anim;
+
+public interface AnimationTargetListener {
+ // XXX font size, viewport, base value
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/AnimationTargetListener.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/ColorAnimation.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/ColorAnimation.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/ColorAnimation.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/ColorAnimation.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,28 @@
+package org.apache.batik.anim;
+
+import org.apache.batik.anim.timing.TimedElement;
+import org.apache.batik.anim.values.AnimatableValue;
+
+/**
+ * An animation class for 'animateColor' animations.
+ */
+public class ColorAnimation extends SimpleAnimation {
+
+ /**
+ * Creates a new ColorAnimation.
+ */
+ public ColorAnimation(TimedElement timedElement,
+ AnimatableElement animatableElement,
+ int calcMode,
+ float[] keyTimes,
+ float[] keySplines,
+ boolean additive,
+ boolean cumulative,
+ AnimatableValue[] values,
+ AnimatableValue from,
+ AnimatableValue to,
+ AnimatableValue by) {
+ super(timedElement, animatableElement, calcMode, keyTimes, keySplines,
+ additive, cumulative, values, from, to, by);
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/ColorAnimation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/MotionAnimation.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/MotionAnimation.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/MotionAnimation.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/MotionAnimation.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,61 @@
+package org.apache.batik.anim;
+
+import org.apache.batik.anim.timing.TimedElement;
+import org.apache.batik.anim.values.AnimatableValue;
+import org.apache.batik.ext.awt.geom.ExtendedGeneralPath;
+
+/**
+ * An animation class for 'animateMotion' animations.
+ */
+public class MotionAnimation extends SimpleAnimation {
+
+ /**
+ * The path that describes the motion.
+ */
+ protected ExtendedGeneralPath path;
+
+ /**
+ * The points defining the distance along the path that the
+ * keyTimes apply.
+ */
+ protected float[] keyPoints;
+
+ /**
+ * Whether automatic rotation should be performed.
+ */
+ protected boolean rotateAuto;
+
+ /**
+ * Whether the automatic rotation should be reversed.
+ */
+ protected boolean rotateAutoReverse;
+
+ /**
+ * The angle of rotation to use when automatic rotation is
+ * not being used.
+ */
+ protected float rotateAngle;
+
+ /**
+ * Creates a new MotionAnimation.
+ */
+ public MotionAnimation(TimedElement timedElement,
+ AnimatableElement animatableElement,
+ int calcMode,
+ float[] keyTimes,
+ float[] keySplines,
+ boolean additive,
+ boolean cumulative,
+ AnimatableValue[] values,
+ AnimatableValue from,
+ AnimatableValue to,
+ AnimatableValue by,
+ ExtendedGeneralPath path,
+ float[] keyPoints,
+ boolean rotateAuto,
+ boolean rotateAutoReverse,
+ float rotateAngle) {
+ super(timedElement, animatableElement, calcMode, keyTimes, keySplines,
+ additive, cumulative, values, from, to, by);
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/MotionAnimation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/SetAnimation.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/SetAnimation.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/SetAnimation.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/SetAnimation.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,40 @@
+package org.apache.batik.anim;
+
+import org.apache.batik.anim.values.AnimatableValue;
+import org.apache.batik.anim.timing.TimedElement;
+
+/**
+ * An animation class for 'set' animations.
+ */
+public class SetAnimation extends AbstractAnimation {
+
+ /**
+ * The set animation value.
+ */
+ protected AnimatableValue to;
+
+ /**
+ * Creates a new SetAnimation.
+ */
+ public SetAnimation(TimedElement timedElement,
+ AnimatableElement animatableElement,
+ AnimatableValue to) {
+ super(timedElement, animatableElement);
+ this.to = to;
+ }
+
+ protected void sampledAt(float simpleTime, float simpleDur,
+ int repeatIteration) {
+ if (value == null) {
+ value = to;
+ markDirty();
+ }
+ }
+
+ protected void sampledLastValue(int repeatIteration) {
+ if (value == null) {
+ value = to;
+ markDirty();
+ }
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/SetAnimation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/SimpleAnimation.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/SimpleAnimation.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/SimpleAnimation.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/SimpleAnimation.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,249 @@
+package org.apache.batik.anim;
+
+import java.awt.geom.Point2D;
+
+import org.apache.batik.anim.timing.TimedElement;
+import org.apache.batik.anim.values.AnimatableValue;
+import org.apache.batik.ext.awt.geom.Cubic;
+
+/**
+ * An animation class for 'animate' animations.
+ */
+public class SimpleAnimation extends AbstractAnimation {
+
+ /**
+ * The interpolation mode of this animator. This should take one
+ * of the CALC_MODE_* constants defined in {@link AbstractAnimation}.
+ */
+ protected int calcMode;
+
+ /**
+ * Values between which to interpolate.
+ */
+ protected AnimatableValue[] values;
+
+ /**
+ * Time values to control the pacing of the animation.
+ */
+ protected float[] keyTimes;
+
+ /**
+ * Bezier control points that control the pacing of the animation.
+ */
+ protected float[] keySplines;
+
+ /**
+ * Starting value of the animation.
+ */
+ protected AnimatableValue from;
+
+ /**
+ * Ending value of the animation.
+ */
+ protected AnimatableValue to;
+
+ /**
+ * Relative offset value for the animation.
+ */
+ protected AnimatableValue by;
+
+ /**
+ * Whether this animation adds to ones below it in the animation sandwich
+ * or replaces them.
+ */
+ protected boolean additive;
+
+ /**
+ * Whether this animation accumulates from previous iterations.
+ */
+ protected boolean cumulative;
+
+ /**
+ * Whether this is a 'to animation' (i.e., one specified by a "to"
+ * but not a "from" value).
+ */
+ protected boolean toAnimation;
+
+ /**
+ * Creates a new SimpleAnimation.
+ */
+ public SimpleAnimation(TimedElement timedElement,
+ AnimatableElement animatableElement,
+ int calcMode,
+ float[] keyTimes,
+ float[] keySplines,
+ boolean additive,
+ boolean cumulative,
+ AnimatableValue[] values,
+ AnimatableValue from,
+ AnimatableValue to,
+ AnimatableValue by) {
+ super(timedElement, animatableElement);
+
+ toAnimation = false;
+ if (values == null) {
+ if (from != null) {
+ values = new AnimatableValue[2];
+ values[0] = from;
+ if (to != null) {
+ values[1] = to;
+ } else if (by != null) {
+ values[1] = to.interpolate(null, null, 0f, by);
+ } else {
+ // XXX
+ throw new RuntimeException("None of 'values', 'to' or 'by' were specified");
+ }
+ } else {
+ if (to != null) {
+ values = new AnimatableValue[1];
+ values[0] = to;
+ toAnimation = true;
+ cumulative = false;
+ } else if (by != null) {
+ additive = true;
+ values = new AnimatableValue[2];
+ values[0] = by.getZeroValue();
+ values[1] = by;
+ } else {
+ // XXX
+ throw new RuntimeException("None of 'values', 'to' or 'by' were specified");
+ }
+ }
+ }
+
+ if (keyTimes != null) {
+ boolean invalidKeyTimes = false;
+ if ((calcMode == CALC_MODE_LINEAR || calcMode == CALC_MODE_SPLINE)
+ && (keyTimes.length < 2
+ || keyTimes[0] != 0
+ || keyTimes[keyTimes.length - 1] != 1)
+ || calcMode == CALC_MODE_DISCRETE
+ && (keyTimes.length == 0 || keyTimes[0] != 0)) {
+ invalidKeyTimes = true;
+ }
+ if (!invalidKeyTimes) {
+ for (int i = 1; i < keyTimes.length; i++) {
+ if (keyTimes[i] < 0 || keyTimes[1] > 1
+ || keyTimes[i] < keyTimes[i - 1]) {
+ invalidKeyTimes = true;
+ break;
+ }
+ }
+ }
+ if (invalidKeyTimes) {
+ // XXX
+ throw new RuntimeException("Invalid 'keyTimes' specified");
+ }
+ } else {
+ if (calcMode == CALC_MODE_LINEAR || calcMode == CALC_MODE_SPLINE) {
+ int count = values.length == 1 ? 2 : values.length;
+ keyTimes = new float[count];
+ for (int i = 0; i < count; i++) {
+ keyTimes[i] = i / (count - 1);
+ }
+ } else if (calcMode == CALC_MODE_DISCRETE) {
+ int count = values.length;
+ keyTimes = new float[count];
+ for (int i = 0; i < count; i++) {
+ keyTimes[i] = i / count;
+ }
+ }
+ }
+
+ if (calcMode == CALC_MODE_SPLINE
+ && (keySplines == null
+ || keySplines.length != (keyTimes.length - 1) * 4)) {
+ // XXX
+ throw new RuntimeException("Invalid 'keySplines' specified");
+ }
+
+ this.calcMode = calcMode;
+ this.keyTimes = keyTimes;
+ this.keySplines = keySplines;
+ this.additive = additive;
+ this.cumulative = cumulative;
+ this.values = values;
+ this.from = from;
+ this.to = to;
+ this.by = by;
+ }
+
+ /**
+ * Returns whether this animation will replace values on animations
+ * lower in the sandwich.
+ */
+ protected boolean willReplace() {
+ return !additive;
+ }
+
+ protected void sampledAt(float simpleTime, float simpleDur,
+ int repeatIteration) {
+ float unitTime;
+ if (simpleDur == TimedElement.INDEFINITE) {
+ unitTime = 0;
+ } else {
+ unitTime = simpleTime / simpleDur;
+ }
+
+ AnimatableValue value, accumulation, nextValue;
+ float interpolation = 0;
+ if (calcMode != CALC_MODE_PACED) {
+ int keyTimeIndex = 0;
+ while (keyTimeIndex < keyTimes.length - 1
+ && unitTime >= keyTimes[keyTimeIndex + 1]) {
+ keyTimeIndex++;
+ }
+ value = values[keyTimeIndex];
+ if (calcMode == CALC_MODE_LINEAR
+ || calcMode == CALC_MODE_SPLINE) {
+ nextValue = values[keyTimeIndex + 1];
+ if (calcMode == CALC_MODE_SPLINE) {
+ if (unitTime != 0) {
+ Cubic c = new Cubic(0, 0,
+ keySplines[keyTimeIndex * 4],
+ keySplines[keyTimeIndex * 4 + 1],
+ keySplines[keyTimeIndex * 4 + 2],
+ keySplines[keyTimeIndex * 4 + 3],
+ 1, 1);
+ float tolerance = 0.01f;
+ float min = 0;
+ float max = 1;
+ Point2D.Double p;
+ for (;;) {
+ float t = (min + max) / 2;
+ p = c.eval(t);
+ double x = p.getX();
+ if (Math.abs(x - unitTime) < tolerance) {
+ break;
+ }
+ if (x < t) {
+ max = t;
+ } else {
+ min = t;
+ }
+ }
+ unitTime = (float) p.getY();
+ }
+ }
+ interpolation = (unitTime - keyTimes[keyTimeIndex])
+ / (keyTimes[keyTimeIndex + 1] - keyTimes[keyTimeIndex]);
+ } else {
+ nextValue = null;
+ }
+ if (cumulative) {
+ accumulation = values[values.length - 1];
+ } else {
+ accumulation = null;
+ }
+ } else {
+ // XXX paced
+ value = null;
+ nextValue = null;
+ accumulation = null;
+ }
+
+ this.value = value.interpolate(this.value, nextValue, interpolation,
+ accumulation);
+ markDirty();
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/SimpleAnimation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/TransformAnimation.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/TransformAnimation.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/TransformAnimation.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/TransformAnimation.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,35 @@
+package org.apache.batik.anim;
+
+import org.apache.batik.anim.timing.TimedElement;
+import org.apache.batik.anim.values.AnimatableValue;
+
+/**
+ * An animation class for 'animateTransform' animations.
+ */
+public class TransformAnimation extends SimpleAnimation {
+
+ /**
+ * The transform type. This should take one of the constants defined
+ * in {@link org.w3c.dom.svg.SVGTransform}.
+ */
+ protected int type;
+
+ /**
+ * Creates a new TransformAnimation.
+ */
+ public TransformAnimation(TimedElement timedElement,
+ AnimatableElement animatableElement,
+ int calcMode,
+ float[] keyTimes,
+ float[] keySplines,
+ boolean additive,
+ boolean cumulative,
+ AnimatableValue[] values,
+ AnimatableValue from,
+ AnimatableValue to,
+ AnimatableValue by,
+ int type) {
+ super(timedElement, animatableElement, calcMode, keyTimes, keySplines,
+ additive, cumulative, values, from, to, by);
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/TransformAnimation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/MediaMarkerTimingSpecifier.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/MediaMarkerTimingSpecifier.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/MediaMarkerTimingSpecifier.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/MediaMarkerTimingSpecifier.java Tue Mar 14 23:20:42 2006
@@ -17,8 +17,6 @@
*/
package org.apache.batik.anim.timing;
-import java.util.Calendar;
-
/**
* A class to handle media marker SMIL timing specifiers. This class
* of timing specifier is currently unused.
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/SyncbaseTimingSpecifier.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/SyncbaseTimingSpecifier.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/SyncbaseTimingSpecifier.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/SyncbaseTimingSpecifier.java Tue Mar 14 23:20:42 2006
@@ -17,6 +17,7 @@
*/
package org.apache.batik.anim.timing;
+import java.lang.ref.WeakReference;
import java.util.HashMap;
/**
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedDocumentRoot.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedDocumentRoot.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedDocumentRoot.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedDocumentRoot.java Tue Mar 14 23:20:42 2006
@@ -19,9 +19,6 @@
import java.util.Calendar;
import java.util.HashSet;
-import java.util.Iterator;
-
-import org.w3c.dom.events.EventTarget;
/**
* An abstract base class for the root time container element
@@ -63,7 +60,7 @@
* Creates a new TimedDocumentRoot.
* @param useSVG11AccessKeys allows the use of accessKey() timing
* specifiers with a single character
- * @param useSVG12Accesskeys allows the use of accessKey() with a
+ * @param useSVG12AccessKeys allows the use of accessKey() with a
* DOM 3 key name
*/
public TimedDocumentRoot(boolean useSVG11AccessKeys,
@@ -95,6 +92,7 @@
* Samples the entire timegraph at the given time.
*/
public void seekTo(float time) {
+ // System.err.println("\nseekTo: " + time);
// No time containers in SVG, so we don't have to worry
// about a partial ordering of timed elements to sample.
TimedElement[] es = getChildren();
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedElement.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedElement.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedElement.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimedElement.java Tue Mar 14 23:20:42 2006
@@ -23,11 +23,10 @@
import java.util.LinkedList;
import java.util.Vector;
-import org.apache.batik.parser.ClockParser;
import org.apache.batik.parser.ClockHandler;
+import org.apache.batik.parser.ClockParser;
import org.apache.batik.parser.ParseException;
-import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
/**
@@ -75,7 +74,7 @@
protected TimingSpecifier[] endTimes;
/**
- * Duration of this element, if {@code {@link #durMedia} = false}.
+ * Duration of this element, if {@link #durMedia}{@code = false}.
* If unspecified, it will be {@link #UNRESOLVED}.
*/
protected float simpleDur;
@@ -496,6 +495,7 @@
* Calculates the local simple time.
*/
protected void sampleAt(float parentSimpleTime) {
+ // System.err.println("Timed element " + toString() + " sampling at " + parentSimpleTime);
float time = parentSimpleTime; // No time containers in SVG.
if (currentInterval != null) {
float begin = currentInterval.getBegin();
@@ -611,15 +611,20 @@
float d = getSimpleDur();
if (isActive) {
+ // System.err.println("element sampling at simple time " + (time - lastRepeatTime));
sampledAt(time - lastRepeatTime, d, currentRepeatIteration);
} else if (isFrozen) {
Interval previousInterval = (Interval) previousIntervals.getLast();
float end = previousInterval.getEnd();
if ((end - lastRepeatTime) % d == 0) {
sampledLastValue(currentRepeatIteration);
+ // System.err.println("element sampling last value");
} else {
sampledAt(end, d, currentRepeatIteration);
+ // System.err.println("element sampling at simple time " + end);
}
+ } else {
+ // System.err.println("element not sampling");
}
lastSampleTime = time;
@@ -727,6 +732,7 @@
* Resets this element.
*/
protected void reset(boolean clearCurrentBegin) {
+ // System.err.println("reset");
Iterator i = beginInstanceTimes.iterator();
while (i.hasNext()) {
InstanceTime it = (InstanceTime) i.next();
@@ -778,6 +784,9 @@
* Parses a new 'begin' attribute.
*/
public void parseBegin(String begin) throws ParseException {
+ if (begin.length() == 0) {
+ begin = "0";
+ }
beginTimes = TimingSpecifierListProducer.parseTimingSpecifierList
(TimedElement.this, true, begin,
root.useSVG11AccessKeys, root.useSVG12AccessKeys);
@@ -942,7 +951,7 @@
beginTimes[i].initialize();
}
for (int i = 0; i < endTimes.length; i++) {
- beginTimes[i].initialize();
+ endTimes[i].initialize();
}
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimingSpecifier.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimingSpecifier.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimingSpecifier.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/timing/TimingSpecifier.java Tue Mar 14 23:20:42 2006
@@ -17,15 +17,6 @@
*/
package org.apache.batik.anim.timing;
-import java.io.IOException;
-import java.util.Calendar;
-import java.util.TimeZone;
-import java.util.SimpleTimeZone;
-
-import org.apache.batik.parser.ParseException;
-
-import org.w3c.dom.events.EventTarget;
-
/**
* An abstract class for SMIL timing specifiers.
*
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableColorValue.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableColorValue.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableColorValue.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableColorValue.java Tue Mar 14 23:20:42 2006
@@ -1,15 +1,23 @@
package org.apache.batik.anim.values;
-import java.awt.Color;
-
import org.apache.batik.anim.AnimationTarget;
public class AnimatableColorValue extends AnimatableValue {
/**
- * The color.
+ * The red component.
+ */
+ protected float red;
+
+ /**
+ * The green component.
+ */
+ protected float green;
+
+ /**
+ * The blue component.
*/
- protected Color color;
+ protected float blue;
/**
* Creates a new AnimatableColorValue.
@@ -21,51 +29,63 @@
/**
* Creates a new AnimatableColorValue.
*/
- public AnimatableColorValue(AnimationTarget target, Color c) {
+ public AnimatableColorValue(AnimationTarget target, float r, float g,
+ float b) {
super(target);
- color = c;
+ red = r;
+ green = g;
+ blue = b;
}
/**
* Performs interpolation to the given value.
*/
- public AnimatableValue interpolate(AnimatableValue to,
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
float interpolation,
AnimatableValue accumulation) {
- if ((to == null || interpolation == 0) && accumulation == null) {
- return this;
- }
- float[] comp = this.getRGBColorComponents(null);
AnimatableColorValue toColor = (AnimatableColorValue) to;
AnimatableColorValue accColor = (AnimatableColorValue) accumulation;
+ float r = red;
+ float g = green;
+ float b = blue;
// XXX Only sRGB colours, and only sRGB interpolation.
if (to != null) {
- float[] comp2 = toColor.getRGBColorComponents(null);
- comp[0] += interpolation * (comp2[0] - comp[0]);
- comp[1] += interpolation * (comp2[1] - comp[1]);
- comp[2] += interpolation * (comp2[2] - comp[2]);
+ r += interpolation * (toColor.red - r);
+ g += interpolation * (toColor.green - g);
+ b += interpolation * (toColor.blue - b);
}
if (accumulation != null) {
- float[] comp2 = accColor.getRGBColorComponents(null);
- comp[0] += interpolation * (comp2[0] - comp[0]);
- comp[1] += interpolation * (comp2[1] - comp[1]);
- comp[2] += interpolation * (comp2[2] - comp[2]);
+ r += accColor.red;
+ g += accColor.green;
+ b += accColor.blue;
+ }
+
+ AnimatableColorValue res;
+ if (result == null) {
+ res = new AnimatableColorValue(target);
+ } else {
+ res = (AnimatableColorValue) result;
}
- return new AnimatableColorValue
- (target, new Color(comp[0], comp[1], comp[2]));
+ res.red = r;
+ res.green = g;
+ res.blue = b;
+ return res;
}
/**
- * Returns the sRGB color components of this color value.
+ * Returns a zero value of this AnimatableValue's type.
*/
- public float[] getRGBColorComponents(float[] comp) {
- return color.getRGBColorComponents(comp);
+ public AnimatableValue getZeroValue() {
+ return new AnimatableColorValue(target, 0f, 0f, 0f);
}
/**
- * Returns a zero value of this AnimatableValue's type.
+ * Returns the CSS text representation of the value.
*/
- public AnimatableValue getZeroValue() {
- return new AnimatableColorValue(target, Color.BLACK);
+ public String getCssText() {
+ return "rgb(" + Math.round(red * 255) + ","
+ + Math.round(green * 255) + ","
+ + Math.round(blue * 255) + ")";
}
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableIntegerValue.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableIntegerValue.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableIntegerValue.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableIntegerValue.java Tue Mar 14 23:20:42 2006
@@ -10,6 +10,13 @@
protected int value;
/**
+ * Creates a new, uninitialized AnimatableIntegerValue.
+ */
+ protected AnimatableIntegerValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
* Creates a new AnimatableIntegerValue.
*/
public AnimatableIntegerValue(AnimationTarget target, int v) {
@@ -20,7 +27,8 @@
/**
* Performs interpolation to the given value.
*/
- public AnimatableValue interpolate(AnimatableValue to,
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
float interpolation,
AnimatableValue accumulation) {
int v = value;
@@ -32,7 +40,15 @@
AnimatableIntegerValue accInteger = (AnimatableIntegerValue) accumulation;
v += accInteger.getValue();
}
- return new AnimatableIntegerValue(target, v);
+
+ AnimatableIntegerValue res;
+ if (result == null) {
+ res = new AnimatableIntegerValue(target);
+ } else {
+ res = (AnimatableIntegerValue) result;
+ }
+ res.value = v;
+ return res;
}
/**
@@ -47,5 +63,12 @@
*/
public AnimatableValue getZeroValue() {
return new AnimatableIntegerValue(target, 0);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ return Integer.toString(value);
}
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthListValue.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthListValue.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthListValue.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthListValue.java Tue Mar 14 23:20:42 2006
@@ -18,6 +18,13 @@
protected float[] lengthValues;
/**
+ * Creates a new, uninitialized AnimatableLengthListValue.
+ */
+ protected AnimatableLengthListValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
* Creates a new AnimatableLengthListValue.
*/
public AnimatableLengthListValue(AnimationTarget target, int types[],
@@ -30,9 +37,11 @@
/**
* Performs interpolation to the given value.
*/
- public AnimatableValue interpolate(AnimatableValue to,
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
float interpolation,
AnimatableValue accumulation) {
+ // XXX Can't return 'this'.
if ((to == null || interpolation == 0) && accumulation == null) {
return this;
}
@@ -70,7 +79,16 @@
}
}
}
- return new AnimatableLengthListValue(target, newTypes, newValues);
+
+ AnimatableLengthListValue res;
+ if (result == null) {
+ res = new AnimatableLengthListValue(target);
+ } else {
+ res = (AnimatableLengthListValue) result;
+ }
+ res.lengthTypes = newTypes;
+ res.lengthValues = newValues;
+ return res;
}
/**
@@ -93,5 +111,13 @@
public AnimatableValue getZeroValue() {
float[] vs = new float[lengthValues.length];
return new AnimatableLengthListValue(target, lengthTypes, vs);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ * Length lists can never be used for CSS properties.
+ */
+ public String getCssText() {
+ return null;
}
}
Added: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthOrIdentValue.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthOrIdentValue.java?rev=385986&view=auto
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthOrIdentValue.java (added)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthOrIdentValue.java Tue Mar 14 23:20:42 2006
@@ -0,0 +1,73 @@
+package org.apache.batik.anim.values;
+
+import org.apache.batik.anim.AnimationTarget;
+
+public class AnimatableLengthOrIdentValue extends AnimatableLengthValue {
+
+ /**
+ * Whether this value is an identifier.
+ */
+ protected boolean isIdent;
+
+ /**
+ * The identifier.
+ */
+ protected String ident;
+
+ /**
+ * Creates a new, uninitialized AnimatableLengthOrIdentValue.
+ */
+ protected AnimatableLengthOrIdentValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableLengthOrIdentValue for a length value.
+ */
+ public AnimatableLengthOrIdentValue(AnimationTarget target, int type,
+ float v) {
+ super(target, type, v);
+ }
+
+ /**
+ * Creates a new AnimatableLengthOrIdentValue for an identifier value.
+ */
+ public AnimatableLengthOrIdentValue(AnimationTarget target, String ident) {
+ super(target);
+ this.ident = ident;
+ this.isIdent = true;
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ if (isIdent) {
+ return ident;
+ }
+ return super.getCssText();
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to, float interpolation,
+ AnimatableValue accumulation) {
+ AnimatableLengthOrIdentValue res;
+ if (result == null) {
+ res = new AnimatableLengthOrIdentValue(target);
+ } else {
+ res = (AnimatableLengthOrIdentValue) result;
+ }
+
+ if (isIdent) {
+ res.ident = ident;
+ res.isIdent = true;
+ } else {
+ super.interpolate(res, to, interpolation, accumulation);
+ res.isIdent = false;
+ }
+ return res;
+ }
+}
Propchange: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthOrIdentValue.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthValue.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthValue.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthValue.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableLengthValue.java Tue Mar 14 23:20:42 2006
@@ -1,6 +1,7 @@
package org.apache.batik.anim.values;
import org.apache.batik.anim.AnimationTarget;
+import org.apache.batik.css.engine.value.FloatValue;
import org.w3c.dom.svg.SVGLength;
@@ -18,6 +19,13 @@
protected float lengthValue;
/**
+ * Creates a new AnimatableLengthValue with no length.
+ */
+ protected AnimatableLengthValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
* Creates a new AnimatableLengthValue.
*/
public AnimatableLengthValue(AnimationTarget target, int type, float v) {
@@ -29,16 +37,14 @@
/**
* Performs interpolation to the given value.
*/
- public AnimatableValue interpolate(AnimatableValue to,
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
float interpolation,
AnimatableValue accumulation) {
- if ((to == null || interpolation == 0) && accumulation == null) {
- return this;
- }
AnimatableLengthValue toLength = (AnimatableLengthValue) to;
AnimatableLengthValue accLength = (AnimatableLengthValue) accumulation;
- boolean convert = to != null && !compatibleTypes(toLength.getLengthType(), lengthType)
- || accumulation != null && !compatibleTypes(accLength.getLengthType(), lengthType);
+ boolean convert = to != null && !compatibleTypes(toLength.lengthType, lengthType)
+ || accumulation != null && !compatibleTypes(accLength.lengthType, lengthType);
int type = convert ? SVGLength.SVG_LENGTHTYPE_NUMBER : lengthType;
float value = convert ? toType(lengthType, lengthValue, type) : lengthValue;
if (to != null) {
@@ -53,7 +59,16 @@
: accLength.getLengthValue();
value += accValue;
}
- return new AnimatableLengthValue(target, type, value);
+
+ AnimatableLengthValue res;
+ if (result == null) {
+ res = new AnimatableLengthValue(target);
+ } else {
+ res = (AnimatableLengthValue) result;
+ }
+ res.lengthType = type;
+ res.lengthValue = value;
+ return res;
}
protected boolean compatibleTypes(int t1, int t2) {
@@ -83,5 +98,12 @@
public AnimatableValue getZeroValue() {
return new AnimatableLengthValue
(target, SVGLength.SVG_LENGTHTYPE_NUMBER, 0);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ return FloatValue.getCssText((short) (lengthType - 1), lengthValue);
}
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableNumberListValue.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableNumberListValue.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableNumberListValue.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableNumberListValue.java Tue Mar 14 23:20:42 2006
@@ -10,6 +10,13 @@
protected float[] numbers;
/**
+ * Creates a new, uninitialized AnimatableNumberListValue.
+ */
+ protected AnimatableNumberListValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
* Creates a new AnimatableNumberListValue.
*/
public AnimatableNumberListValue(AnimationTarget target, float[] numbers) {
@@ -20,36 +27,40 @@
/**
* Performs interpolation to the given value.
*/
- public AnimatableValue interpolate(AnimatableValue to,
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
float interpolation,
AnimatableValue accumulation) {
- if ((to == null || interpolation == 0) && accumulation == null) {
- return this;
+ AnimatableNumberListValue res;
+ if (result == null) {
+ res = new AnimatableNumberListValue(target);
+ res.numbers = new float[numbers.length];
+ } else {
+ res = (AnimatableNumberListValue) result;
+ if (res.numbers == null || res.numbers.length != numbers.length) {
+ res.numbers = new float[numbers.length];
+ }
}
+
AnimatableNumberListValue toNumList = (AnimatableNumberListValue) to;
AnimatableNumberListValue accNumList =
(AnimatableNumberListValue) accumulation;
- float[] newNums = new float[numbers.length];
- for (int i = 0; i < numbers.length; i++) {
- newNums[i] = numbers[i];
- }
+ System.arraycopy(numbers, 0, res.numbers, 0, numbers.length);
if (to != null) {
- float[] toNums = toNumList.getNumbers();
- if (toNums.length == numbers.length) {
- for (int i = 0; i < toNums.length; i++) {
- newNums[i] += interpolation * toNums[i];
+ if (toNumList.numbers.length == numbers.length) {
+ for (int i = 0; i < numbers.length; i++) {
+ res.numbers[i] += interpolation * toNumList.numbers[i];
}
}
}
if (accumulation != null) {
- float[] accNums = accNumList.getNumbers();
- if (accNums.length == numbers.length) {
- for (int i = 0; i < accNums.length; i++) {
- newNums[i] += accNums[i];
+ if (accNumList.numbers.length == numbers.length) {
+ for (int i = 0; i < numbers.length; i++) {
+ res.numbers[i] += accNumList.numbers[i];
}
}
}
- return new AnimatableNumberListValue(target, newNums);
+ return res;
}
/**
@@ -65,5 +76,18 @@
public AnimatableValue getZeroValue() {
float[] ns = new float[numbers.length];
return new AnimatableNumberListValue(target, ns);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(numbers[0]);
+ for (int i = 1; i < numbers.length; i++) {
+ sb.append(' ');
+ sb.append(numbers[i]);
+ }
+ return sb.toString();
}
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableNumberValue.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableNumberValue.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableNumberValue.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableNumberValue.java Tue Mar 14 23:20:42 2006
@@ -10,6 +10,13 @@
protected float value;
/**
+ * Creates a new, uninitialized AnimatableNumberValue.
+ */
+ protected AnimatableNumberValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
* Creates a new AnimatableNumberValue.
*/
public AnimatableNumberValue(AnimationTarget target, float v) {
@@ -20,19 +27,28 @@
/**
* Performs interpolation to the given value.
*/
- public AnimatableValue interpolate(AnimatableValue to,
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
float interpolation,
AnimatableValue accumulation) {
float v = value;
if (to != null) {
AnimatableNumberValue toNumber = (AnimatableNumberValue) to;
- v += value + interpolation * (toNumber.getValue() - value);
+ v += value + interpolation * (toNumber.value - value);
}
if (accumulation != null) {
AnimatableNumberValue accNumber = (AnimatableNumberValue) accumulation;
- v += accNumber.getValue();
+ v += accNumber.value;
+ }
+
+ AnimatableNumberValue res;
+ if (result == null) {
+ res = new AnimatableNumberValue(target);
+ } else {
+ res = (AnimatableNumberValue) result;
}
- return new AnimatableNumberValue(target, v);
+ res.value = v;
+ return res;
}
/**
@@ -47,5 +63,12 @@
*/
public AnimatableValue getZeroValue() {
return new AnimatableNumberValue(target, 0);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ return Float.toString(value);
}
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePaintValue.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePaintValue.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePaintValue.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePaintValue.java Tue Mar 14 23:20:42 2006
@@ -1,20 +1,18 @@
package org.apache.batik.anim.values;
-import java.awt.Color;
-
import org.apache.batik.anim.AnimationTarget;
public class AnimatablePaintValue extends AnimatableColorValue {
// Constants for paintType.
- public static int PAINT_NONE = 0;
- public static int PAINT_CURRENT_COLOR = 1;
- public static int PAINT_COLOR = 2;
- public static int PAINT_URI = 3;
- public static int PAINT_URI_NONE = 4;
- public static int PAINT_URI_CURRENT_COLOR = 5;
- public static int PAINT_URI_COLOR = 6;
- public static int PAINT_INHERIT = 7;
+ public static final int PAINT_NONE = 0;
+ public static final int PAINT_CURRENT_COLOR = 1;
+ public static final int PAINT_COLOR = 2;
+ public static final int PAINT_URI = 3;
+ public static final int PAINT_URI_NONE = 4;
+ public static final int PAINT_URI_CURRENT_COLOR = 5;
+ public static final int PAINT_URI_COLOR = 6;
+ public static final int PAINT_INHERIT = 7;
/**
* The type of paint.
@@ -27,7 +25,7 @@
protected String uri;
/**
- * Creates a new AnimatablePaintValue.
+ * Creates a new, uninitialized AnimatablePaintValue.
*/
protected AnimatablePaintValue(AnimationTarget target) {
super(target);
@@ -36,8 +34,9 @@
/**
* Creates a new AnimatablePaintValue.
*/
- protected AnimatablePaintValue(AnimationTarget target, Color c) {
- super(target, c);
+ protected AnimatablePaintValue(AnimationTarget target, float r, float g,
+ float b) {
+ super(target, r, g, b);
}
/**
@@ -64,8 +63,8 @@
* Creates a new AnimatablePaintValue for a color value.
*/
public static AnimatablePaintValue createColorPaintValue
- (AnimationTarget target, Color c) {
- AnimatablePaintValue v = new AnimatablePaintValue(target, c);
+ (AnimationTarget target, float r, float g, float b) {
+ AnimatablePaintValue v = new AnimatablePaintValue(target, r, g, b);
v.paintType = PAINT_COLOR;
return v;
}
@@ -110,8 +109,8 @@
* color fallback.
*/
public static AnimatablePaintValue createURIColorPaintValue
- (AnimationTarget target, String uri, Color c) {
- AnimatablePaintValue v = new AnimatablePaintValue(target, c);
+ (AnimationTarget target, String uri, float r, float g, float b) {
+ AnimatablePaintValue v = new AnimatablePaintValue(target, r, g, b);
v.uri = uri;
v.paintType = PAINT_URI_COLOR;
return v;
@@ -130,20 +129,30 @@
/**
* Performs interpolation to the given value.
*/
- public AnimatableValue interpolate(AnimatableValue to,
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
float interpolation,
AnimatableValue accumulation) {
+ AnimatablePaintValue res;
+ if (result == null) {
+ res = new AnimatablePaintValue(target);
+ } else {
+ res = (AnimatablePaintValue) result;
+ }
+
if (paintType == PAINT_COLOR) {
- if (to instanceof AnimatablePaintValue) {
- AnimatablePaintValue toPaint = (AnimatablePaintValue) to;
- if (toPaint.getPaintType() == PAINT_COLOR) {
- return super.interpolate(to, interpolation, accumulation);
- }
- } else if (to instanceof AnimatableColorValue) {
- return super.interpolate(to, interpolation, accumulation);
+ AnimatablePaintValue toPaint = (AnimatablePaintValue) to;
+ if (toPaint.paintType == PAINT_COLOR) {
+ res.paintType = PAINT_COLOR;
+ return super.interpolate(res, to, interpolation, accumulation);
}
}
- return this;
+ res.paintType = paintType;
+ res.uri = uri;
+ res.red = red;
+ res.green = green;
+ res.blue = blue;
+ return res;
}
/**
@@ -164,6 +173,30 @@
* Returns a zero value of this AnimatableValue's type.
*/
public AnimatableValue getZeroValue() {
- return AnimatablePaintValue.createColorPaintValue(target, Color.BLACK);
+ return AnimatablePaintValue.createColorPaintValue(target, 0f, 0f, 0f);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ switch (paintType) {
+ case PAINT_NONE:
+ return "none";
+ case PAINT_CURRENT_COLOR:
+ return "currentColor";
+ case PAINT_COLOR:
+ return super.getCssText();
+ case PAINT_URI:
+ return "url(" + uri + ")";
+ case PAINT_URI_NONE:
+ return "url(" + uri + ") none";
+ case PAINT_URI_CURRENT_COLOR:
+ return "url(" + uri + ") currentColor";
+ case PAINT_URI_COLOR:
+ return "url(" + uri + ") " + super.getCssText();
+ default: // PAINT_INHERIT
+ return "inherit";
+ }
}
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePercentageValue.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePercentageValue.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePercentageValue.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePercentageValue.java Tue Mar 14 23:20:42 2006
@@ -5,16 +5,43 @@
public class AnimatablePercentageValue extends AnimatableNumberValue {
/**
+ * Creates a new, uninitialized AnimatablePercentageValue.
+ */
+ protected AnimatablePercentageValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
* Creates a new AnimatablePercentageValue.
*/
public AnimatablePercentageValue(AnimationTarget target, float v) {
super(target, v);
}
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation) {
+ if (result == null) {
+ result = new AnimatablePercentageValue(target);
+ }
+ return super.interpolate(result, to, interpolation, accumulation);
+ }
/**
* Returns a zero value of this AnimatableValue's type.
*/
public AnimatableValue getZeroValue() {
return new AnimatablePercentageValue(target, 0);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ return super.getCssText() + "%";
}
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePointListValue.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePointListValue.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePointListValue.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatablePointListValue.java Tue Mar 14 23:20:42 2006
@@ -5,14 +5,29 @@
public class AnimatablePointListValue extends AnimatableNumberListValue {
/**
- * The numbers.
+ * Creates a new, uninitialized AnimatablePointListValue.
*/
- protected float[] numbers;
-
+ protected AnimatablePointListValue(AnimationTarget target) {
+ super(target);
+ }
+
/**
* Creates a new AnimatablePointListValue.
*/
public AnimatablePointListValue(AnimationTarget target, float[] numbers) {
super(target, numbers);
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation) {
+ if (result == null) {
+ result = new AnimatablePointListValue(target);
+ }
+ return super.interpolate(result, to, interpolation, accumulation);
}
}
Modified: xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableValue.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableValue.java?rev=385986&r1=385985&r2=385986&view=diff
==============================================================================
--- xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableValue.java (original)
+++ xmlgraphics/batik/branches/anim/sources/org/apache/batik/anim/values/AnimatableValue.java Tue Mar 14 23:20:42 2006
@@ -18,21 +18,33 @@
/**
* Performs interpolation to the given value.
+ * @param result the object in which to store the result of the
+ * interpolation, or null if a new object should be created
+ * @param to the value this value should be interpolated towards, or null
+ * if no actual interpolation should be performed
+ * @param interpolation the interpolation distance, 0 <= interpolation
+ * <= 1
+ * @param accumulation an accumulation to add to the interpolated value
*/
- public abstract AnimatableValue interpolate(AnimatableValue to,
+ public abstract AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
float interpolation,
AnimatableValue accumulation);
/**
- * Adds the given AnimatableValue to this one and returns the result.
+ * Returns a zero value of this AnimatableValue's type.
*/
- public /*abstract*/ AnimatableValue add(AnimatableValue v) {
- // XXX
- return null;
- }
+ public abstract AnimatableValue getZeroValue();
/**
- * Returns a zero value of this AnimatableValue's type.
+ * Returns the CSS text representation of the value.
*/
- public abstract AnimatableValue getZeroValue();
+ public abstract String getCssText();
+
+ /**
+ * Returns a string representation of this object.
+ */
+ public String toString() {
+ return getClass().getName() + "[" + getCssText() + "]";
+ }
}