You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2013/10/08 16:03:42 UTC
[27/62] [abbrv] [partial] Merged Apache Flex 4.9.0 release branch
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/timing/WallclockTimingSpecifier.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/timing/WallclockTimingSpecifier.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/timing/WallclockTimingSpecifier.java
new file mode 100644
index 0000000..be5853b
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/timing/WallclockTimingSpecifier.java
@@ -0,0 +1,74 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.timing;
+
+import java.util.Calendar;
+
+/**
+ * A class to handle wallclock SMIL timing specifiers.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: WallclockTimingSpecifier.java 580338 2007-09-28 13:13:46Z cam $
+ */
+public class WallclockTimingSpecifier extends TimingSpecifier {
+
+ /**
+ * The wallclock time.
+ */
+ protected Calendar time;
+
+ /**
+ * The instance time.
+ */
+ protected InstanceTime instance;
+
+ /**
+ * Creates a new WallclockTimingSpecifier object.
+ */
+ public WallclockTimingSpecifier(TimedElement owner, boolean isBegin,
+ Calendar time) {
+ super(owner, isBegin);
+ this.time = time;
+ }
+
+ /**
+ * Returns a string representation of this timing specifier.
+ */
+ public String toString() {
+ return "wallclock(" + time.toString() + ")";
+ }
+
+ /**
+ * Initializes this timing specifier by adding the initial instance time
+ * to the owner's instance time list or setting up any event listeners.
+ */
+ public void initialize() {
+ float t = owner.getRoot().convertWallclockTime(time);
+ instance = new InstanceTime(this, t, false);
+ owner.addInstanceTime(instance, isBegin);
+ }
+
+ /**
+ * Returns whether this timing specifier is event-like (i.e., if it is
+ * an eventbase, accesskey or a repeat timing specifier).
+ */
+ public boolean isEventCondition() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableAngleOrIdentValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableAngleOrIdentValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableAngleOrIdentValue.java
new file mode 100644
index 0000000..1b2f4e0
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableAngleOrIdentValue.java
@@ -0,0 +1,179 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+import org.w3c.dom.svg.SVGAngle;
+
+/**
+ * An SVG angle-or-identifier value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableAngleOrIdentValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AnimatableAngleOrIdentValue extends AnimatableAngleValue {
+
+ /**
+ * Whether this value is an identifier.
+ */
+ protected boolean isIdent;
+
+ /**
+ * The identifier.
+ */
+ protected String ident;
+
+ /**
+ * Creates a new, uninitialized AnimatableAngleOrIdentValue.
+ */
+ protected AnimatableAngleOrIdentValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableAngleOrIdentValue for an angle value.
+ */
+ public AnimatableAngleOrIdentValue(AnimationTarget target, float v, short unit) {
+ super(target, v, unit);
+ }
+
+ /**
+ * Creates a new AnimatableAngleOrIdentValue for an identifier value.
+ */
+ public AnimatableAngleOrIdentValue(AnimationTarget target, String ident) {
+ super(target);
+ this.ident = ident;
+ this.isIdent = true;
+ }
+
+ /**
+ * Returns whether the value is an identifier.
+ */
+ public boolean isIdent() {
+ return isIdent;
+ }
+
+ /**
+ * Returns the identifiers.
+ */
+ public String getIdent() {
+ return ident;
+ }
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public boolean canPace() {
+ return false;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ return 0f;
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public AnimatableValue getZeroValue() {
+ return new AnimatableAngleOrIdentValue
+ (target, 0, SVGAngle.SVG_ANGLETYPE_UNSPECIFIED);
+ }
+
+ /**
+ * 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,
+ int multiplier) {
+ AnimatableAngleOrIdentValue res;
+ if (result == null) {
+ res = new AnimatableAngleOrIdentValue(target);
+ } else {
+ res = (AnimatableAngleOrIdentValue) result;
+ }
+
+ if (to == null) {
+ if (isIdent) {
+ res.hasChanged = !res.isIdent || !res.ident.equals(ident);
+ res.ident = ident;
+ res.isIdent = true;
+ } else {
+ short oldUnit = res.unit;
+ float oldValue = res.value;
+ super.interpolate(res, to, interpolation, accumulation,
+ multiplier);
+ if (res.unit != oldUnit || res.value != oldValue) {
+ res.hasChanged = true;
+ }
+ }
+ } else {
+ AnimatableAngleOrIdentValue toValue
+ = (AnimatableAngleOrIdentValue) to;
+ if (isIdent || toValue.isIdent) {
+ if (interpolation >= 0.5) {
+ if (res.isIdent != toValue.isIdent
+ || res.unit != toValue.unit
+ || res.value != toValue.value
+ || res.isIdent && toValue.isIdent
+ && !toValue.ident.equals(ident)) {
+ res.isIdent = toValue.isIdent;
+ res.ident = toValue.ident;
+ res.unit = toValue.unit;
+ res.value = toValue.value;
+ res.hasChanged = true;
+ }
+ } else {
+ if (res.isIdent != isIdent
+ || res.unit != unit
+ || res.value != value
+ || res.isIdent && isIdent
+ && !res.ident.equals(ident)) {
+ res.isIdent = isIdent;
+ res.ident = ident;
+ res.unit = unit;
+ res.value = value;
+ res.hasChanged = true;
+ }
+ }
+ } else {
+ super.interpolate(res, to, interpolation, accumulation,
+ multiplier);
+ }
+ }
+
+ return res;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableAngleValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableAngleValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableAngleValue.java
new file mode 100644
index 0000000..f81d031
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableAngleValue.java
@@ -0,0 +1,149 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+import org.w3c.dom.svg.SVGAngle;
+
+/**
+ * An SVG angle value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableAngleValue.java 532986 2007-04-27 06:30:58Z cam $
+ */
+public class AnimatableAngleValue extends AnimatableNumberValue {
+
+ /**
+ * The unit string representations.
+ */
+ protected static final String[] UNITS = {
+ "", "", "deg", "rad", "grad"
+ };
+
+ /**
+ * The angle unit.
+ */
+ protected short unit;
+
+ /**
+ * Creates a new, uninitialized AnimatableAngleValue.
+ */
+ public AnimatableAngleValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableAngleValue.
+ */
+ public AnimatableAngleValue(AnimationTarget target, float v, short unit) {
+ super(target, v);
+ this.unit = unit;
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableAngleValue res;
+ if (result == null) {
+ res = new AnimatableAngleValue(target);
+ } else {
+ res = (AnimatableAngleValue) result;
+ }
+
+ float v = value;
+ short u = unit;
+ if (to != null) {
+ AnimatableAngleValue toAngle = (AnimatableAngleValue) to;
+ if (toAngle.unit != u) {
+ v = rad(v, u);
+ v += interpolation * (rad(toAngle.value, toAngle.unit) - v);
+ u = SVGAngle.SVG_ANGLETYPE_RAD;
+ } else {
+ v += interpolation * (toAngle.value - v);
+ }
+ }
+ if (accumulation != null) {
+ AnimatableAngleValue accAngle = (AnimatableAngleValue) accumulation;
+ if (accAngle.unit != u) {
+ v += multiplier * rad(accAngle.value, accAngle.unit);
+ u = SVGAngle.SVG_ANGLETYPE_RAD;
+ } else {
+ v += multiplier * accAngle.value;
+ }
+ }
+
+ if (res.value != v || res.unit != u) {
+ res.value = v;
+ res.unit = u;
+ res.hasChanged = true;
+ }
+ return res;
+ }
+
+ /**
+ * Returns the angle unit.
+ */
+ public short getUnit() {
+ return unit;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ AnimatableAngleValue o = (AnimatableAngleValue) other;
+ return Math.abs(rad(value, unit) - rad(o.value, o.unit));
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public AnimatableValue getZeroValue() {
+ return new AnimatableAngleValue
+ (target, 0, SVGAngle.SVG_ANGLETYPE_UNSPECIFIED);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ return super.getCssText() + UNITS[unit];
+ }
+
+ /**
+ * Converts an angle value to radians.
+ */
+ public static float rad(float v, short unit) {
+ switch (unit) {
+ case SVGAngle.SVG_ANGLETYPE_RAD:
+ return v;
+ case SVGAngle.SVG_ANGLETYPE_GRAD:
+ return (float) Math.PI * v / 200;
+ default:
+ return (float) Math.PI * v / 180;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableBooleanValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableBooleanValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableBooleanValue.java
new file mode 100644
index 0000000..c6aad51
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableBooleanValue.java
@@ -0,0 +1,117 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+/**
+ * A boolean value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableBooleanValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AnimatableBooleanValue extends AnimatableValue {
+
+ /**
+ * The boolean value.
+ */
+ protected boolean value;
+
+ /**
+ * Creates a new, uninitialized AnimatableBooleanValue.
+ */
+ protected AnimatableBooleanValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableBooleanValue.
+ */
+ public AnimatableBooleanValue(AnimationTarget target, boolean b) {
+ super(target);
+ value = b;
+ }
+
+ /**
+ * Performs interpolation to the given value. Boolean values cannot be
+ * interpolated.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to, float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableBooleanValue res;
+ if (result == null) {
+ res = new AnimatableBooleanValue(target);
+ } else {
+ res = (AnimatableBooleanValue) result;
+ }
+
+ boolean newValue;
+ if (to != null && interpolation >= 0.5) {
+ AnimatableBooleanValue toValue = (AnimatableBooleanValue) to;
+ newValue = toValue.value;
+ } else {
+ newValue = value;
+ }
+
+ if (res.value != newValue) {
+ res.value = newValue;
+ res.hasChanged = true;
+ }
+ return res;
+ }
+
+ /**
+ * Returns the boolean value.
+ */
+ public boolean getValue() {
+ return value;
+ }
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public boolean canPace() {
+ return false;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ return 0f;
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public AnimatableValue getZeroValue() {
+ return new AnimatableBooleanValue(target, false);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ return (value)?"true":"false";
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableColorValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableColorValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableColorValue.java
new file mode 100644
index 0000000..83b1585
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableColorValue.java
@@ -0,0 +1,145 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+/**
+ * An SVG color value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableColorValue.java 501495 2007-01-30 18:00:36Z dvholten $
+ */
+public class AnimatableColorValue extends AnimatableValue {
+
+ /**
+ * The red component.
+ */
+ protected float red;
+
+ /**
+ * The green component.
+ */
+ protected float green;
+
+ /**
+ * The blue component.
+ */
+ protected float blue;
+
+ /**
+ * Creates a new AnimatableColorValue.
+ */
+ protected AnimatableColorValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableColorValue.
+ */
+ public AnimatableColorValue(AnimationTarget target,
+ float r, float g, float b) {
+ super(target);
+ red = r;
+ green = g;
+ blue = b;
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableColorValue res;
+ if (result == null) {
+ res = new AnimatableColorValue(target);
+ } else {
+ res = (AnimatableColorValue) result;
+ }
+
+ float oldRed = res.red;
+ float oldGreen = res.green;
+ float oldBlue = res.blue;
+
+ res.red = red;
+ res.green = green;
+ res.blue = blue;
+
+ AnimatableColorValue toColor = (AnimatableColorValue) to;
+ AnimatableColorValue accColor = (AnimatableColorValue) accumulation;
+
+ // XXX Should handle non-sRGB colours and non-sRGB interpolation.
+
+ if (to != null) {
+ res.red += interpolation * (toColor.red - res.red);
+ res.green += interpolation * (toColor.green - res.green);
+ res.blue += interpolation * (toColor.blue - res.blue);
+ }
+
+ if (accumulation != null) {
+ res.red += multiplier * accColor.red;
+ res.green += multiplier * accColor.green;
+ res.blue += multiplier * accColor.blue;
+ }
+
+ if (res.red != oldRed || res.green != oldGreen || res.blue != oldBlue) {
+ res.hasChanged = true;
+ }
+ return res;
+ }
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public boolean canPace() {
+ return true;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ AnimatableColorValue o = (AnimatableColorValue) other;
+ float dr = red - o.red;
+ float dg = green - o.green;
+ float db = blue - o.blue;
+ return (float) Math.sqrt(dr * dr + dg * dg + db * db);
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public AnimatableValue getZeroValue() {
+ return new AnimatableColorValue(target, 0f, 0f, 0f);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ return "rgb(" + Math.round(red * 255) + ','
+ + Math.round(green * 255) + ','
+ + Math.round(blue * 255) + ')';
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableIntegerValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableIntegerValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableIntegerValue.java
new file mode 100644
index 0000000..720da6b
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableIntegerValue.java
@@ -0,0 +1,121 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+/**
+ * An integer in the animation engine.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableIntegerValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AnimatableIntegerValue extends AnimatableValue {
+
+ /**
+ * The value.
+ */
+ protected int value;
+
+ /**
+ * Creates a new, uninitialized AnimatableIntegerValue.
+ */
+ protected AnimatableIntegerValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableIntegerValue.
+ */
+ public AnimatableIntegerValue(AnimationTarget target, int v) {
+ super(target);
+ value = v;
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableIntegerValue res;
+ if (result == null) {
+ res = new AnimatableIntegerValue(target);
+ } else {
+ res = (AnimatableIntegerValue) result;
+ }
+
+ int v = value;
+ if (to != null) {
+ AnimatableIntegerValue toInteger = (AnimatableIntegerValue) to;
+ v += value + interpolation * (toInteger.getValue() - value);
+ }
+ if (accumulation != null) {
+ AnimatableIntegerValue accInteger =
+ (AnimatableIntegerValue) accumulation;
+ v += multiplier * accInteger.getValue();
+ }
+
+ if (res.value != v) {
+ res.value = v;
+ res.hasChanged = true;
+ }
+ return res;
+ }
+
+ /**
+ * Returns the integer value.
+ */
+ public int getValue() {
+ return value;
+ }
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public boolean canPace() {
+ return true;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ AnimatableIntegerValue o = (AnimatableIntegerValue) other;
+ return Math.abs(value - o.value);
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public AnimatableValue getZeroValue() {
+ return new AnimatableIntegerValue(target, 0);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ return Integer.toString(value);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableLengthListValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableLengthListValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableLengthListValue.java
new file mode 100644
index 0000000..21b4aed
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableLengthListValue.java
@@ -0,0 +1,224 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+import org.w3c.dom.svg.SVGLength;
+
+/**
+ * An SVG length list value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableLengthListValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AnimatableLengthListValue extends AnimatableValue {
+
+ /**
+ * The length types.
+ */
+ protected short[] lengthTypes;
+
+ /**
+ * The length values. These should be one of the constants defined in
+ * {@link SVGLength}.
+ */
+ protected float[] lengthValues;
+
+ /**
+ * How to interpret percentage values. These should be one of the
+ * {@link AnimationTarget}.PERCENTAGE_* constants.
+ */
+ protected short percentageInterpretation;
+
+ /**
+ * Creates a new, uninitialized AnimatableLengthListValue.
+ */
+ protected AnimatableLengthListValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableLengthListValue.
+ */
+ public AnimatableLengthListValue(AnimationTarget target, short[] types,
+ float[] values, short pcInterp) {
+ super(target);
+ this.lengthTypes = types;
+ this.lengthValues = values;
+ this.percentageInterpretation = pcInterp;
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableLengthListValue toLengthList = (AnimatableLengthListValue) to;
+ AnimatableLengthListValue accLengthList
+ = (AnimatableLengthListValue) accumulation;
+
+ boolean hasTo = to != null;
+ boolean hasAcc = accumulation != null;
+ boolean canInterpolate =
+ !(hasTo && toLengthList.lengthTypes.length != lengthTypes.length)
+ && !(hasAcc && accLengthList.lengthTypes.length != lengthTypes.length);
+
+ short[] baseLengthTypes;
+ float[] baseLengthValues;
+ if (!canInterpolate && hasTo && interpolation >= 0.5) {
+ baseLengthTypes = toLengthList.lengthTypes;
+ baseLengthValues = toLengthList.lengthValues;
+ } else {
+ baseLengthTypes = lengthTypes;
+ baseLengthValues = lengthValues;
+ }
+ int len = baseLengthTypes.length;
+
+ AnimatableLengthListValue res;
+ if (result == null) {
+ res = new AnimatableLengthListValue(target);
+ res.lengthTypes = new short[len];
+ res.lengthValues = new float[len];
+ } else {
+ res = (AnimatableLengthListValue) result;
+ if (res.lengthTypes == null || res.lengthTypes.length != len) {
+ res.lengthTypes = new short[len];
+ res.lengthValues = new float[len];
+ }
+ }
+
+ res.hasChanged =
+ percentageInterpretation != res.percentageInterpretation;
+ res.percentageInterpretation = percentageInterpretation;
+
+ for (int i = 0; i < len; i++) {
+ float toV = 0, accV = 0;
+ short newLengthType = baseLengthTypes[i];
+ float newLengthValue = baseLengthValues[i];
+ if (canInterpolate) {
+ if (hasTo && !AnimatableLengthValue.compatibleTypes
+ (newLengthType,
+ percentageInterpretation,
+ toLengthList.lengthTypes[i],
+ toLengthList.percentageInterpretation)
+ || hasAcc && !AnimatableLengthValue.compatibleTypes
+ (newLengthType,
+ percentageInterpretation,
+ accLengthList.lengthTypes[i],
+ accLengthList.percentageInterpretation)) {
+ newLengthValue = target.svgToUserSpace
+ (newLengthValue, newLengthType,
+ percentageInterpretation);
+ newLengthType = SVGLength.SVG_LENGTHTYPE_NUMBER;
+ if (hasTo) {
+ toV = to.target.svgToUserSpace
+ (toLengthList.lengthValues[i],
+ toLengthList.lengthTypes[i],
+ toLengthList.percentageInterpretation);
+ }
+ if (hasAcc) {
+ accV = accumulation.target.svgToUserSpace
+ (accLengthList.lengthValues[i],
+ accLengthList.lengthTypes[i],
+ accLengthList.percentageInterpretation);
+ }
+ } else {
+ if (hasTo) {
+ toV = toLengthList.lengthValues[i];
+ }
+ if (hasAcc) {
+ accV = accLengthList.lengthValues[i];
+ }
+ }
+ newLengthValue +=
+ interpolation * (toV - newLengthValue)
+ + multiplier * accV;
+ }
+ if (!res.hasChanged) {
+ res.hasChanged = newLengthType != res.lengthTypes[i]
+ || newLengthValue != res.lengthValues[i];
+ }
+ res.lengthTypes[i] = newLengthType;
+ res.lengthValues[i] = newLengthValue;
+ }
+
+ return res;
+ }
+
+ /**
+ * Gets the length types.
+ */
+ public short[] getLengthTypes() {
+ return lengthTypes;
+ }
+
+ /**
+ * Gets the length values.
+ */
+ public float[] getLengthValues() {
+ return lengthValues;
+ }
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public boolean canPace() {
+ return false;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ return 0f;
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public AnimatableValue getZeroValue() {
+ float[] vs = new float[lengthValues.length];
+ return new AnimatableLengthListValue
+ (target, lengthTypes, vs, percentageInterpretation);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ * Length lists can never be used for CSS properties.
+ */
+ public String getCssText() {
+ StringBuffer sb = new StringBuffer();
+ if (lengthValues.length > 0) {
+ sb.append(formatNumber(lengthValues[0]));
+ sb.append(AnimatableLengthValue.UNITS[lengthTypes[0] - 1]);
+ }
+ for (int i = 1; i < lengthValues.length; i++) {
+ sb.append(',');
+ sb.append(formatNumber(lengthValues[i]));
+ sb.append(AnimatableLengthValue.UNITS[lengthTypes[i] - 1]);
+ }
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableLengthOrIdentValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableLengthOrIdentValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableLengthOrIdentValue.java
new file mode 100644
index 0000000..5ce36f9
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableLengthOrIdentValue.java
@@ -0,0 +1,185 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+import org.w3c.dom.svg.SVGLength;
+
+/**
+ * An SVG length-or-identifier value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableLengthOrIdentValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+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, short type,
+ float v, short pcInterp) {
+ super(target, type, v, pcInterp);
+ }
+
+ /**
+ * Creates a new AnimatableLengthOrIdentValue for an identifier value.
+ */
+ public AnimatableLengthOrIdentValue(AnimationTarget target, String ident) {
+ super(target);
+ this.ident = ident;
+ this.isIdent = true;
+ }
+
+ /**
+ * Returns whether this value is an identifier or a length.
+ */
+ public boolean isIdent() {
+ return isIdent;
+ }
+
+ /**
+ * Returns the identifier.
+ */
+ public String getIdent() {
+ return ident;
+ }
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public boolean canPace() {
+ return false;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ return 0f;
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public AnimatableValue getZeroValue() {
+ return new AnimatableLengthOrIdentValue
+ (target, SVGLength.SVG_LENGTHTYPE_NUMBER, 0f,
+ percentageInterpretation);
+ }
+
+ /**
+ * 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,
+ int multiplier) {
+ AnimatableLengthOrIdentValue res;
+ if (result == null) {
+ res = new AnimatableLengthOrIdentValue(target);
+ } else {
+ res = (AnimatableLengthOrIdentValue) result;
+ }
+
+ if (to == null) {
+ if (isIdent) {
+ res.hasChanged = !res.isIdent || !res.ident.equals(ident);
+ res.ident = ident;
+ res.isIdent = true;
+ } else {
+ short oldLengthType = res.lengthType;
+ float oldLengthValue = res.lengthValue;
+ short oldPercentageInterpretation = res.percentageInterpretation;
+ super.interpolate(res, to, interpolation, accumulation,
+ multiplier);
+ if (res.lengthType != oldLengthType
+ || res.lengthValue != oldLengthValue
+ || res.percentageInterpretation
+ != oldPercentageInterpretation) {
+ res.hasChanged = true;
+ }
+ }
+ } else {
+ AnimatableLengthOrIdentValue toValue
+ = (AnimatableLengthOrIdentValue) to;
+ if (isIdent || toValue.isIdent) {
+ if (interpolation >= 0.5) {
+ if (res.isIdent != toValue.isIdent
+ || res.lengthType != toValue.lengthType
+ || res.lengthValue != toValue.lengthValue
+ || res.isIdent && toValue.isIdent
+ && !toValue.ident.equals(ident)) {
+ res.isIdent = toValue.isIdent;
+ res.ident = toValue.ident;
+ res.lengthType = toValue.lengthType;
+ res.lengthValue = toValue.lengthValue;
+ res.hasChanged = true;
+ }
+ } else {
+ if (res.isIdent != isIdent
+ || res.lengthType != lengthType
+ || res.lengthValue != lengthValue
+ || res.isIdent && isIdent
+ && !res.ident.equals(ident)) {
+ res.isIdent = isIdent;
+ res.ident = ident;
+ res.ident = ident;
+ res.lengthType = lengthType;
+ res.hasChanged = true;
+ }
+ }
+ } else {
+ super.interpolate(res, to, interpolation, accumulation,
+ multiplier);
+ }
+ }
+
+ return res;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableLengthValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableLengthValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableLengthValue.java
new file mode 100644
index 0000000..3f513a7
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableLengthValue.java
@@ -0,0 +1,214 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+import org.w3c.dom.svg.SVGLength;
+
+/**
+ * An SVG length value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableLengthValue.java 478160 2006-11-22 13:35:06Z dvholten $
+ */
+public class AnimatableLengthValue extends AnimatableValue {
+
+ /**
+ * Length units.
+ */
+ protected static final String[] UNITS = {
+ "", "%", "em", "ex", "px", "cm", "mm", "in", "pt", "pc"
+ };
+
+ /**
+ * The length type.
+ */
+ protected short lengthType;
+
+ /**
+ * The length value. This should be one of the constants defined in
+ * {@link SVGLength}.
+ */
+ protected float lengthValue;
+
+ /**
+ * How to interpret percentage values. One of the
+ * {@link AnimationTarget}.PERCENTAGE_* constants.
+ */
+ protected short percentageInterpretation;
+
+ /**
+ * Creates a new AnimatableLengthValue with no length.
+ */
+ protected AnimatableLengthValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableLengthValue.
+ */
+ public AnimatableLengthValue(AnimationTarget target, short type, float v,
+ short pcInterp) {
+ super(target);
+ lengthType = type;
+ lengthValue = v;
+ percentageInterpretation = pcInterp;
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableLengthValue res;
+ if (result == null) {
+ res = new AnimatableLengthValue(target);
+ } else {
+ res = (AnimatableLengthValue) result;
+ }
+
+ short oldLengthType = res.lengthType;
+ float oldLengthValue = res.lengthValue;
+ short oldPercentageInterpretation = res.percentageInterpretation;
+
+ res.lengthType = lengthType;
+ res.lengthValue = lengthValue;
+ res.percentageInterpretation = percentageInterpretation;
+
+ if (to != null) {
+ AnimatableLengthValue toLength = (AnimatableLengthValue) to;
+ float toValue;
+ if (!compatibleTypes
+ (res.lengthType, res.percentageInterpretation,
+ toLength.lengthType, toLength.percentageInterpretation)) {
+ res.lengthValue = target.svgToUserSpace
+ (res.lengthValue, res.lengthType,
+ res.percentageInterpretation);
+ res.lengthType = SVGLength.SVG_LENGTHTYPE_NUMBER;
+ toValue = toLength.target.svgToUserSpace
+ (toLength.lengthValue, toLength.lengthType,
+ toLength.percentageInterpretation);
+ } else {
+ toValue = toLength.lengthValue;
+ }
+ res.lengthValue += interpolation * (toValue - res.lengthValue);
+ }
+
+ if (accumulation != null) {
+ AnimatableLengthValue accLength = (AnimatableLengthValue) accumulation;
+ float accValue;
+ if (!compatibleTypes
+ (res.lengthType, res.percentageInterpretation,
+ accLength.lengthType,
+ accLength.percentageInterpretation)) {
+ res.lengthValue = target.svgToUserSpace
+ (res.lengthValue, res.lengthType,
+ res.percentageInterpretation);
+ res.lengthType = SVGLength.SVG_LENGTHTYPE_NUMBER;
+ accValue = accLength.target.svgToUserSpace
+ (accLength.lengthValue, accLength.lengthType,
+ accLength.percentageInterpretation);
+ } else {
+ accValue = accLength.lengthValue;
+ }
+ res.lengthValue += multiplier * accValue;
+ }
+
+ if (oldPercentageInterpretation != res.percentageInterpretation
+ || oldLengthType != res.lengthType
+ || oldLengthValue != res.lengthValue) {
+ res.hasChanged = true;
+ }
+ return res;
+ }
+
+ /**
+ * Determines if two SVG length types are compatible.
+ * @param t1 the first SVG length type
+ * @param pi1 the first percentage interpretation type
+ * @param t2 the second SVG length type
+ * @param pi2 the second percentage interpretation type
+ */
+ public static boolean compatibleTypes(short t1, short pi1, short t2,
+ short pi2) {
+ return t1 == t2
+ && (t1 != SVGLength.SVG_LENGTHTYPE_PERCENTAGE || pi1 == pi2)
+ || t1 == SVGLength.SVG_LENGTHTYPE_NUMBER
+ && t2 == SVGLength.SVG_LENGTHTYPE_PX
+ || t1 == SVGLength.SVG_LENGTHTYPE_PX
+ && t2 == SVGLength.SVG_LENGTHTYPE_NUMBER;
+ }
+
+ /**
+ * Returns the unit type of this length value.
+ */
+ public int getLengthType() {
+ return lengthType;
+ }
+
+ /**
+ * Returns the magnitude of this length value.
+ */
+ public float getLengthValue() {
+ return lengthValue;
+ }
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public boolean canPace() {
+ return true;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ AnimatableLengthValue o = (AnimatableLengthValue) other;
+ float v1 = target.svgToUserSpace(lengthValue, lengthType,
+ percentageInterpretation);
+ float v2 = target.svgToUserSpace(o.lengthValue, o.lengthType,
+ o.percentageInterpretation);
+ return Math.abs(v1 - v2);
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public AnimatableValue getZeroValue() {
+ return new AnimatableLengthValue
+ (target, SVGLength.SVG_LENGTHTYPE_NUMBER, 0f,
+ percentageInterpretation);
+ }
+
+ /**
+ * Returns the CSS text representation of the value. This could use
+ * org.apache.flex.forks.batik.css.engine.value.FloatValue.getCssText, but we don't
+ * want a dependency on the CSS package.
+ */
+ public String getCssText() {
+ return formatNumber(lengthValue) + UNITS[lengthType - 1];
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableMotionPointValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableMotionPointValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableMotionPointValue.java
new file mode 100644
index 0000000..aa0eb75
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableMotionPointValue.java
@@ -0,0 +1,169 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+/**
+ * A point value in the animation system from a motion animation.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableMotionPointValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AnimatableMotionPointValue extends AnimatableValue {
+
+ /**
+ * The x coordinate.
+ */
+ protected float x;
+
+ /**
+ * The y coordinate.
+ */
+ protected float y;
+
+ /**
+ * The rotation angle in radians.
+ */
+ protected float angle;
+
+ /**
+ * Creates a new, uninitialized AnimatableMotionPointValue.
+ */
+ protected AnimatableMotionPointValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableMotionPointValue with one x.
+ */
+ public AnimatableMotionPointValue(AnimationTarget target, float x, float y,
+ float angle) {
+ super(target);
+ this.x = x;
+ this.y = y;
+ this.angle = angle;
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableMotionPointValue res;
+ if (result == null) {
+ res = new AnimatableMotionPointValue(target);
+ } else {
+ res = (AnimatableMotionPointValue) result;
+ }
+
+ float newX = x, newY = y, newAngle = angle;
+ int angleCount = 1;
+
+ if (to != null) {
+ AnimatableMotionPointValue toValue =
+ (AnimatableMotionPointValue) to;
+ newX += interpolation * (toValue.x - x);
+ newY += interpolation * (toValue.y - y);
+ newAngle += toValue.angle;
+ angleCount++;
+ }
+ if (accumulation != null && multiplier != 0) {
+ AnimatableMotionPointValue accValue =
+ (AnimatableMotionPointValue) accumulation;
+ newX += multiplier * accValue.x;
+ newY += multiplier * accValue.y;
+ newAngle += accValue.angle;
+ angleCount++;
+ }
+ newAngle /= angleCount;
+
+ if (res.x != newX || res.y != newY || res.angle != newAngle) {
+ res.x = newX;
+ res.y = newY;
+ res.angle = newAngle;
+ res.hasChanged = true;
+ }
+ return res;
+ }
+
+ /**
+ * Returns the x coordinate.
+ */
+ public float getX() {
+ return x;
+ }
+
+ /**
+ * Returns the y coordinate.
+ */
+ public float getY() {
+ return y;
+ }
+
+ /**
+ * Returns the rotation angle.
+ */
+ public float getAngle() {
+ return angle;
+ }
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public boolean canPace() {
+ return true;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ AnimatableMotionPointValue o = (AnimatableMotionPointValue) other;
+ float dx = x - o.x;
+ float dy = y - o.y;
+ return (float) Math.sqrt(dx * dx + dy * dy);
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public AnimatableValue getZeroValue() {
+ return new AnimatableMotionPointValue(target, 0f, 0f, 0f);
+ }
+
+ /**
+ * Returns a string representation of this object.
+ */
+ public String toStringRep() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(formatNumber(x));
+ sb.append(',');
+ sb.append(formatNumber(y));
+ sb.append(',');
+ sb.append(formatNumber(angle));
+ sb.append("rad");
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberListValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberListValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberListValue.java
new file mode 100644
index 0000000..fc1040c
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberListValue.java
@@ -0,0 +1,151 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+/**
+ * A number list in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableNumberListValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AnimatableNumberListValue extends AnimatableValue {
+
+ /**
+ * The numbers.
+ */
+ protected float[] numbers;
+
+ /**
+ * Creates a new, uninitialized AnimatableNumberListValue.
+ */
+ protected AnimatableNumberListValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableNumberListValue.
+ */
+ public AnimatableNumberListValue(AnimationTarget target, float[] numbers) {
+ super(target);
+ this.numbers = numbers;
+ }
+
+ /**
+ * Performs interpolation to the given value. Number list values cannot
+ * be interpolated.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableNumberListValue toNumList = (AnimatableNumberListValue) to;
+ AnimatableNumberListValue accNumList =
+ (AnimatableNumberListValue) accumulation;
+
+ boolean hasTo = to != null;
+ boolean hasAcc = accumulation != null;
+ boolean canInterpolate =
+ !(hasTo && toNumList.numbers.length != numbers.length)
+ && !(hasAcc && accNumList.numbers.length != numbers.length);
+
+ float[] baseValues;
+ if (!canInterpolate && hasTo && interpolation >= 0.5) {
+ baseValues = toNumList.numbers;
+ } else {
+ baseValues = numbers;
+ }
+ int len = baseValues.length;
+
+ AnimatableNumberListValue res;
+ if (result == null) {
+ res = new AnimatableNumberListValue(target);
+ res.numbers = new float[len];
+ } else {
+ res = (AnimatableNumberListValue) result;
+ if (res.numbers == null || res.numbers.length != len) {
+ res.numbers = new float[len];
+ }
+ }
+
+ for (int i = 0; i < len; i++) {
+ float newValue = baseValues[i];
+ if (canInterpolate) {
+ if (hasTo) {
+ newValue += interpolation * (toNumList.numbers[i] - newValue);
+ }
+ if (hasAcc) {
+ newValue += multiplier * accNumList.numbers[i];
+ }
+ }
+ if (res.numbers[i] != newValue) {
+ res.numbers[i] = newValue;
+ res.hasChanged = true;
+ }
+ }
+
+ return res;
+ }
+
+ /**
+ * Gets the numbers.
+ */
+ public float[] getNumbers() {
+ return numbers;
+ }
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public boolean canPace() {
+ return false;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ return 0f;
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ 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();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberOptionalNumberValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberOptionalNumberValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberOptionalNumberValue.java
new file mode 100644
index 0000000..ad786d9
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberOptionalNumberValue.java
@@ -0,0 +1,174 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+/**
+ * A number-optional-number value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableNumberOptionalNumberValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AnimatableNumberOptionalNumberValue extends AnimatableValue {
+
+ /**
+ * The first number.
+ */
+ protected float number;
+
+ /**
+ * Whether the optional number is present.
+ */
+ protected boolean hasOptionalNumber;
+
+ /**
+ * The optional number.
+ */
+ protected float optionalNumber;
+
+ /**
+ * Creates a new, uninitialized AnimatableNumberOptionalNumberValue.
+ */
+ protected AnimatableNumberOptionalNumberValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableNumberOptionalNumberValue with one number.
+ */
+ public AnimatableNumberOptionalNumberValue(AnimationTarget target,
+ float n) {
+ super(target);
+ number = n;
+ }
+
+ /**
+ * Creates a new AnimatableNumberOptionalNumberValue with two numbers.
+ */
+ public AnimatableNumberOptionalNumberValue(AnimationTarget target, float n,
+ float on) {
+ super(target);
+ number = n;
+ optionalNumber = on;
+ hasOptionalNumber = true;
+ }
+
+ /**
+ * Performs interpolation to the given value. Number-optional-number
+ * values cannot be interpolated.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableNumberOptionalNumberValue res;
+ if (result == null) {
+ res = new AnimatableNumberOptionalNumberValue(target);
+ } else {
+ res = (AnimatableNumberOptionalNumberValue) result;
+ }
+
+ float newNumber, newOptionalNumber;
+ boolean newHasOptionalNumber;
+
+ if (to != null && interpolation >= 0.5) {
+ AnimatableNumberOptionalNumberValue toValue
+ = (AnimatableNumberOptionalNumberValue) to;
+ newNumber = toValue.number;
+ newOptionalNumber = toValue.optionalNumber;
+ newHasOptionalNumber = toValue.hasOptionalNumber;
+ } else {
+ newNumber = number;
+ newOptionalNumber = optionalNumber;
+ newHasOptionalNumber = hasOptionalNumber;
+ }
+
+ if (res.number != newNumber
+ || res.hasOptionalNumber != newHasOptionalNumber
+ || res.optionalNumber != newOptionalNumber) {
+ res.number = number;
+ res.optionalNumber = optionalNumber;
+ res.hasOptionalNumber = hasOptionalNumber;
+ res.hasChanged = true;
+ }
+ return res;
+ }
+
+ /**
+ * Returns the first number.
+ */
+ public float getNumber() {
+ return number;
+ }
+
+ /**
+ * Returns whether the optional number is present.
+ */
+ public boolean hasOptionalNumber() {
+ return hasOptionalNumber;
+ }
+
+ /**
+ * Returns the optional number.
+ */
+ public float getOptionalNumber() {
+ return optionalNumber;
+ }
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public boolean canPace() {
+ return false;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ return 0f;
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public AnimatableValue getZeroValue() {
+ if (hasOptionalNumber) {
+ return new AnimatableNumberOptionalNumberValue(target, 0f, 0f);
+ }
+ return new AnimatableNumberOptionalNumberValue(target, 0f);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(formatNumber(number));
+ if (hasOptionalNumber) {
+ sb.append(' ');
+ sb.append(formatNumber(optionalNumber));
+ }
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberOrIdentValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberOrIdentValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberOrIdentValue.java
new file mode 100644
index 0000000..e7284db
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberOrIdentValue.java
@@ -0,0 +1,177 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+/**
+ * A number-or-identifier value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableNumberOrIdentValue.java 492528 2007-01-04 11:45:47Z cam $
+ */
+public class AnimatableNumberOrIdentValue extends AnimatableNumberValue {
+
+ /**
+ * Whether this value is an identifier.
+ */
+ protected boolean isIdent;
+
+ /**
+ * The identifier.
+ */
+ protected String ident;
+
+ /**
+ * Whether numbers should be considered as numeric keywords, as with the
+ * font-weight property.
+ */
+ protected boolean numericIdent;
+
+ /**
+ * Creates a new, uninitialized AnimatableNumberOrIdentValue.
+ */
+ protected AnimatableNumberOrIdentValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableNumberOrIdentValue for a Number value.
+ */
+ public AnimatableNumberOrIdentValue(AnimationTarget target, float v,
+ boolean numericIdent) {
+ super(target, v);
+ this.numericIdent = numericIdent;
+ }
+
+ /**
+ * Creates a new AnimatableNumberOrIdentValue for an identifier value.
+ */
+ public AnimatableNumberOrIdentValue(AnimationTarget target, String ident) {
+ super(target);
+ this.ident = ident;
+ this.isIdent = true;
+ }
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public boolean canPace() {
+ return false;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ return 0f;
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public AnimatableValue getZeroValue() {
+ return new AnimatableNumberOrIdentValue(target, 0f, numericIdent);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ if (isIdent) {
+ return ident;
+ }
+ if (numericIdent) {
+ return Integer.toString((int) value);
+ }
+ return super.getCssText();
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to, float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableNumberOrIdentValue res;
+ if (result == null) {
+ res = new AnimatableNumberOrIdentValue(target);
+ } else {
+ res = (AnimatableNumberOrIdentValue) result;
+ }
+
+ if (to == null) {
+ if (isIdent) {
+ res.hasChanged = !res.isIdent || !res.ident.equals(ident);
+ res.ident = ident;
+ res.isIdent = true;
+ } else if (numericIdent) {
+ res.hasChanged = res.value != value || res.isIdent;
+ res.value = value;
+ res.isIdent = false;
+ res.hasChanged = true;
+ res.numericIdent = true;
+ } else {
+ float oldValue = res.value;
+ super.interpolate(res, to, interpolation, accumulation,
+ multiplier);
+ res.numericIdent = false;
+ if (res.value != oldValue) {
+ res.hasChanged = true;
+ }
+ }
+ } else {
+ AnimatableNumberOrIdentValue toValue
+ = (AnimatableNumberOrIdentValue) to;
+ if (isIdent || toValue.isIdent || numericIdent) {
+ if (interpolation >= 0.5) {
+ if (res.isIdent != toValue.isIdent
+ || res.value != toValue.value
+ || res.isIdent && toValue.isIdent
+ && !toValue.ident.equals(ident)) {
+ res.isIdent = toValue.isIdent;
+ res.ident = toValue.ident;
+ res.value = toValue.value;
+ res.numericIdent = toValue.numericIdent;
+ res.hasChanged = true;
+ }
+ } else {
+ if (res.isIdent != isIdent
+ || res.value != value
+ || res.isIdent && isIdent
+ && !res.ident.equals(ident)) {
+ res.isIdent = isIdent;
+ res.ident = ident;
+ res.value = value;
+ res.numericIdent = numericIdent;
+ res.hasChanged = true;
+ }
+ }
+ } else {
+ super.interpolate(res, to, interpolation, accumulation,
+ multiplier);
+ res.numericIdent = false;
+ }
+ }
+ return res;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberOrPercentageValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberOrPercentageValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberOrPercentageValue.java
new file mode 100644
index 0000000..ce01047
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberOrPercentageValue.java
@@ -0,0 +1,155 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+/**
+ * A number-or-percentage value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableNumberOrPercentageValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AnimatableNumberOrPercentageValue extends AnimatableNumberValue {
+
+ /**
+ * Whether the number is a percentage.
+ */
+ protected boolean isPercentage;
+
+ /**
+ * Creates a new, uninitialized AnimatableNumberOrPercentageValue.
+ */
+ protected AnimatableNumberOrPercentageValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableNumberOrPercentageValue with a number.
+ */
+ public AnimatableNumberOrPercentageValue(AnimationTarget target, float n) {
+ super(target, n);
+ }
+
+ /**
+ * Creates a new AnimatableNumberOrPercentageValue with either a number
+ * or a percentage.
+ */
+ public AnimatableNumberOrPercentageValue(AnimationTarget target, float n,
+ boolean isPercentage) {
+ super(target, n);
+ this.isPercentage = isPercentage;
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableNumberOrPercentageValue res;
+ if (result == null) {
+ res = new AnimatableNumberOrPercentageValue(target);
+ } else {
+ res = (AnimatableNumberOrPercentageValue) result;
+ }
+
+ float newValue;
+ boolean newIsPercentage;
+
+ AnimatableNumberOrPercentageValue toValue
+ = (AnimatableNumberOrPercentageValue) to;
+ AnimatableNumberOrPercentageValue accValue
+ = (AnimatableNumberOrPercentageValue) accumulation;
+
+ if (to != null) {
+ if (toValue.isPercentage == isPercentage) {
+ newValue = value + interpolation * (toValue.value - value);
+ newIsPercentage = isPercentage;
+ } else {
+ if (interpolation >= 0.5) {
+ newValue = toValue.value;
+ newIsPercentage = toValue.isPercentage;
+ } else {
+ newValue = value;
+ newIsPercentage = isPercentage;
+ }
+ }
+ } else {
+ newValue = value;
+ newIsPercentage = isPercentage;
+ }
+
+ if (accumulation != null && accValue.isPercentage == newIsPercentage) {
+ newValue += multiplier * accValue.value;
+ }
+
+ if (res.value != newValue
+ || res.isPercentage != newIsPercentage) {
+ res.value = newValue;
+ res.isPercentage = newIsPercentage;
+ res.hasChanged = true;
+ }
+ return res;
+ }
+
+ /**
+ * Returns whether the value is a percentage.
+ */
+ public boolean isPercentage() {
+ return isPercentage;
+ }
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public boolean canPace() {
+ return false;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ return 0f;
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public AnimatableValue getZeroValue() {
+ return new AnimatableNumberOrPercentageValue(target, 0, isPercentage);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(formatNumber(value));
+ if (isPercentage) {
+ sb.append('%');
+ }
+ return sb.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberValue.java
new file mode 100644
index 0000000..eafbcf1
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableNumberValue.java
@@ -0,0 +1,120 @@
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.flex.forks.batik.anim.values;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+/**
+ * A number value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableNumberValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AnimatableNumberValue extends AnimatableValue {
+
+ /**
+ * The value.
+ */
+ protected float value;
+
+ /**
+ * Creates a new, uninitialized AnimatableNumberValue.
+ */
+ protected AnimatableNumberValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableNumberValue.
+ */
+ public AnimatableNumberValue(AnimationTarget target, float v) {
+ super(target);
+ value = v;
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableNumberValue res;
+ if (result == null) {
+ res = new AnimatableNumberValue(target);
+ } else {
+ res = (AnimatableNumberValue) result;
+ }
+
+ float v = value;
+ if (to != null) {
+ AnimatableNumberValue toNumber = (AnimatableNumberValue) to;
+ v += interpolation * (toNumber.value - value);
+ }
+ if (accumulation != null) {
+ AnimatableNumberValue accNumber = (AnimatableNumberValue) accumulation;
+ v += multiplier * accNumber.value;
+ }
+
+ if (res.value != v) {
+ res.value = v;
+ res.hasChanged = true;
+ }
+ return res;
+ }
+
+ /**
+ * Returns the number value.
+ */
+ public float getValue() {
+ return value;
+ }
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public boolean canPace() {
+ return true;
+ }
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public float distanceTo(AnimatableValue other) {
+ AnimatableNumberValue o = (AnimatableNumberValue) other;
+ return Math.abs(value - o.value);
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public AnimatableValue getZeroValue() {
+ return new AnimatableNumberValue(target, 0);
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ return formatNumber(value);
+ }
+}