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:41 UTC
[26/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/values/AnimatablePaintValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePaintValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePaintValue.java
new file mode 100644
index 0000000..5ae846d
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePaintValue.java
@@ -0,0 +1,283 @@
+/*
+
+ 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 paint value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatablePaintValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AnimatablePaintValue extends AnimatableColorValue {
+
+ // Constants for paintType.
+ 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.
+ */
+ protected int paintType;
+
+ /**
+ * The URI of the referenced paint server.
+ */
+ protected String uri;
+
+ /**
+ * Creates a new, uninitialized AnimatablePaintValue.
+ */
+ protected AnimatablePaintValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatablePaintValue.
+ */
+ protected AnimatablePaintValue(AnimationTarget target, float r, float g,
+ float b) {
+ super(target, r, g, b);
+ }
+
+ /**
+ * Creates a new AnimatablePaintValue for a 'none' value.
+ */
+ public static AnimatablePaintValue createNonePaintValue
+ (AnimationTarget target) {
+ AnimatablePaintValue v = new AnimatablePaintValue(target);
+ v.paintType = PAINT_NONE;
+ return v;
+ }
+
+ /**
+ * Creates a new AnimatablePaintValue for a 'currentColor' value.
+ */
+ public static AnimatablePaintValue createCurrentColorPaintValue
+ (AnimationTarget target) {
+ AnimatablePaintValue v = new AnimatablePaintValue(target);
+ v.paintType = PAINT_CURRENT_COLOR;
+ return v;
+ }
+
+ /**
+ * Creates a new AnimatablePaintValue for a color value.
+ */
+ public static AnimatablePaintValue createColorPaintValue
+ (AnimationTarget target, float r, float g, float b) {
+ AnimatablePaintValue v = new AnimatablePaintValue(target, r, g, b);
+ v.paintType = PAINT_COLOR;
+ return v;
+ }
+
+ /**
+ * Creates a new AnimatablePaintValue for a URI reference.
+ */
+ public static AnimatablePaintValue createURIPaintValue
+ (AnimationTarget target, String uri) {
+ AnimatablePaintValue v = new AnimatablePaintValue(target);
+ v.uri = uri;
+ v.paintType = PAINT_URI;
+ return v;
+ }
+
+ /**
+ * Creates a new AnimatablePaintValue for a URI reference with a
+ * 'none' fallback.
+ */
+ public static AnimatablePaintValue createURINonePaintValue
+ (AnimationTarget target, String uri) {
+ AnimatablePaintValue v = new AnimatablePaintValue(target);
+ v.uri = uri;
+ v.paintType = PAINT_URI_NONE;
+ return v;
+ }
+
+ /**
+ * Creates a new AnimatablePaintValue for a URI reference with a
+ * 'currentColor' fallback.
+ */
+ public static AnimatablePaintValue createURICurrentColorPaintValue
+ (AnimationTarget target, String uri) {
+ AnimatablePaintValue v = new AnimatablePaintValue(target);
+ v.uri = uri;
+ v.paintType = PAINT_URI_CURRENT_COLOR;
+ return v;
+ }
+
+ /**
+ * Creates a new AnimatablePaintValue for a URI reference with a
+ * color fallback.
+ */
+ public static AnimatablePaintValue createURIColorPaintValue
+ (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;
+ }
+
+ /**
+ * Creates a new AnimatablePaintValue for a 'inherit' value.
+ */
+ public static AnimatablePaintValue createInheritPaintValue
+ (AnimationTarget target) {
+ AnimatablePaintValue v = new AnimatablePaintValue(target);
+ v.paintType = PAINT_INHERIT;
+ return v;
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatablePaintValue res;
+ if (result == null) {
+ res = new AnimatablePaintValue(target);
+ } else {
+ res = (AnimatablePaintValue) result;
+ }
+
+ if (paintType == PAINT_COLOR) {
+ boolean canInterpolate = true;
+ if (to != null) {
+ AnimatablePaintValue toPaint = (AnimatablePaintValue) to;
+ canInterpolate = toPaint.paintType == PAINT_COLOR;
+ }
+ if (accumulation != null) {
+ AnimatablePaintValue accPaint =
+ (AnimatablePaintValue) accumulation;
+ canInterpolate =
+ canInterpolate && accPaint.paintType == PAINT_COLOR;
+ }
+ if (canInterpolate) {
+ res.paintType = PAINT_COLOR;
+ return super.interpolate
+ (res, to, interpolation, accumulation, multiplier);
+ }
+ }
+
+ int newPaintType;
+ String newURI;
+ float newRed, newGreen, newBlue;
+
+ if (to != null && interpolation >= 0.5) {
+ AnimatablePaintValue toValue = (AnimatablePaintValue) to;
+ newPaintType = toValue.paintType;
+ newURI = toValue.uri;
+ newRed = toValue.red;
+ newGreen = toValue.green;
+ newBlue = toValue.blue;
+ } else {
+ newPaintType = paintType;
+ newURI = uri;
+ newRed = red;
+ newGreen = green;
+ newBlue = blue;
+ }
+
+ if (res.paintType != newPaintType
+ || res.uri == null
+ || !res.uri.equals(newURI)
+ || res.red != newRed
+ || res.green != newGreen
+ || res.blue != newBlue) {
+ res.paintType = newPaintType;
+ res.uri = newURI;
+ res.red = newRed;
+ res.green = newGreen;
+ res.blue = newBlue;
+ res.hasChanged = true;
+ }
+
+ return res;
+ }
+
+ /**
+ * Returns the type of paint this value represents.
+ */
+ public int getPaintType() {
+ return paintType;
+ }
+
+ /**
+ * Returns the paint server URI.
+ */
+ public String getURI() {
+ return uri;
+ }
+
+ /**
+ * 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 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";
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePathDataValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePathDataValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePathDataValue.java
new file mode 100644
index 0000000..5bff18c
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePathDataValue.java
@@ -0,0 +1,198 @@
+/*
+
+ 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 java.util.Arrays;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+/**
+ * An SVG path value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatablePathDataValue.java 479349 2006-11-26 11:54:23Z cam $
+ */
+public class AnimatablePathDataValue extends AnimatableValue {
+
+ /**
+ * The path commands. These must be one of the PATHSEG_*
+ * constants defined in {@link org.w3c.dom.svg.SVGPathSeg}.
+ */
+ protected short[] commands;
+
+ /**
+ * The path parameters. Also includes the booleans.
+ */
+ protected float[] parameters;
+
+ /**
+ * Creates a new, uninitialized AnimatablePathDataValue.
+ */
+ protected AnimatablePathDataValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatablePathDataValue.
+ */
+ public AnimatablePathDataValue(AnimationTarget target, short[] commands,
+ float[] parameters) {
+ super(target);
+ this.commands = commands;
+ this.parameters = parameters;
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to, float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatablePathDataValue toValue = (AnimatablePathDataValue) to;
+ AnimatablePathDataValue accValue =
+ (AnimatablePathDataValue) accumulation;
+
+ boolean hasTo = to != null;
+ boolean hasAcc = accumulation != null;
+ boolean canInterpolate = hasTo
+ && toValue.parameters.length == parameters.length
+ && Arrays.equals(toValue.commands, commands);
+ boolean canAccumulate = hasAcc
+ && accValue.parameters.length == parameters.length
+ && Arrays.equals(accValue.commands, commands);
+
+ AnimatablePathDataValue base;
+ if (!canInterpolate && hasTo && interpolation >= 0.5) {
+ base = toValue;
+ } else {
+ base = this;
+ }
+ int cmdCount = base.commands.length;
+ int paramCount = base.parameters.length;
+
+ AnimatablePathDataValue res;
+ if (result == null) {
+ res = new AnimatablePathDataValue(target);
+ res.commands = new short[cmdCount];
+ res.parameters = new float[paramCount];
+ System.arraycopy(base.commands, 0, res.commands, 0, cmdCount);
+ } else {
+ res = (AnimatablePathDataValue) result;
+ if (res.commands == null || res.commands.length != cmdCount) {
+ res.commands = new short[cmdCount];
+ System.arraycopy(base.commands, 0, res.commands, 0, cmdCount);
+ res.hasChanged = true;
+ } else {
+ if (!Arrays.equals(base.commands, res.commands)) {
+ System.arraycopy(base.commands, 0, res.commands, 0,
+ cmdCount);
+ res.hasChanged = true;
+ }
+ }
+ }
+
+ for (int i = 0; i < paramCount; i++) {
+ float newValue = base.parameters[i];
+ if (canInterpolate) {
+ newValue += interpolation * (toValue.parameters[i] - newValue);
+ }
+ if (canAccumulate) {
+ newValue += multiplier * accValue.parameters[i];
+ }
+ if (res.parameters[i] != newValue) {
+ res.parameters[i] = newValue;
+ res.hasChanged = true;
+ }
+ }
+
+ return res;
+ }
+
+ /**
+ * Returns the array of path data commands.
+ */
+ public short[] getCommands() {
+ return commands;
+ }
+
+ /**
+ * Returns the array of path data parameters.
+ */
+ public float[] getParameters() {
+ return parameters;
+ }
+
+ /**
+ * 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() {
+ short[] cmds = new short[commands.length];
+ System.arraycopy(commands, 0, cmds, 0, commands.length);
+ float[] params = new float[parameters.length];
+ return new AnimatablePathDataValue(target, cmds, params);
+ }
+
+ /**
+ * The path data commands.
+ */
+ protected static final char[] PATH_COMMANDS = {
+ ' ', 'z', 'M', 'm', 'L', 'l', 'C', 'c', 'Q', 'q', 'A', 'a', 'H', 'h',
+ 'V', 'v', 'S', 's', 'T', 't'
+ };
+
+ /**
+ * The number of parameters for each path command.
+ */
+ protected static final int[] PATH_PARAMS = {
+ 0, 0, 2, 2, 2, 2, 6, 6, 4, 4, 7, 7, 1, 1, 1, 1, 4, 4, 2, 2
+ };
+
+ /**
+ * Returns a string representation of this object.
+ */
+ public String toStringRep() {
+ StringBuffer sb = new StringBuffer();
+ int k = 0;
+ for (int i = 0; i < commands.length; i++) {
+ sb.append(PATH_COMMANDS[commands[i]]);
+ for (int j = 0; j < PATH_PARAMS[commands[i]]; j++) {
+ sb.append(' ');
+ sb.append(parameters[k++]);
+ }
+ }
+ 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/AnimatablePercentageValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePercentageValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePercentageValue.java
new file mode 100644
index 0000000..4974eb5
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePercentageValue.java
@@ -0,0 +1,73 @@
+/*
+
+ 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 percentage value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatablePercentageValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+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,
+ int multiplier) {
+ if (result == null) {
+ result = new AnimatablePercentageValue(target);
+ }
+ return super.interpolate
+ (result, to, interpolation, accumulation, multiplier);
+ }
+
+ /**
+ * 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() + "%";
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePointListValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePointListValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePointListValue.java
new file mode 100644
index 0000000..14ed88d
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePointListValue.java
@@ -0,0 +1,83 @@
+/*
+
+ 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 point list value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatablePointListValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AnimatablePointListValue extends AnimatableNumberListValue {
+
+ /**
+ * Creates a new, uninitialized AnimatablePointListValue.
+ */
+ 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,
+ int multiplier) {
+ if (result == null) {
+ result = new AnimatablePointListValue(target);
+ }
+ return super.interpolate
+ (result, to, interpolation, accumulation, multiplier);
+ }
+
+ /**
+ * 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 AnimatablePointListValue(target, ns);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePreserveAspectRatioValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePreserveAspectRatioValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePreserveAspectRatioValue.java
new file mode 100644
index 0000000..699f956
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatablePreserveAspectRatioValue.java
@@ -0,0 +1,176 @@
+/*
+
+ 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.apache.flex.forks.batik.util.SVGConstants;
+
+import org.w3c.dom.svg.SVGPreserveAspectRatio;
+
+/**
+ * An SVG preserveAspectRatio value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatablePreserveAspectRatioValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AnimatablePreserveAspectRatioValue extends AnimatableValue {
+
+ /**
+ * Strings for the 'align' values.
+ */
+ protected static final String[] ALIGN_VALUES = {
+ null,
+ SVGConstants.SVG_NONE_VALUE,
+ SVGConstants.SVG_XMINYMIN_VALUE,
+ SVGConstants.SVG_XMIDYMIN_VALUE,
+ SVGConstants.SVG_XMAXYMIN_VALUE,
+ SVGConstants.SVG_XMINYMID_VALUE,
+ SVGConstants.SVG_XMIDYMID_VALUE,
+ SVGConstants.SVG_XMAXYMID_VALUE,
+ SVGConstants.SVG_XMINYMAX_VALUE,
+ SVGConstants.SVG_XMIDYMAX_VALUE,
+ SVGConstants.SVG_XMAXYMAX_VALUE
+ };
+
+ /**
+ * Strings for the 'meet-or-slice' values.
+ */
+ protected static final String[] MEET_OR_SLICE_VALUES = {
+ null,
+ SVGConstants.SVG_MEET_VALUE,
+ SVGConstants.SVG_SLICE_VALUE
+ };
+
+ /**
+ * The align value.
+ */
+ protected short align;
+
+ /**
+ * The meet-or-slice value.
+ */
+ protected short meetOrSlice;
+
+ /**
+ * Creates a new, uninitialized AnimatablePreserveAspectRatioValue.
+ */
+ protected AnimatablePreserveAspectRatioValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatablePreserveAspectRatioValue.
+ */
+ public AnimatablePreserveAspectRatioValue(AnimationTarget target,
+ short align, short meetOrSlice) {
+ super(target);
+ this.align = align;
+ this.meetOrSlice = meetOrSlice;
+ }
+
+ /**
+ * Performs interpolation to the given value. Preserve aspect ratio values
+ * cannot be interpolated.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to, float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatablePreserveAspectRatioValue res;
+ if (result == null) {
+ res = new AnimatablePreserveAspectRatioValue(target);
+ } else {
+ res = (AnimatablePreserveAspectRatioValue) result;
+ }
+
+ short newAlign, newMeetOrSlice;
+ if (to != null && interpolation >= 0.5) {
+ AnimatablePreserveAspectRatioValue toValue =
+ (AnimatablePreserveAspectRatioValue) to;
+ newAlign = toValue.align;
+ newMeetOrSlice = toValue.meetOrSlice;
+ } else {
+ newAlign = align;
+ newMeetOrSlice = meetOrSlice;
+ }
+
+ if (res.align != newAlign || res.meetOrSlice != newMeetOrSlice) {
+ res.align = align;
+ res.meetOrSlice = meetOrSlice;
+ res.hasChanged = true;
+ }
+ return res;
+ }
+
+ /**
+ * Returns the align value.
+ */
+ public short getAlign() {
+ return align;
+ }
+
+ /**
+ * Returns the meet-or-slice value.
+ */
+ public short getMeetOrSlice() {
+ return meetOrSlice;
+ }
+
+ /**
+ * 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 AnimatablePreserveAspectRatioValue
+ (target, SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_NONE,
+ SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET);
+ }
+
+ /**
+ * Returns a string representation of this object.
+ */
+ public String toStringRep() {
+ if (align < 1 || align > 10) {
+ return null;
+ }
+ String value = ALIGN_VALUES[align];
+ if (align == SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_NONE) {
+ return value;
+ }
+ if (meetOrSlice < 1 || meetOrSlice > 2) {
+ return null;
+ }
+ return value + ' ' + MEET_OR_SLICE_VALUES[meetOrSlice];
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableRectValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableRectValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableRectValue.java
new file mode 100644
index 0000000..e181fd3
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableRectValue.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;
+
+/**
+ * An SVG rect value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableRectValue.java 579487 2007-09-26 06:40:16Z cam $
+ */
+public class AnimatableRectValue extends AnimatableValue {
+
+ /**
+ * The x coordinate.
+ */
+ protected float x;
+
+ /**
+ * The y coordinate.
+ */
+ protected float y;
+
+ /**
+ * The width.
+ */
+ protected float width;
+
+ /**
+ * The height.
+ */
+ protected float height;
+
+ /**
+ * Creates a new, uninitialized AnimatableRectValue.
+ */
+ protected AnimatableRectValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableRectValue with one number.
+ */
+ public AnimatableRectValue(AnimationTarget target, float x, float y,
+ float w, float h) {
+ super(target);
+ this.x = x;
+ this.y = y;
+ this.width = w;
+ this.height = h;
+ }
+
+ /**
+ * Performs interpolation to the given value. Rect values cannot be
+ * interpolated.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableRectValue res;
+ if (result == null) {
+ res = new AnimatableRectValue(target);
+ } else {
+ res = (AnimatableRectValue) result;
+ }
+
+ float newX = x, newY = y, newWidth = width, newHeight = height;
+ if (to != null) {
+ AnimatableRectValue toValue = (AnimatableRectValue) to;
+ newX += interpolation * (toValue.x - x);
+ newY += interpolation * (toValue.y - y);
+ newWidth += interpolation * (toValue.width - width);
+ newHeight += interpolation * (toValue.height - height);
+ }
+ if (accumulation != null && multiplier != 0) {
+ AnimatableRectValue accValue = (AnimatableRectValue) accumulation;
+ newX += multiplier * accValue.x;
+ newY += multiplier * accValue.y;
+ newWidth += multiplier * accValue.width;
+ newHeight += multiplier * accValue.height;
+ }
+ if (res.x != newX || res.y != newY
+ || res.width != newWidth || res.height != newHeight) {
+ res.x = newX;
+ res.y = newY;
+ res.width = newWidth;
+ res.height = newHeight;
+ 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 width.
+ */
+ public float getWidth() {
+ return width;
+ }
+
+ /**
+ * Returns the height.
+ */
+ public float getHeight() {
+ return height;
+ }
+
+ /**
+ * 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 AnimatableRectValue(target, 0f, 0f, 0f, 0f);
+ }
+
+ /**
+ * Returns a string representation of this object.
+ */
+ public String toStringRep() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(x);
+ sb.append(',');
+ sb.append(y);
+ sb.append(',');
+ sb.append(width);
+ sb.append(',');
+ sb.append(height);
+ 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/AnimatableStringValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableStringValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableStringValue.java
new file mode 100644
index 0000000..c5c5070
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableStringValue.java
@@ -0,0 +1,118 @@
+/*
+
+ 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 string value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableStringValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public class AnimatableStringValue extends AnimatableValue {
+
+ /**
+ * The string value.
+ */
+ protected String string;
+
+ /**
+ * Creates a new, uninitialized AnimatableStringValue.
+ */
+ protected AnimatableStringValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableStringValue.
+ */
+ public AnimatableStringValue(AnimationTarget target, String s) {
+ super(target);
+ string = s;
+ }
+
+ /**
+ * Performs interpolation to the given value. String values cannot be
+ * interpolated.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to, float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+ AnimatableStringValue res;
+ if (result == null) {
+ res = new AnimatableStringValue(target);
+ } else {
+ res = (AnimatableStringValue) result;
+ }
+
+ String newString;
+ if (to != null && interpolation >= 0.5) {
+ AnimatableStringValue toValue =
+ (AnimatableStringValue) to;
+ newString = toValue.string;
+ } else {
+ newString = string;
+ }
+
+ if (res.string == null || !res.string.equals(newString)) {
+ res.string = newString;
+ res.hasChanged = true;
+ }
+ return res;
+ }
+
+ /**
+ * Returns the string.
+ */
+ public String getString() {
+ return string;
+ }
+
+ /**
+ * 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 AnimatableStringValue(target, "");
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ return string;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableTransformListValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableTransformListValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableTransformListValue.java
new file mode 100644
index 0000000..c67cd37
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableTransformListValue.java
@@ -0,0 +1,611 @@
+/*
+
+ 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 java.util.Iterator;
+import java.util.Vector;
+import java.util.List;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+import org.apache.flex.forks.batik.dom.svg.AbstractSVGTransform;
+import org.apache.flex.forks.batik.dom.svg.SVGOMTransform;
+
+import org.w3c.dom.svg.SVGMatrix;
+import org.w3c.dom.svg.SVGTransform;
+
+/**
+ * An SVG transform list value in the animation system.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableTransformListValue.java 515307 2007-03-06 21:15:58Z cam $
+ */
+public class AnimatableTransformListValue extends AnimatableValue {
+
+ /**
+ * Identity transform value of type 'skewX'.
+ */
+ protected static SVGOMTransform IDENTITY_SKEWX = new SVGOMTransform();
+
+ /**
+ * Identity transform value of type 'skewY'.
+ */
+ protected static SVGOMTransform IDENTITY_SKEWY = new SVGOMTransform();
+
+ /**
+ * Identity transform value of type 'scale'.
+ */
+ protected static SVGOMTransform IDENTITY_SCALE = new SVGOMTransform();
+
+ /**
+ * Identity transform value of type 'rotate'.
+ */
+ protected static SVGOMTransform IDENTITY_ROTATE = new SVGOMTransform();
+
+ /**
+ * Identity transform value of type 'translate'.
+ */
+ protected static SVGOMTransform IDENTITY_TRANSLATE = new SVGOMTransform();
+
+ static {
+ IDENTITY_SKEWX.setSkewX(0f);
+ IDENTITY_SKEWY.setSkewY(0f);
+ IDENTITY_SCALE.setScale(0f, 0f);
+ IDENTITY_ROTATE.setRotate(0f, 0f, 0f);
+ IDENTITY_TRANSLATE.setTranslate(0f, 0f);
+ }
+
+ /**
+ * List of transforms.
+ */
+ protected Vector transforms;
+
+ /**
+ * Creates a new, uninitialized AnimatableTransformListValue.
+ */
+ protected AnimatableTransformListValue(AnimationTarget target) {
+ super(target);
+ }
+
+ /**
+ * Creates a new AnimatableTransformListValue with a single transform.
+ */
+ public AnimatableTransformListValue(AnimationTarget target,
+ AbstractSVGTransform t) {
+ super(target);
+ this.transforms = new Vector();
+ this.transforms.add(t);
+ }
+
+ /**
+ * Creates a new AnimatableTransformListValue with a transform list.
+ */
+ public AnimatableTransformListValue(AnimationTarget target,
+ List transforms) {
+ super(target);
+
+ this.transforms = new Vector( transforms );
+
+ }
+
+ /**
+ * Performs interpolation to the given value.
+ */
+ public AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier) {
+
+ AnimatableTransformListValue toTransformList =
+ (AnimatableTransformListValue) to;
+ AnimatableTransformListValue accTransformList =
+ (AnimatableTransformListValue) accumulation;
+
+ int accSize = accumulation == null ? 0 : accTransformList.transforms.size();
+ int newSize = transforms.size() + accSize * multiplier;
+
+ AnimatableTransformListValue res;
+ if (result == null) {
+ res = new AnimatableTransformListValue(target);
+ res.transforms = new Vector(newSize);
+ res.transforms.setSize(newSize);
+ } else {
+ res = (AnimatableTransformListValue) result;
+ if (res.transforms == null) {
+ res.transforms = new Vector(newSize);
+ res.transforms.setSize(newSize);
+ } else if (res.transforms.size() != newSize) {
+ res.transforms.setSize(newSize);
+ }
+ }
+
+ int index = 0;
+ for (int j = 0; j < multiplier; j++) {
+ for (int i = 0; i < accSize; i++, index++) {
+ res.transforms.setElementAt
+ (accTransformList.transforms.elementAt(i), index);
+ }
+ }
+ for (int i = 0; i < transforms.size() - 1; i++, index++) {
+ res.transforms.setElementAt(transforms.elementAt(i), index);
+ }
+
+ if (to != null) {
+ AbstractSVGTransform tt =
+ (AbstractSVGTransform) toTransformList.transforms.lastElement();
+ AbstractSVGTransform ft = null;
+ int type;
+ if (transforms.isEmpty()) {
+ // For the case of an additive animation with an underlying
+ // transform list of zero elements.
+ type = tt.getType();
+ switch (type) {
+ case SVGTransform.SVG_TRANSFORM_SKEWX:
+ ft = IDENTITY_SKEWX;
+ break;
+ case SVGTransform.SVG_TRANSFORM_SKEWY:
+ ft = IDENTITY_SKEWY;
+ break;
+ case SVGTransform.SVG_TRANSFORM_SCALE:
+ ft = IDENTITY_SCALE;
+ break;
+ case SVGTransform.SVG_TRANSFORM_ROTATE:
+ ft = IDENTITY_ROTATE;
+ break;
+ case SVGTransform.SVG_TRANSFORM_TRANSLATE:
+ ft = IDENTITY_TRANSLATE;
+ break;
+ }
+ } else {
+ ft = (AbstractSVGTransform) transforms.lastElement();
+ type = ft.getType();
+ }
+ if (type == tt.getType()) {
+ AbstractSVGTransform t;
+ if (res.transforms.isEmpty()) {
+ t = new SVGOMTransform();
+ res.transforms.add(t);
+ } else {
+ t = (AbstractSVGTransform) res.transforms.elementAt(index);
+ if (t == null) {
+ t = new SVGOMTransform();
+ res.transforms.setElementAt(t, index);
+ }
+ }
+ float x, y, r = 0;
+ switch (type) {
+ case SVGTransform.SVG_TRANSFORM_SKEWX:
+ case SVGTransform.SVG_TRANSFORM_SKEWY:
+ r = ft.getAngle();
+ r += interpolation * (tt.getAngle() - r);
+ if (type == SVGTransform.SVG_TRANSFORM_SKEWX) {
+ t.setSkewX(r);
+ } else if (type == SVGTransform.SVG_TRANSFORM_SKEWY) {
+ t.setSkewY(r);
+ }
+ break;
+ case SVGTransform.SVG_TRANSFORM_SCALE: {
+ SVGMatrix fm = ft.getMatrix();
+ SVGMatrix tm = tt.getMatrix();
+ x = fm.getA();
+ y = fm.getD();
+ x += interpolation * (tm.getA() - x);
+ y += interpolation * (tm.getD() - y);
+ t.setScale(x, y);
+ break;
+ }
+ case SVGTransform.SVG_TRANSFORM_ROTATE: {
+ x = ft.getX();
+ y = ft.getY();
+ x += interpolation * (tt.getX() - x);
+ y += interpolation * (tt.getY() - y);
+ r = ft.getAngle();
+ r += interpolation * (tt.getAngle() - r);
+ t.setRotate(r, x, y);
+ break;
+ }
+ case SVGTransform.SVG_TRANSFORM_TRANSLATE: {
+ SVGMatrix fm = ft.getMatrix();
+ SVGMatrix tm = tt.getMatrix();
+ x = fm.getE();
+ y = fm.getF();
+ x += interpolation * (tm.getE() - x);
+ y += interpolation * (tm.getF() - y);
+ t.setTranslate(x, y);
+ break;
+ }
+ }
+ }
+ } else {
+ AbstractSVGTransform ft =
+ (AbstractSVGTransform) transforms.lastElement();
+ AbstractSVGTransform t =
+ (AbstractSVGTransform) res.transforms.elementAt(index);
+ if (t == null) {
+ t = new SVGOMTransform();
+ res.transforms.setElementAt(t, index);
+ }
+ t.assign(ft);
+ }
+
+ // XXX Do better checking for changes.
+ res.hasChanged = true;
+
+ return res;
+ }
+
+ /**
+ * Performs a two-way interpolation between the specified values.
+ * value[12] and to[12] must all be of the same type, either scale or
+ * translation transforms, or all null.
+ */
+ public static AnimatableTransformListValue interpolate
+ (AnimatableTransformListValue res,
+ AnimatableTransformListValue value1,
+ AnimatableTransformListValue value2,
+ AnimatableTransformListValue to1,
+ AnimatableTransformListValue to2,
+ float interpolation1,
+ float interpolation2,
+ AnimatableTransformListValue accumulation,
+ int multiplier) {
+
+ int accSize = accumulation == null ? 0 : accumulation.transforms.size();
+ int newSize = accSize * multiplier + 1;
+
+ if (res == null) {
+ res = new AnimatableTransformListValue(to1.target);
+ res.transforms = new Vector(newSize);
+ res.transforms.setSize(newSize);
+ } else {
+ if (res.transforms == null) {
+ res.transforms = new Vector(newSize);
+ res.transforms.setSize(newSize);
+ } else if (res.transforms.size() != newSize) {
+ res.transforms.setSize(newSize);
+ }
+ }
+
+ int index = 0;
+ for (int j = 0; j < multiplier; j++) {
+ for (int i = 0; i < accSize; i++, index++) {
+ res.transforms.setElementAt
+ (accumulation.transforms.elementAt(i), index);
+ }
+ }
+
+ AbstractSVGTransform ft1 =
+ (AbstractSVGTransform) value1.transforms.lastElement();
+ AbstractSVGTransform ft2 =
+ (AbstractSVGTransform) value2.transforms.lastElement();
+
+ AbstractSVGTransform t =
+ (AbstractSVGTransform) res.transforms.elementAt(index);
+ if (t == null) {
+ t = new SVGOMTransform();
+ res.transforms.setElementAt(t, index);
+ }
+
+ int type = ft1.getType();
+
+ float x, y;
+ if (type == SVGTransform.SVG_TRANSFORM_SCALE) {
+ x = ft1.getMatrix().getA();
+ y = ft2.getMatrix().getD();
+ } else {
+ x = ft1.getMatrix().getE();
+ y = ft2.getMatrix().getF();
+ }
+
+ if (to1 != null) {
+ AbstractSVGTransform tt1 =
+ (AbstractSVGTransform) to1.transforms.lastElement();
+ AbstractSVGTransform tt2 =
+ (AbstractSVGTransform) to2.transforms.lastElement();
+
+ if (type == SVGTransform.SVG_TRANSFORM_SCALE) {
+ x += interpolation1 * (tt1.getMatrix().getA() - x);
+ y += interpolation2 * (tt2.getMatrix().getD() - y);
+ } else {
+ x += interpolation1 * (tt1.getMatrix().getE() - x);
+ y += interpolation2 * (tt2.getMatrix().getF() - y);
+ }
+ }
+
+ if (type == SVGTransform.SVG_TRANSFORM_SCALE) {
+ t.setScale(x, y);
+ } else {
+ t.setTranslate(x, y);
+ }
+
+ // XXX Do better checking for changes.
+ res.hasChanged = true;
+
+ return res;
+ }
+
+ /**
+ * Performs a three-way interpolation between the specified values.
+ * value[123] and to[123] must all be single rotation transforms,
+ * or all null.
+ */
+ public static AnimatableTransformListValue interpolate
+ (AnimatableTransformListValue res,
+ AnimatableTransformListValue value1,
+ AnimatableTransformListValue value2,
+ AnimatableTransformListValue value3,
+ AnimatableTransformListValue to1,
+ AnimatableTransformListValue to2,
+ AnimatableTransformListValue to3,
+ float interpolation1,
+ float interpolation2,
+ float interpolation3,
+ AnimatableTransformListValue accumulation,
+ int multiplier) {
+
+ int accSize = accumulation == null ? 0 : accumulation.transforms.size();
+ int newSize = accSize * multiplier + 1;
+
+ if (res == null) {
+ res = new AnimatableTransformListValue(to1.target);
+ res.transforms = new Vector(newSize);
+ res.transforms.setSize(newSize);
+ } else {
+ if (res.transforms == null) {
+ res.transforms = new Vector(newSize);
+ res.transforms.setSize(newSize);
+ } else if (res.transforms.size() != newSize) {
+ res.transforms.setSize(newSize);
+ }
+ }
+
+ int index = 0;
+ for (int j = 0; j < multiplier; j++) {
+ for (int i = 0; i < accSize; i++, index++) {
+ res.transforms.setElementAt
+ (accumulation.transforms.elementAt(i), index);
+ }
+ }
+
+ AbstractSVGTransform ft1 =
+ (AbstractSVGTransform) value1.transforms.lastElement();
+ AbstractSVGTransform ft2 =
+ (AbstractSVGTransform) value2.transforms.lastElement();
+ AbstractSVGTransform ft3 =
+ (AbstractSVGTransform) value3.transforms.lastElement();
+
+ AbstractSVGTransform t =
+ (AbstractSVGTransform) res.transforms.elementAt(index);
+ if (t == null) {
+ t = new SVGOMTransform();
+ res.transforms.setElementAt(t, index);
+ }
+
+ float x, y, r;
+ r = ft1.getAngle();
+ x = ft2.getX();
+ y = ft3.getY();
+
+ if (to1 != null) {
+ AbstractSVGTransform tt1 =
+ (AbstractSVGTransform) to1.transforms.lastElement();
+ AbstractSVGTransform tt2 =
+ (AbstractSVGTransform) to2.transforms.lastElement();
+ AbstractSVGTransform tt3 =
+ (AbstractSVGTransform) to3.transforms.lastElement();
+
+ r += interpolation1 * (tt1.getAngle() - r);
+ x += interpolation2 * (tt2.getX() - x);
+ y += interpolation3 * (tt3.getY() - y);
+ }
+ t.setRotate(r, x, y);
+
+ // XXX Do better checking for changes.
+ res.hasChanged = true;
+
+ return res;
+ }
+
+ /**
+ * Gets the transforms.
+ */
+ public Iterator getTransforms() {
+ return transforms.iterator();
+ }
+
+ /**
+ * 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) {
+ AnimatableTransformListValue o = (AnimatableTransformListValue) other;
+ if (transforms.isEmpty() || o.transforms.isEmpty()) {
+ return 0f;
+ }
+ AbstractSVGTransform t1 = (AbstractSVGTransform) transforms.lastElement();
+ AbstractSVGTransform t2 = (AbstractSVGTransform) o.transforms.lastElement();
+ short type1 = t1.getType();
+ if (type1 != t2.getType()) {
+ return 0f;
+ }
+ SVGMatrix m1 = t1.getMatrix();
+ SVGMatrix m2 = t2.getMatrix();
+ switch (type1) {
+ case SVGTransform.SVG_TRANSFORM_TRANSLATE:
+ return Math.abs(m1.getE() - m2.getE()) + Math.abs(m1.getF() - m2.getF());
+ case SVGTransform.SVG_TRANSFORM_SCALE:
+ return Math.abs(m1.getA() - m2.getA()) + Math.abs(m1.getD() - m2.getD());
+ case SVGTransform.SVG_TRANSFORM_ROTATE:
+ case SVGTransform.SVG_TRANSFORM_SKEWX:
+ case SVGTransform.SVG_TRANSFORM_SKEWY:
+ return Math.abs(t1.getAngle() - t2.getAngle());
+ }
+ return 0f;
+ }
+
+ /**
+ * Returns the distance between this value's first component and the
+ * specified other value's first component.
+ */
+ public float distanceTo1(AnimatableValue other) {
+ AnimatableTransformListValue o = (AnimatableTransformListValue) other;
+ if (transforms.isEmpty() || o.transforms.isEmpty()) {
+ return 0f;
+ }
+ AbstractSVGTransform t1 = (AbstractSVGTransform) transforms.lastElement();
+ AbstractSVGTransform t2 = (AbstractSVGTransform) o.transforms.lastElement();
+ short type1 = t1.getType();
+ if (type1 != t2.getType()) {
+ return 0f;
+ }
+ SVGMatrix m1 = t1.getMatrix();
+ SVGMatrix m2 = t2.getMatrix();
+ switch (type1) {
+ case SVGTransform.SVG_TRANSFORM_TRANSLATE:
+ return Math.abs(m1.getE() - m2.getE());
+ case SVGTransform.SVG_TRANSFORM_SCALE:
+ return Math.abs(m1.getA() - m2.getA());
+ case SVGTransform.SVG_TRANSFORM_ROTATE:
+ case SVGTransform.SVG_TRANSFORM_SKEWX:
+ case SVGTransform.SVG_TRANSFORM_SKEWY:
+ return Math.abs(t1.getAngle() - t2.getAngle());
+ }
+ return 0f;
+ }
+
+ /**
+ * Returns the distance between this value's second component and the
+ * specified other value's second component.
+ */
+ public float distanceTo2(AnimatableValue other) {
+ AnimatableTransformListValue o = (AnimatableTransformListValue) other;
+ if (transforms.isEmpty() || o.transforms.isEmpty()) {
+ return 0f;
+ }
+ AbstractSVGTransform t1 = (AbstractSVGTransform) transforms.lastElement();
+ AbstractSVGTransform t2 = (AbstractSVGTransform) o.transforms.lastElement();
+ short type1 = t1.getType();
+ if (type1 != t2.getType()) {
+ return 0f;
+ }
+ SVGMatrix m1 = t1.getMatrix();
+ SVGMatrix m2 = t2.getMatrix();
+ switch (type1) {
+ case SVGTransform.SVG_TRANSFORM_TRANSLATE:
+ return Math.abs(m1.getF() - m2.getF());
+ case SVGTransform.SVG_TRANSFORM_SCALE:
+ return Math.abs(m1.getD() - m2.getD());
+ case SVGTransform.SVG_TRANSFORM_ROTATE:
+ return Math.abs(t1.getX() - t2.getX());
+ }
+ return 0f;
+ }
+
+ /**
+ * Returns the distance between this value's third component and the
+ * specified other value's third component.
+ */
+ public float distanceTo3(AnimatableValue other) {
+ AnimatableTransformListValue o = (AnimatableTransformListValue) other;
+ if (transforms.isEmpty() || o.transforms.isEmpty()) {
+ return 0f;
+ }
+ AbstractSVGTransform t1 = (AbstractSVGTransform) transforms.lastElement();
+ AbstractSVGTransform t2 = (AbstractSVGTransform) o.transforms.lastElement();
+ short type1 = t1.getType();
+ if (type1 != t2.getType()) {
+ return 0f;
+ }
+ if (type1 == SVGTransform.SVG_TRANSFORM_ROTATE) {
+ return Math.abs(t1.getY() - t2.getY());
+ }
+ return 0f;
+ }
+
+ /**
+ * Returns a zero value of this AnimatableValue's type. This returns an
+ * empty transform list.
+ */
+ public AnimatableValue getZeroValue() {
+ return new AnimatableTransformListValue(target, new Vector(5));
+ }
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String toStringRep() {
+ StringBuffer sb = new StringBuffer();
+ Iterator i = transforms.iterator();
+ while (i.hasNext()) {
+ AbstractSVGTransform t = (AbstractSVGTransform) i.next();
+ if (t == null) {
+ sb.append("null");
+ } else {
+ SVGMatrix m = t.getMatrix();
+ switch (t.getType()) {
+ case SVGTransform.SVG_TRANSFORM_TRANSLATE:
+ sb.append("translate(");
+ sb.append(m.getE());
+ sb.append(',');
+ sb.append(m.getF());
+ sb.append(')');
+ break;
+ case SVGTransform.SVG_TRANSFORM_SCALE:
+ sb.append("scale(");
+ sb.append(m.getA());
+ sb.append(',');
+ sb.append(m.getD());
+ sb.append(')');
+ break;
+ case SVGTransform.SVG_TRANSFORM_SKEWX:
+ sb.append("skewX(");
+ sb.append(t.getAngle());
+ sb.append(')');
+ break;
+ case SVGTransform.SVG_TRANSFORM_SKEWY:
+ sb.append("skewY(");
+ sb.append(t.getAngle());
+ sb.append(')');
+ break;
+ case SVGTransform.SVG_TRANSFORM_ROTATE:
+ sb.append("rotate(");
+ sb.append(t.getAngle());
+ sb.append(',');
+ sb.append(t.getX());
+ sb.append(',');
+ sb.append(t.getY());
+ sb.append(')');
+ break;
+ }
+ }
+ if (i.hasNext()) {
+ 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/AnimatableValue.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableValue.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableValue.java
new file mode 100644
index 0000000..ee2a4c3
--- /dev/null
+++ b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/anim/values/AnimatableValue.java
@@ -0,0 +1,134 @@
+/*
+
+ 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 java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
+
+import org.apache.flex.forks.batik.dom.anim.AnimationTarget;
+
+/**
+ * An abstract class for values in the animation engine.
+ *
+ * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
+ * @version $Id: AnimatableValue.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public abstract class AnimatableValue {
+
+ /**
+ * A formatting object to get CSS compatible float strings.
+ */
+ protected static DecimalFormat decimalFormat = new DecimalFormat
+ ("0.0###########################################################",
+ new DecimalFormatSymbols(Locale.ENGLISH));
+
+ /**
+ * The target of the animation.
+ */
+ protected AnimationTarget target;
+
+ /**
+ * Whether this value has changed since the last call to
+ * {@link #hasChanged()}. This must be updated within {@link #interpolate}
+ * in descendant classes.
+ */
+ protected boolean hasChanged = true;
+
+ /**
+ * Creates a new AnimatableValue.
+ */
+ protected AnimatableValue(AnimationTarget target) {
+ this.target = target;
+ }
+
+ /**
+ * Returns a CSS compatible string version of the specified float.
+ */
+ public static String formatNumber(float f) {
+ return decimalFormat.format(f);
+ }
+
+ /**
+ * 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
+ * @param multiplier an amount the accumulation values should be multiplied
+ * by before being added to the interpolated value
+ */
+ public abstract AnimatableValue interpolate(AnimatableValue result,
+ AnimatableValue to,
+ float interpolation,
+ AnimatableValue accumulation,
+ int multiplier);
+
+ /**
+ * Returns whether two values of this type can have their distance
+ * computed, as needed by paced animation.
+ */
+ public abstract boolean canPace();
+
+ /**
+ * Returns the absolute distance between this value and the specified other
+ * value.
+ */
+ public abstract float distanceTo(AnimatableValue other);
+
+ /**
+ * Returns a zero value of this AnimatableValue's type.
+ */
+ public abstract AnimatableValue getZeroValue();
+
+ /**
+ * Returns the CSS text representation of the value.
+ */
+ public String getCssText() {
+ return null;
+ }
+
+ /**
+ * Returns whether the value in this AnimatableValue has been modified.
+ */
+ public boolean hasChanged() {
+ boolean ret = hasChanged;
+ hasChanged = false;
+ return ret;
+ }
+
+ /**
+ * Returns a string representation of this object. This should be
+ * overridden in classes that do not have a CSS representation.
+ */
+ public String toStringRep() {
+ return getCssText();
+ }
+
+ /**
+ * Returns a string representation of this object prefixed with its
+ * class name.
+ */
+ public String toString() {
+ return getClass().getName() + "[" + toStringRep() + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/DefaultSVGConverterController.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/DefaultSVGConverterController.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/DefaultSVGConverterController.java
deleted file mode 100644
index 4b3f013..0000000
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/DefaultSVGConverterController.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
-
- Copyright 2001,2003 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.flex.forks.batik.apps.rasterizer;
-
-import java.io.File;
-import java.util.Map;
-import java.util.Vector;
-
-import org.apache.flex.forks.batik.transcoder.Transcoder;
-
-/**
- * Default controller for the
- * <tt>SVGConverter</tt> operation.
- *
- * @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
- * @version $Id: DefaultSVGConverterController.java,v 1.5 2004/08/18 07:12:25 vhardy Exp $
- */
-public class DefaultSVGConverterController implements SVGConverterController {
- /**
- * Invoked when the rasterizer has computed the
- * exact description of what it should do. The controller
- * should return true if the transcoding process should
- * proceed or false otherwise.
- *
- * @param transcoder Transcoder which will be used for the conversion
- * @param hints set of hints that were set on the transcoder
- * @param sources list of SVG sources it will convert.
- * @param dest list of destination file it will use
- */
- public boolean proceedWithComputedTask(Transcoder transcoder,
- Map hints,
- Vector sources,
- Vector dest){
- return true;
- }
-
- /**
- * Invoked when the rasterizer is about to start transcoding
- * of a given source.
- * The controller should return true if the source should be
- * transcoded and false otherwise.
- */
- public boolean proceedWithSourceTranscoding(SVGConverterSource source,
- File dest) {
- System.out.println("About to transcoder source of type: " + source.getClass().getName());
- return true;
- }
-
- /**
- * Invoked when the rasterizer got an error while
- * transcoding the input source.
- * The controller should return true if the transcoding process
- * should continue on other sources and it should return false
- * if it should not.
- *
- * @param errorCode see the {@link SVGConverter} error code descriptions.
- */
- public boolean proceedOnSourceTranscodingFailure(SVGConverterSource source,
- File dest,
- String errorCode){
- return true;
- }
-
- /**
- * Invoked when the rasterizer successfully transcoded
- * the input source.
- */
- public void onSourceTranscodingSuccess(SVGConverterSource source,
- File dest){
- }
-}
-
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/DestinationType.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/DestinationType.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/DestinationType.java
deleted file mode 100644
index 4561ce8..0000000
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/DestinationType.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
-
- Copyright 2001,2003 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.flex.forks.batik.apps.rasterizer;
-
-import org.apache.flex.forks.batik.transcoder.Transcoder;
-import org.apache.flex.forks.batik.transcoder.image.JPEGTranscoder;
-import org.apache.flex.forks.batik.transcoder.image.PNGTranscoder;
-import org.apache.flex.forks.batik.transcoder.image.TIFFTranscoder;
-
-/**
- * Describes the type of destination for an <tt>SVGConverter</tt>
- * operation.
- *
- * @author Henri Ruini
- * @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
- * @version $Id: DestinationType.java,v 1.6 2005/03/27 08:58:29 cam Exp $
- */
-public final class DestinationType {
- public static final String PNG_STR = "image/png";
- public static final String JPEG_STR = "image/jpeg";
- public static final String TIFF_STR = "image/tiff";
- public static final String PDF_STR = "application/pdf";
-
- public static final int PNG_CODE = 0;
- public static final int JPEG_CODE = 1;
- public static final int TIFF_CODE = 2;
- public static final int PDF_CODE = 3;
-
- public static final String PNG_EXTENSION = ".png";
- public static final String JPEG_EXTENSION = ".jpg";
- public static final String TIFF_EXTENSION = ".tif";
- public static final String PDF_EXTENSION = ".pdf";
-
- public static final DestinationType PNG
- = new DestinationType(PNG_STR, PNG_CODE, PNG_EXTENSION);
- public static final DestinationType JPEG
- = new DestinationType(JPEG_STR, JPEG_CODE, JPEG_EXTENSION);
- public static final DestinationType TIFF
- = new DestinationType(TIFF_STR, TIFF_CODE, TIFF_EXTENSION);
- public static final DestinationType PDF
- = new DestinationType(PDF_STR, PDF_CODE, PDF_EXTENSION);
-
- private String type;
- private int code;
- private String extension;
-
- private DestinationType(String type, int code, String extension){
- this.type = type;
- this.code = code;
- this.extension = extension;
- }
-
- public String getExtension(){
- return extension;
- }
-
- public String toString(){
- return type;
- }
-
- public int toInt(){
- return code;
- }
-
- /**
- * Returns a transcoder object of the result image type.
- *
- * @return Transcoder object or <tt>null</tt> if there isn't a proper transcoder.
- */
- protected Transcoder getTranscoder(){
- switch(code) {
- case PNG_CODE:
- return new PNGTranscoder();
- case JPEG_CODE:
- return new JPEGTranscoder();
- case TIFF_CODE:
- return new TIFFTranscoder();
- case PDF_CODE:
- try {
- Class pdfClass = Class.forName("org.apache.fop.svg.PDFTranscoder");
- return (Transcoder)pdfClass.newInstance();
- } catch(Exception e) {
- return null;
- }
- default:
- return null;
- }
-
- }
-
- /**
- * Defines valid image types.
- *
- * @return Array of valid values as strings.
- */
- public DestinationType[] getValues() {
- return new DestinationType[]{PNG, JPEG, TIFF, PDF};
- }
-
- public Object readResolve(){
- switch(code){
- case PNG_CODE:
- return PNG;
- case JPEG_CODE:
- return JPEG;
- case TIFF_CODE:
- return TIFF;
- case PDF_CODE:
- return PDF;
- default:
- throw new Error();
- }
- }
-}