summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/kitfox/salamander/svg/coordSystems
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/kitfox/salamander/svg/coordSystems')
-rwxr-xr-xsrc/main/java/com/kitfox/salamander/svg/coordSystems/SVGAnimatedPreserveAspectRatio.java22
-rwxr-xr-xsrc/main/java/com/kitfox/salamander/svg/coordSystems/SVGAnimatedTransformList.java21
-rwxr-xr-xsrc/main/java/com/kitfox/salamander/svg/coordSystems/SVGMatrix.java127
-rwxr-xr-xsrc/main/java/com/kitfox/salamander/svg/coordSystems/SVGPreserveAspectRatio.java89
-rwxr-xr-xsrc/main/java/com/kitfox/salamander/svg/coordSystems/SVGTransform.java102
-rwxr-xr-xsrc/main/java/com/kitfox/salamander/svg/coordSystems/SVGTransformList.java36
6 files changed, 397 insertions, 0 deletions
diff --git a/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGAnimatedPreserveAspectRatio.java b/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGAnimatedPreserveAspectRatio.java
new file mode 100755
index 0000000..35f84f5
--- /dev/null
+++ b/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGAnimatedPreserveAspectRatio.java
@@ -0,0 +1,22 @@
+/*
+ * SVGAnimatedPreserveAspectRatio.java
+ *
+ * Created on April 12, 2007, 3:46 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package com.kitfox.salamander.svg.coordSystems;
+
+import com.kitfox.salamander.svg.basic.SVGAnimatedDataType;
+
+/**
+ *
+ * Used for attributes of type SVGPreserveAspectRatio which can be animated.
+ * @author kitfox
+ */
+public interface SVGAnimatedPreserveAspectRatio extends SVGAnimatedDataType<SVGPreserveAspectRatio>
+{
+
+}
diff --git a/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGAnimatedTransformList.java b/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGAnimatedTransformList.java
new file mode 100755
index 0000000..b97b70e
--- /dev/null
+++ b/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGAnimatedTransformList.java
@@ -0,0 +1,21 @@
+/*
+ * SVGAnimatedTransformList.java
+ *
+ * Created on April 12, 2007, 2:19 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package com.kitfox.salamander.svg.coordSystems;
+
+import com.kitfox.salamander.svg.basic.SVGAnimatedDataType;
+
+/**
+ *
+ * Used for the various attributes which specify a set of transformations, such as the transform attribute which is available for many of SVG's elements, and which can be animated.
+ * @author kitfox
+ */
+public interface SVGAnimatedTransformList extends SVGAnimatedDataType<SVGTransformList>
+{
+}
diff --git a/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGMatrix.java b/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGMatrix.java
new file mode 100755
index 0000000..160fd28
--- /dev/null
+++ b/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGMatrix.java
@@ -0,0 +1,127 @@
+/*
+ * SVGMatrix.java
+ *
+ * Created on April 12, 2007, 1:35 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package com.kitfox.salamander.svg.coordSystems;
+
+import com.kitfox.salamander.svg.SVGException;
+import com.kitfox.salamander.svg.basic.SVGDataType;
+
+/**
+ * Many of SVG's graphics operations utilize 2x3 matrices of the form:
+ *
+ * <CODE>
+ * [a c e]
+ * [b d f]
+ * </CODE>
+ *
+ * which, when expanded into a 3x3 matrix for the purposes of matrix arithmetic, become:
+ *
+ * <CODE>
+ * [a c e]
+ * [b d f]
+ * [0 0 1]
+ * </CODE>
+ * @author kitfox
+ */
+public interface SVGMatrix extends SVGDataType
+{
+ /**
+ * The a component of the matrix.
+ */
+ public float getA();
+ /**
+ * The b component of the matrix.
+ */
+ public float getB();
+ /**
+ * The c component of the matrix.
+ */
+ public float getC();
+ /**
+ * The d component of the matrix.
+ */
+ public float getD();
+ /**
+ * The e component of the matrix.
+ */
+ public float getE();
+ /**
+ * The f component of the matrix.
+ */
+ public float getF();
+
+ /**
+ * Performs matrix multiplication. This matrix is post-multiplied by another matrix, returning the resulting new matrix.
+ * @param secondMatrix The matrix which is post-multiplied to this matrix.
+ * @return The resulting matrix.
+ */
+ public SVGMatrix multiply(SVGMatrix secondMatrix);
+ /**
+ * Returns the inverse matrix.
+ * @return The inverse matrix.
+ * @throws com.kitfox.salamander.svg.SVGException SVG_MATRIX_NOT_INVERTABLE: Raised if this matrix is not invertable.
+ */
+ public SVGMatrix inverse() throws SVGException;
+ /**
+ * Post-multiplies a translation transformation on the current matrix and returns the resulting matrix.
+ * @param x The distance to translate along the x-axis.
+ * @param y The distance to translate along the y-axis.
+ * @return The resulting matrix.
+ */
+ public SVGMatrix translate(float x, float y);
+ /**
+ * Post-multiplies a uniform scale transformation on the current matrix and returns the resulting matrix.
+ * @param scaleFactor Scale factor in both X and Y.
+ * @return The resulting matrix.
+ */
+ public SVGMatrix scale(float scaleFactor);
+ /**
+ * Post-multiplies a non-uniform scale transformation on the current matrix and returns the resulting matrix.
+ * @param scaleFactorX Scale factor in X.
+ * @param scaleFactorY Scale factor in Y.
+ * @return The resulting matrix.
+ */
+ public SVGMatrix scaleNonUniform(float scaleFactorX, float scaleFactorY);
+ /**
+ * Post-multiplies a rotation transformation on the current matrix and returns the resulting matrix.
+ * @param angle Rotation angle.
+ * @return The resulting matrix.
+ */
+ public SVGMatrix rotate(float angle);
+ /**
+ * Post-multiplies a rotation transformation on the current matrix and returns the resulting matrix. The rotation angle is determined by taking (+/-) atan(y/x). The direction of the vector (x,y) determines whether the positive or negative angle value is used.
+ * @param x The X coordinate of the vector (x,y). Must not be zero.
+ * @param y The Y coordinate of the vector (x,y). Must not be zero.
+ * @return The resulting matrix.
+ * @throws com.kitfox.salamander.svg.SVGException SVG_INVALID_VALUE_ERR: Raised if one of the parameters has an invalid value.
+ */
+ public SVGMatrix rotateFromVector(float x, float y) throws SVGException;
+ /**
+ * Post-multiplies the transformation [-1 0 0 1 0 0] and returns the resulting matrix.
+ * @return The resulting matrix.
+ */
+ public SVGMatrix flipX();
+ /**
+ * Post-multiplies the transformation [1 0 0 -1 0 0] and returns the resulting matrix.
+ * @return The resulting matrix.
+ */
+ public SVGMatrix flipY();
+ /**
+ * Post-multiplies a skewX transformation on the current matrix and returns the resulting matrix.
+ * @param angle Skew angle.
+ * @return The resulting matrix.
+ */
+ public SVGMatrix skewX(float angle);
+ /**
+ * Post-multiplies a skewY transformation on the current matrix and returns the resulting matrix.
+ * @param angle Skew angle.
+ * @return The resulting matrix.
+ */
+ public SVGMatrix skewY(float angle);
+}
diff --git a/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGPreserveAspectRatio.java b/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGPreserveAspectRatio.java
new file mode 100755
index 0000000..5db5c16
--- /dev/null
+++ b/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGPreserveAspectRatio.java
@@ -0,0 +1,89 @@
+/*
+ * SVGPreserveAspectRatio.java
+ *
+ * Created on April 12, 2007, 3:47 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package com.kitfox.salamander.svg.coordSystems;
+
+import com.kitfox.salamander.svg.basic.SVGDataType;
+
+/**
+ * The SVGPreserveAspectRatio interface corresponds to the preserveAspectRatio attribute, which is available for some of SVG's elements.
+ * @author kitfox
+ */
+public interface SVGPreserveAspectRatio extends SVGDataType
+{
+ public static enum Type {
+ /**
+ * The enumeration was set to a value that is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.
+ */
+ UNKNOWN,
+ /**
+ * Corresponds to value 'none' for attribute preserveAspectRatio.
+ */
+ NONE,
+ /**
+ * Corresponds to value 'xMinYMin' for attribute preserveAspectRatio.
+ */
+ X_MIN_Y_MIN,
+ /**
+ * Corresponds to value 'xMidYMin' for attribute preserveAspectRatio.
+ */
+ X_MID_Y_MIN,
+ /**
+ * Corresponds to value 'xMaxYMin' for attribute preserveAspectRatio.
+ */
+ X_MAX_Y_MIN,
+ /**
+ * Corresponds to value 'xMinYMid' for attribute preserveAspectRatio.
+ */
+ X_MIN_Y_MID,
+ /**
+ * Corresponds to value 'xMidYMid' for attribute preserveAspectRatio.
+ */
+ X_MID_Y_MID,
+ /**
+ * Corresponds to value 'xMaxYMid' for attribute preserveAspectRatio.
+ */
+ X_MAX_Y_MID,
+ /**
+ * Corresponds to value 'xMinYMax' for attribute preserveAspectRatio.
+ */
+ X_MIN_Y_MAX,
+ /**
+ * Corresponds to value 'xMidYMax' for attribute preserveAspectRatio.
+ */
+ X_MID_Y_MAX,
+ /**
+ * Corresponds to value 'xMaxYMax' for attribute preserveAspectRatio.
+ */
+ X_MAX_Y_MAX,
+ };
+
+ public static enum MeetOrSlice {
+ /**
+ * The enumeration was set to a value that is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.
+ */
+ UNKNOWN,
+ /**
+ * Corresponds to value 'meet' for attribute preserveAspectRatio.
+ */
+ MEET,
+ /**
+ * Corresponds to value 'slice' for attribute preserveAspectRatio.
+ */
+ SLICE};
+
+ /**
+ * The type of the alignment value as specified by one of the constants specified above.
+ */
+ public Type getAlign();
+ /**
+ * The type of the meet-or-slice value as specified by one of the constants specified above.
+ */
+ public MeetOrSlice getMeetOrSlice();
+}
diff --git a/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGTransform.java b/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGTransform.java
new file mode 100755
index 0000000..029ce47
--- /dev/null
+++ b/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGTransform.java
@@ -0,0 +1,102 @@
+/*
+ * SVGTransform.java
+ *
+ * Created on April 12, 2007, 1:26 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package com.kitfox.salamander.svg.coordSystems;
+
+import com.kitfox.salamander.svg.basic.SVGDataType;
+
+/**
+ * SVGTransform is the interface for one of the component transformations within a SVGTransformList; thus, a SVGTransform object corresponds to a single component (e.g., "scale(..)" or "matrix(...)") within a transform attribute specification.
+ * @author kitfox
+ */
+public interface SVGTransform extends SVGDataType
+{
+ public static enum Type {
+ /**
+ * The unit type is not one of predefined types. It is invalid to attempt to define a new value of this type or to attempt to switch an existing value to this type.
+ */
+ UNKNOWN,
+ /**
+ * A "matrix(...)" transformation.
+ */
+ MATRIX,
+ /**
+ * A "translate(...)" transformation.
+ */
+ TRANSLATE,
+ /**
+ * A "scale(...)" transformation.
+ */
+ SCALE,
+ /**
+ * A "rotate(...)" transformation.
+ */
+ ROTATE,
+ /**
+ * A "skewX(...)" transformation.
+ */
+ SKEWX,
+ /**
+ * A "skewY(...)" transformation.
+ */
+ SKEWY};
+
+ /**
+ * The type of the value as specified by one of the constants specified above.
+ */
+ public Type getType();
+ /**
+ * The matrix that represents this transformation.
+ * For SVG_TRANSFORM_MATRIX, the matrix contains the a, b, c, d, e, f values supplied by the user.
+ * For SVG_TRANSFORM_TRANSLATE, e and f represent the translation amounts (a=1,b=0,c=0,d=1).
+ * For SVG_TRANSFORM_SCALE, a and d represent the scale amounts (b=0,c=0,e=0,f=0).
+ * For SVG_TRANSFORM_ROTATE, SVG_TRANSFORM_SKEWX and SVG_TRANSFORM_SKEWY, a, b, c and d represent the matrix which will result in the given transformation (e=0,f=0).
+ */
+ public SVGMatrix getMatrix();
+ /**
+ * A convenience attribute for SVG_TRANSFORM_ROTATE, SVG_TRANSFORM_SKEWX and SVG_TRANSFORM_SKEWY. It holds the angle that was specified.
+ * For SVG_TRANSFORM_MATRIX, SVG_TRANSFORM_TRANSLATE and SVG_TRANSFORM_SCALE, angle will be zero.
+ */
+ public float getAngle();
+
+ /**
+ * Sets the transform type to SVG_TRANSFORM_MATRIX, with parameter matrix defining the new transformation.
+ * @param matrix The new matrix for the transformation.
+ */
+ public void setMatrix(SVGMatrix matrix);
+ /**
+ * Sets the transform type to SVG_TRANSFORM_TRANSLATE, with parameters tx and ty defining the translation amounts.
+ * @param tx The translation amount in X.
+ * @param ty The translation amount in Y.
+ */
+ public void setTranslate(float tx, float ty);
+ /**
+ * Sets the transform type to SVG_TRANSFORM_SCALE, with parameters sx and sy defining the scale amounts.
+ * @param sx The scale factor in X.
+ * @param sy The scale factor in Y.
+ */
+ public void setScale(float sx, float sy);
+ /**
+ * Sets the transform type to SVG_TRANSFORM_ROTATE, with parameter angle defining the rotation angle and parameters cx and cy defining the optional centre of rotation.
+ * @param angle The rotation angle.
+ * @param cx The x coordinate of centre of rotation.
+ * @param cy The y coordinate of centre of rotation.
+ */
+ public void setRotate(float angle, float cx, float cy);
+ /**
+ * Sets the transform type to SVG_TRANSFORM_SKEWX, with parameter angle defining the amount of skew.
+ * @param angle The skew angle.
+ */
+ public void setSkewX(float angle);
+ /**
+ * Sets the transform type to SVG_TRANSFORM_SKEWY, with parameter angle defining the amount of skew.
+ * @param angle The skew angle.
+ */
+ public void setSkewY(float angle);
+}
diff --git a/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGTransformList.java b/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGTransformList.java
new file mode 100755
index 0000000..9135385
--- /dev/null
+++ b/src/main/java/com/kitfox/salamander/svg/coordSystems/SVGTransformList.java
@@ -0,0 +1,36 @@
+/*
+ * SVGTransformList.java
+ *
+ * Created on April 12, 2007, 1:09 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package com.kitfox.salamander.svg.coordSystems;
+
+import com.kitfox.salamander.svg.basic.SVGList;
+
+
+/**
+ * <p>This interface defines a list of SVGTransform objects.</p>
+ *
+ * <p>The SVGTransformList and SVGTransform interfaces correspond to the various attributes which specify a set of transformations, such as the transform attribute which is available for many of SVG's elements.</p>
+ *
+ * <p>SVGTransformList has the same attributes and methods as other SVGxxxList interfaces. Implementers may consider using a single base class to implement the various SVGxxxList interfaces.</p>
+ * @author kitfox
+ */
+public interface SVGTransformList extends SVGList<SVGTransform>
+{
+ /**
+ * Creates an SVGTransform object which is initialized to transform of type SVG_TRANSFORM_MATRIX and whose values are the given matrix.
+ * @param matrix The matrix which defines the transformation.
+ * @return The returned SVGTransform object.
+ */
+ public SVGTransform createSVGTransformFromMatrix(SVGMatrix matrix);
+ /**
+ * Consolidates the list of separate SVGTransform objects by multiplying the equivalent transformation matrices together to result in a list consisting of a single SVGTransform object of type SVG_TRANSFORM_MATRIX.
+ * @return The resulting SVGTransform object which becomes single item in the list. If the list was empty, then a value of null is returned.
+ */
+ public SVGTransform consolidate();
+}