public class AffineTransform
extends java.lang.Object
implements java.lang.Cloneable
The AffineTransform class provides methods to create and modify
2-dimensional affine transformations.
It delegates to the AffineTransform functionality.
| Constructor and Description |
|---|
AffineTransform()
Creates a new
AffineTransform with its transformation matrix set
to the identity matrix. |
AffineTransform(double[] flatmatrix)
Creates a new
AffineTransform with its transformation matrix set
to the values of the passed-in array. |
AffineTransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
Creates a new
AffineTransform with its transformation matrix set
to the specified values. |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone() |
AffineTransform |
concatenate(AffineTransform Tx)
Concatenates this
AffineTransform and the given
AffineTransform, multiplying the transformation matrix of this
AffineTransform from the left with the transformation matrix of
the other AffineTransform. |
void |
deltaTransform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Transforms an array of
Points specified by their coordinate
values with this AffineTransform without applying the translation
components of the transformation matrix of this AffineTransform. |
Point |
deltaTransform(Point pt)
Transforms the given
Point with this AffineTransform
without applying the translation components of the transformation matrix
of this AffineTransform. |
boolean |
equals(java.lang.Object obj) |
AffineTransform |
getCopy()
Returns a copy of this
AffineTransform. |
double |
getDeterminant()
Computes the determinant of the transformation matrix of this
AffineTransform. |
AffineTransform |
getInverse()
Creates a new
AffineTransform that represents the inverse
transformation of this AffineTransform. |
double |
getM00()
Returns the matrix component in the first row and first column.
|
double |
getM01()
Returns the matrix component in the first row and second column.
|
double |
getM10()
Returns the matrix component in the second row and first column.
|
double |
getM11()
Returns the matrix component in the second row and second column.
|
double[] |
getMatrix()
Returns the 6 specifiable elements of the transformation matrix of this
AffineTransform. |
Angle |
getRotation()
Returns the rotation component of this
AffineTransform. |
double |
getScaleX()
Returns the x coordinate scaling of this
AffineTransform's
transformation matrix. |
double |
getScaleY()
Returns the y coordinate scaling of this
AffineTransform's
transformation matrix. |
Point |
getTransformed(Point ptSrc)
Transforms the given
Point with this AffineTransform by
multiplying the transformation matrix of this AffineTransform
with the given Point. |
Point[] |
getTransformed(Point[] points)
Transforms the given array of
Points with this
AffineTransform by multiplying the transformation matrix of this
AffineTransform individually with each of the given Point
s. |
double |
getTranslateX()
Returns the x coordinate translation of this
AffineTransform's
transformation matrix. |
double |
getTranslateY()
Returns the y coordinate translation of this
AffineTransform's
transformation matrix. |
int |
getType()
Returns the type of transformation represented by this
AffineTransform. |
int |
hashCode() |
void |
inverseTransform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Inverse transforms an array of
Points specified by their
coordinate values with this AffineTransform. |
Point |
inverseTransform(Point pt)
Inverse transforms the given
Point with this
AffineTransform. |
AffineTransform |
invert()
Inverts this
AffineTransform. |
boolean |
isIdentity()
Checks if the transformation matrix of this
AffineTransform
equals the identity matrix. |
AffineTransform |
preConcatenate(AffineTransform Tx)
Concatenates this
AffineTransform and the given
AffineTransform in reverse order, multiplying the transformation
matrix of this AffineTransform from the right with the
transformation matrix of the other AffineTransform. |
AffineTransform |
quadrantRotate(int numquadrants)
Adds a rotation by an integer multiple of 90deg to the transformation
matrix of this
AffineTransform. |
AffineTransform |
quadrantRotate(int numquadrants,
double anchorx,
double anchory)
Adds a rotation by an integer multiple of 90deg around the
Point
specified by the given x and y coordinates to the transformation matrix
of this AffineTransform. |
AffineTransform |
rotate(double theta)
Adds a rotation with the given angle (in radians) to the transformation
matrix of this
AffineTransform. |
AffineTransform |
rotate(double vecx,
double vecy)
Adds a rotation to the transformation matrix of this
AffineTransform. |
AffineTransform |
rotate(double theta,
double anchorx,
double anchory)
Adds a rotation with the given angle (in radians) around the
Point specified by the given x and y coordinates to the
transformation matrix of this AffineTransform. |
AffineTransform |
rotate(double vecx,
double vecy,
double anchorx,
double anchory)
Adds a rotation around a
Point to the transformation matrix of
this AffineTransform. |
AffineTransform |
scale(double sx,
double sy)
Adds an x and y scaling to the transformation matrix of this
AffineTransform. |
AffineTransform |
setToIdentity()
Sets the transformation matrix of this
AffineTransform to the
identity matrix. |
AffineTransform |
setToQuadrantRotation(int numquadrants)
Sets the transformation matrix of this
AffineTransform to a pure
rotation matrix where the rotation angle is an integer multiple of 90deg. |
AffineTransform |
setToQuadrantRotation(int numquadrants,
double anchorx,
double anchory)
Sets the transformation matrix of this
AffineTransform to a pure
rotation and translation matrix where the rotation angle is an integer
multiple of 90deg and the rotation is around the Point specified
by the given x and y coordinates. |
AffineTransform |
setToRotation(double theta)
Sets the transformation matrix of this
AffineTransform to a pure
rotation matrix by the given angle specified in radians. |
AffineTransform |
setToRotation(double vecx,
double vecy)
Sets the transformation matrix of this
AffineTransform to a pure
rotation matrix. |
AffineTransform |
setToRotation(double theta,
double anchorx,
double anchory)
Sets the transformation matrix of this
AffineTransform to a pure
rotation and translation matrix. |
AffineTransform |
setToRotation(double vecx,
double vecy,
double anchorx,
double anchory)
Sets the transformation matrix of this
AffineTransform to a pure
rotation and translation matrix. |
AffineTransform |
setToScale(double sx,
double sy)
Sets the transformation matrix of this
AffineTransform to a pure
scaling matrix. |
AffineTransform |
setToShear(double shx,
double shy)
Sets the transformation matrix of this
AffineTransform to a pure
shearing matrix. |
AffineTransform |
setToTranslation(double tx,
double ty)
Sets the transformation matrix of this
AffineTransform to a pure
translation matrix that translates Points by the given x and y
values. |
AffineTransform |
setTransform(AffineTransform Tx)
Sets the transformation matrix of this
AffineTransform to the
transformation matrix of the given AffineTransform. |
AffineTransform |
setTransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
Sets the respective values of the transformation matrix of this
AffineTransform to the supplied ones. |
AffineTransform |
shear(double shx,
double shy)
Adds an x and y shearing to the transformation matrix of this
AffineTransform. |
java.lang.String |
toString() |
AffineTransform |
translate(double tx,
double ty)
Sets the translation values of the x and y coordinates of the
transformation matrix of this
AffineTransform. |
public AffineTransform()
AffineTransform with its transformation matrix set
to the identity matrix.public AffineTransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
AffineTransform with its transformation matrix set
to the specified values. Note that rotation is a combination of shearing
and scaling.m00 - the value of the transformation matrix in row 0 and column 0
(x coordinate scaling)m10 - the value of the transformation matrix in row 1 and column 0
(y coordinate shearing)m01 - the value of the transformation matrix in row 0 and column 1
(x coordinate shearing)m11 - the value of the transformation matrix in row 1 and column 1
(y coordinate scaling)m02 - the value of the transformation matrix in row 0 and column 2
(x coordinate translation)m12 - the value of the transformation matrix in row 1 and column 2
(y coordinate translation)public AffineTransform(double[] flatmatrix)
AffineTransform with its transformation matrix set
to the values of the passed-in array. See the
AffineTransform(double, double, double, double, double, double)
or the AffineTransform.AffineTransform(double[])
method for a specification of the values in the array.flatmatrix - the values for the transformation matrixAffineTransform(double, double, double, double,
double, double)public java.lang.Object clone()
clone in class java.lang.Objectpublic AffineTransform concatenate(AffineTransform Tx)
AffineTransform and the given
AffineTransform, multiplying the transformation matrix of this
AffineTransform from the left with the transformation matrix of
the other AffineTransform.Tx - the AffineTransform that is concatenated with this
AffineTransformthis for conveniencepublic void deltaTransform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Points specified by their coordinate
values with this AffineTransform without applying the translation
components of the transformation matrix of this AffineTransform.srcPts - the array of x and y coordinates specifying the Points
that are transformedsrcOff - the index of the srcPts array where the x coordinate of
the first Point to transform is founddstPts - the destination array of x and y coordinates for the result of
the transformationdstOff - the index of the dstPts array where the x coordinate of
the first transformed Point is storednumPts - the number of Points to transformpublic Point deltaTransform(Point pt)
Point with this AffineTransform
without applying the translation components of the transformation matrix
of this AffineTransform.public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic AffineTransform getCopy()
AffineTransform.AffineTransformpublic double getDeterminant()
AffineTransform.AffineTransformpublic AffineTransform getInverse()
AffineTransform that represents the inverse
transformation of this AffineTransform.AffineTransform that represents the inverse
transformation of this AffineTransformpublic double getM00()
public double getM01()
public double getM10()
public double getM11()
public double[] getMatrix()
AffineTransform.AffineTransformpublic Angle getRotation()
AffineTransform.AffineTransform.public double getScaleX()
AffineTransform's
transformation matrix.AffineTransform's
transformation matrixpublic double getScaleY()
AffineTransform's
transformation matrix.AffineTransform's
transformation matrixpublic Point getTransformed(Point ptSrc)
Point with this AffineTransform by
multiplying the transformation matrix of this AffineTransform
with the given Point.public Point[] getTransformed(Point[] points)
Points with this
AffineTransform by multiplying the transformation matrix of this
AffineTransform individually with each of the given Point
s.public double getTranslateX()
AffineTransform's
transformation matrix.AffineTransform's
transformation matrixpublic double getTranslateY()
AffineTransform's
transformation matrix.AffineTransform's
transformation matrixpublic int getType()
AffineTransform. See the
AffineTransform.getType() method for a
specification of the return type of this method.AffineTransformpublic int hashCode()
hashCode in class java.lang.Objectpublic void inverseTransform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
throws java.awt.geom.NoninvertibleTransformException
Points specified by their
coordinate values with this AffineTransform.srcPts - the array of x and y coordinates specifying the Points
that are inverse transformedsrcOff - the index of the srcPts array where the x coordinate of
the first Point to inverse transform is founddstPts - the destination array of x and y coordinates for the result of
the inverse transformationdstOff - the index of the dstPts array where the x coordinate of
the first inverse transformed Point is storednumPts - the number of Points to inverse transformjava.awt.geom.NoninvertibleTransformException - when this AffineTransform is not invertible.public Point inverseTransform(Point pt) throws java.awt.geom.NoninvertibleTransformException
Point with this
AffineTransform.pt - the Point to inverse transformPointjava.awt.geom.NoninvertibleTransformException - when this AffineTransform is not invertible.public AffineTransform invert() throws java.awt.geom.NoninvertibleTransformException
AffineTransform.this for conveniencejava.awt.geom.NoninvertibleTransformException - when this AffineTransform is not invertible.public boolean isIdentity()
AffineTransform
equals the identity matrix.true if the transformation matrix of this
AffineTransform equals the identity matrix, otherwise
falsepublic AffineTransform preConcatenate(AffineTransform Tx)
AffineTransform and the given
AffineTransform in reverse order, multiplying the transformation
matrix of this AffineTransform from the right with the
transformation matrix of the other AffineTransform.Tx - the AffineTransform that is concatenated with this
AffineTransform in reverse orderthis for conveniencepublic AffineTransform quadrantRotate(int numquadrants)
AffineTransform. The integer multiple of 90deg is
specified by the given number of quadrants.numquadrants - the integer that defines the number of quadrants to rotate bythis for conveniencepublic AffineTransform quadrantRotate(int numquadrants, double anchorx, double anchory)
Point
specified by the given x and y coordinates to the transformation matrix
of this AffineTransform.public AffineTransform rotate(double theta)
AffineTransform.theta - the rotation angle in radiansthis for conveniencepublic AffineTransform rotate(double vecx, double vecy)
AffineTransform. The given coordinates specify a Vector
whose Angle to the x-axis is the applied rotation Angle.public AffineTransform rotate(double theta, double anchorx, double anchory)
Point specified by the given x and y coordinates to the
transformation matrix of this AffineTransform.public AffineTransform rotate(double vecx, double vecy, double anchorx, double anchory)
public AffineTransform scale(double sx, double sy)
AffineTransform.sx - the x scaling factor added to the transformation matrix of
this AffineTransformsy - the y scaling factor added to the transformation matrix of
this AffineTransformthis for conveniencepublic AffineTransform setToIdentity()
AffineTransform to the
identity matrix.this for conveniencepublic AffineTransform setToQuadrantRotation(int numquadrants)
AffineTransform to a pure
rotation matrix where the rotation angle is an integer multiple of 90deg.numquadrants - the integer that defines the number of quadrants to rotate bythis for conveniencepublic AffineTransform setToQuadrantRotation(int numquadrants, double anchorx, double anchory)
AffineTransform to a pure
rotation and translation matrix where the rotation angle is an integer
multiple of 90deg and the rotation is around the Point specified
by the given x and y coordinates.public AffineTransform setToRotation(double theta)
AffineTransform to a pure
rotation matrix by the given angle specified in radians.theta - the rotation angle (in radians)this for conveniencepublic AffineTransform setToRotation(double vecx, double vecy)
AffineTransform to a pure
rotation matrix. The given x and y coordinates specify a Vector
whose Angle to the x-axis defines the rotation Angle.public AffineTransform setToRotation(double theta, double anchorx, double anchory)
AffineTransform to a pure
rotation and translation matrix. Thus, the resulting transformation
matrix rotates Points by the given angle (in radians) around the
Point specified by the given x and y coordinates.public AffineTransform setToRotation(double vecx, double vecy, double anchorx, double anchory)
AffineTransform to a pure
rotation and translation matrix. The firstly given x and y coordinates
specify a Vector whose Angle to the x-axis defines the
rotation Angle. The secondly given x and y coordinates specify
the Point to rotate around.vecx - the x coordinate of the Vector whose Angle to
the x-axis defines the rotation Anglevecy - the y coordinate of the Vector whose Angle to
the x-axis defines the rotation Angleanchorx - the x coordinate of the Point to rotate aroundanchory - the y coordinate of the Point to rotate aroundthis for conveniencepublic AffineTransform setToScale(double sx, double sy)
AffineTransform to a pure
scaling matrix.sx - the x scaling factorsy - the y scaling factorthis for conveniencepublic AffineTransform setToShear(double shx, double shy)
AffineTransform to a pure
shearing matrix.shx - the x shearing factorshy - the y shearing factorthis for conveniencepublic AffineTransform setToTranslation(double tx, double ty)
AffineTransform to a pure
translation matrix that translates Points by the given x and y
values.tx - the x translation valuety - the y translation valuethis for conveniencepublic AffineTransform setTransform(AffineTransform Tx)
AffineTransform to the
transformation matrix of the given AffineTransform.Tx - the AffineTransform specifying the new transformation
matrix of this AffineTransformthis for conveniencepublic AffineTransform setTransform(double m00, double m10, double m01, double m11, double m02, double m12)
AffineTransform to the supplied ones. Note that rotation is a
combination of shearing and scaling.m00 - the value of the transformation matrix in row 0 and column 0
(x coordinate scaling)m10 - the value of the transformation matrix in row 1 and column 0
(y coordinate shearing)m01 - the value of the transformation matrix in row 0 and column 1
(x coordinate shearing)m11 - the value of the transformation matrix in row 1 and column 1
(y coordinate scaling)m02 - the value of the transformation matrix in row 0 and column 2
(x coordinate translation)m12 - the value of the transformation matrix in row 1 and column 2
(y coordinate translation)this for conveniencepublic AffineTransform shear(double shx, double shy)
AffineTransform.shx - the x shearing factor added to the transformation matrix of
this AffineTransformshy - the y shearing factor added to the transformation matrix of
this AffineTransformthis for conveniencepublic java.lang.String toString()
toString in class java.lang.Objectpublic AffineTransform translate(double tx, double ty)
AffineTransform.tx - the x coordinate translationty - the y coordinate translationthis for convenienceCopyright (c) 2014 itemis AG, and others. All rights reserved.