Package org.cip4.jdflib.datatypes
Class JDFMatrix
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.Vector<java.lang.Object>
-
- org.cip4.jdflib.datatypes.JDFNumList
-
- org.cip4.jdflib.datatypes.JDFMatrix
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<java.lang.Object>,java.util.Collection<java.lang.Object>,java.util.List<java.lang.Object>,java.util.RandomAccess,JDFBaseDataTypes
public class JDFMatrix extends JDFNumList
This class represents a transformation matrix consisting of 6 transformation values a, b, c, d, tx, ty all values are double values. The matrix looks like:[ x'] [ a b tx ] [ x ] [ m00x + m01y + m02 ] [ y'] = [ c d ty ] [ y ] = [ m10x + m11y + m12 ] [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ]
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.cip4.jdflib.datatypes.JDFNumList
JDFNumList.NormComparator, JDFNumList.VolumeComparator
-
Nested classes/interfaces inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
JDFBaseDataTypes.EnumFitsValue
-
-
Field Summary
-
Fields inherited from interface org.cip4.jdflib.datatypes.JDFBaseDataTypes
EPSILON, MAX_CMYK_COLOR, MAX_LAB_COLOR, MAX_MATRIX_DIMENSION, MAX_RECTANGLE_DIMENSION, MAX_RGB_COLOR, MAX_SHAPE_DIMENSION, MAX_XY_DIMENSION
-
-
Constructor Summary
Constructors Constructor Description JDFMatrix()constructs a matrix with all values set to 0.0 DoubleJDFMatrix(double degrees, double x, double y)constructs a matrix with all values set via arotation and a shiftJDFMatrix(double a, double b, double c, double d, double tx, double ty)constructs a new JDFMatrix with the given double valuesJDFMatrix(java.lang.String s)constructs a matrix with all values set via a StringJDFMatrix(java.util.Vector v)Deprecated.use typesafe constructorsJDFMatrix(JDFElement.EnumOrientation orientation, double w, double h)constructs a matrix with all values set via an enumerated orientationJDFMatrix(JDFMatrix matrix)copy constructorJDFMatrix(JDFNumList nl)constructs a rectangle with all values set via a JDFNumberListJDFMatrix(JDFRectangle rect)constructs a rectangle with all values set via a JDFNumberList
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JDFMatrixclone()JDFMatrixconcat(JDFMatrix m)concatinates this with mstatic JDFMatrixcreateMatrix(java.lang.String s)factory for JDFXYPair that silently returns null in case of illegal stringsbooleanequals(java.lang.Object other)equals - returns true if both JDFMatrices are equal, otherwise falsedoublegetA()getA - returns the first coordinatejava.awt.geom.AffineTransformgetAffineTransform()getAffineTransform -doublegetAngle()doublegetB()getB - returns the second coordinatedoublegetC()getC - returns the third coordinatedoublegetD()getD - returns the fourth coordinateJDFElement.EnumOrientationgetOrientation()JDFXYPairgetShift()doublegetTx()getTx - returns the tx coordinatedoublegetTy()getTy - returns the ty coordinatestatic JDFMatrixgetUnitMatrix()inthashCode()hashCode complements equals() to fulfill the equals/hashCode contractJDFMatrixinvert()inverts thisbooleanisFlip()booleanisValid()isValid - true if the size of the vector is 6 and all instances are Double typesJDFMatrixrotate(double degrees)rotate this by degrees degrees CouterClockwisevoidsetA(double p_a)setA - sets the first coordinatevoidsetAffineTransform(java.awt.geom.AffineTransform affineTrans)setAffineTransform -voidsetB(double p_b)setB - sets the second coordinatevoidsetC(double p_c)setC - sets the third coordinatevoidsetD(double p_d)setD - sets the fourth coordinateJDFMatrixsetShift(JDFXYPair point)shift this matrix by an xypairvoidsetTx(double p_tx)setTx - sets the tx coordinatevoidsetTy(double p_ty)setTy - sets the ty coordinateJDFMatrixshift(double tx, double ty)shifts Tx and Ty by the amount specifiedJDFMatrixshift(JDFXYPair point)shift this matrix by an xypairJDFRectangletransform(JDFRectangle jdfRectangle)JDFXYPairtransform(JDFXYPair inCoordinate)applies this to a point-
Methods inherited from class org.cip4.jdflib.datatypes.JDFNumList
abs, contains, containsAll, copyNumList, doubleAt, elementAt, getDouble, getDoubleList, getDoubleVector, getIntArray, getString, getString, intAt, isValidString, matches, max, min, norm, removeElementAt, replaceElementAt, scale, scale, scaleFromCM, scaleFromCM, scaleFromMM, scaleFromMM, scaleToCM, scaleToCM, scaleToMM, scaleToMM, set, setString, setX, shift, sort, subtract, toString, unify, volume
-
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, contains, containsAll, copyInto, elements, ensureCapacity, firstElement, forEach, get, indexOf, indexOf, insertElementAt, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeAllElements, removeElement, removeIf, removeRange, replaceAll, retainAll, set, setElementAt, setSize, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
-
-
-
Constructor Detail
-
JDFMatrix
public JDFMatrix()
constructs a matrix with all values set to 0.0 Double
-
JDFMatrix
@Deprecated public JDFMatrix(java.util.Vector v) throws java.util.zip.DataFormatExceptionDeprecated.use typesafe constructorsconstructs a matrix with all values set via a Vector of Double objects- Parameters:
Vector- v - the given Vector- Throws:
java.util.zip.DataFormatException- - if the Vector has not a valid format
-
JDFMatrix
public JDFMatrix(double degrees, double x, double y)constructs a matrix with all values set via arotation and a shift- Parameters:
degrees- - the rotation in degreesx- the X shifty- the Y shift- Throws:
java.util.zip.DataFormatException- - if the Vector has not a valid format
-
JDFMatrix
public JDFMatrix(JDFElement.EnumOrientation orientation, double w, double h)
constructs a matrix with all values set via an enumerated orientation- Parameters:
orientation- - the named orientationw- the width of the unrotated object to transformh- the height of the unrotated object to transform- Throws:
java.util.zip.DataFormatException- - if the Vector has not a valid format
-
JDFMatrix
public JDFMatrix(java.lang.String s) throws java.util.zip.DataFormatExceptionconstructs a matrix with all values set via a String- Parameters:
s- the given String- Throws:
java.util.zip.DataFormatException- - if the String has not a valid format
-
JDFMatrix
public JDFMatrix(JDFNumList nl) throws java.util.zip.DataFormatException
constructs a rectangle with all values set via a JDFNumberList- Parameters:
nl- the given number list- Throws:
java.util.zip.DataFormatException- - if the JDFNumberList has not a valid format
-
JDFMatrix
public JDFMatrix(JDFMatrix matrix)
copy constructor- Parameters:
matrix- the given number list
-
JDFMatrix
public JDFMatrix(JDFRectangle rect)
constructs a rectangle with all values set via a JDFNumberList- Parameters:
rect- the given number list
-
JDFMatrix
public JDFMatrix(double a, double b, double c, double d, double tx, double ty)constructs a new JDFMatrix with the given double values- Parameters:
a- position 01 of the transformation matrixb- position 02 of the transformation matrixc- position 10 of the transformation matrixd- position 11 of the transformation matrixtx- position 03 of the transformation matrixty- position 13 of the transformation matrix
-
-
Method Detail
-
getUnitMatrix
public static JDFMatrix getUnitMatrix()
- Returns:
- a copy of the unit matrix
-
clone
public JDFMatrix clone()
- Overrides:
clonein classJDFNumList- See Also:
JDFNumList.clone()
-
createMatrix
public static JDFMatrix createMatrix(java.lang.String s)
factory for JDFXYPair that silently returns null in case of illegal strings- Parameters:
s- the string to parse- Returns:
- the JDFXYPair, null if s is not compatible
-
isValid
public boolean isValid() throws java.util.zip.DataFormatExceptionisValid - true if the size of the vector is 6 and all instances are Double types- Specified by:
isValidin classJDFNumList- Returns:
- boolean - true if all instances are Double or Integer types
- Throws:
java.util.zip.DataFormatException- - if the Vector has not a valid format
-
getA
public double getA()
getA - returns the first coordinate- Returns:
- the first coordinate
-
setA
public void setA(double p_a)
setA - sets the first coordinate- Parameters:
p_a- the first coordinate
-
getB
public double getB()
getB - returns the second coordinate- Returns:
- double - the second coordinate
-
setB
public void setB(double p_b)
setB - sets the second coordinate- Parameters:
p_b- the first coordinate
-
getC
public double getC()
getC - returns the third coordinate- Returns:
- double - the third coordinate
-
setC
public void setC(double p_c)
setC - sets the third coordinate- Parameters:
p_c- the third coordinate
-
getD
public double getD()
getD - returns the fourth coordinate- Returns:
- double - the fourth coordinate
-
setD
public void setD(double p_d)
setD - sets the fourth coordinate- Parameters:
p_d- the fourth coordinate
-
getTx
public double getTx()
getTx - returns the tx coordinate- Returns:
- double - the tx coordinate
-
getShift
public JDFXYPair getShift()
- Returns:
-
getOrientation
public JDFElement.EnumOrientation getOrientation()
- Returns:
-
getAngle
public double getAngle()
- Returns:
-
isFlip
public boolean isFlip()
- Returns:
-
setTx
public void setTx(double p_tx)
setTx - sets the tx coordinate- Parameters:
p_tx- the tx coordinate
-
getTy
public double getTy()
getTy - returns the ty coordinate- Returns:
- double - the ty coordinate
-
setTy
public void setTy(double p_ty)
setTy - sets the ty coordinate- Parameters:
p_ty- the ty coordinate
-
equals
public boolean equals(java.lang.Object other)
equals - returns true if both JDFMatrices are equal, otherwise false- Specified by:
equalsin interfacejava.util.Collection<java.lang.Object>- Specified by:
equalsin interfacejava.util.List<java.lang.Object>- Overrides:
equalsin classJDFNumList- Returns:
- boolean - true if equal otherwise false
-
hashCode
public int hashCode()
hashCode complements equals() to fulfill the equals/hashCode contract- Specified by:
hashCodein interfacejava.util.Collection<java.lang.Object>- Specified by:
hashCodein interfacejava.util.List<java.lang.Object>- Overrides:
hashCodein classJDFNumList
-
getAffineTransform
public java.awt.geom.AffineTransform getAffineTransform()
getAffineTransform -- Returns:
- AffineTransform
-
setAffineTransform
public void setAffineTransform(java.awt.geom.AffineTransform affineTrans)
setAffineTransform -- Parameters:
affineTrans- matrix to be stored
-
transform
public JDFXYPair transform(JDFXYPair inCoordinate)
applies this to a point- Parameters:
inCoordinate-- Returns:
-
shift
public JDFMatrix shift(double tx, double ty)
shifts Tx and Ty by the amount specified- Parameters:
tx- shift in x directionty- shift in y direction- Returns:
-
rotate
public JDFMatrix rotate(double degrees)
rotate this by degrees degrees CouterClockwise- Parameters:
degrees- the degrees to rotate by in counterclockwise direction
-
concat
public JDFMatrix concat(JDFMatrix m)
concatinates this with m- Parameters:
m- the matrix to concatinate
-
invert
public JDFMatrix invert()
inverts this- Parameters:
m- the matrix to concatinate
-
shift
public JDFMatrix shift(JDFXYPair point)
shift this matrix by an xypair- Parameters:
point- the point to shift by
-
setShift
public JDFMatrix setShift(JDFXYPair point)
shift this matrix by an xypair- Parameters:
point- the point to shift by
-
transform
public JDFRectangle transform(JDFRectangle jdfRectangle)
-
-