public class AffineTransform extends Object implements Cloneable
AffineTransform class represents an affine transformation,
which is a combination of linear transformations such as translation,
scaling, rotation, and shearing which allows preservation of the straightness of lines.| Modifier and Type | Field and Description |
|---|---|
static int |
TYPE_FLIP
The type of affine transformation.
|
static int |
TYPE_GENERAL_ROTATION
The type of affine transformation.
|
static int |
TYPE_GENERAL_SCALE
The type of affine transformation.
|
static int |
TYPE_GENERAL_TRANSFORM
The type of affine transformation.
|
static int |
TYPE_IDENTITY
The type of affine transformation.
|
static int |
TYPE_MASK_ROTATION
The type of affine transformation.
|
static int |
TYPE_MASK_SCALE
The type of affine transformation.
|
static int |
TYPE_QUADRANT_ROTATION
The type of affine transformation.
|
static int |
TYPE_TRANSLATION
The type of affine transformation.
|
static int |
TYPE_UNIFORM_SCALE
The type of affine transformation.
|
| Constructor and Description |
|---|
AffineTransform()
Create an empty
AffineTransform instance. |
AffineTransform(AffineTransform t)
Will create a new
AffineTransform instance with the values provided from the original
AffineTransform instance. |
AffineTransform(double[] matrix)
Create an
AffineTransform instance with the values provided. |
AffineTransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
Create an
AffineTransform instance with the values provided. |
AffineTransform(float[] matrix)
Create an
AffineTransform instance with the values provided. |
| Modifier and Type | Method and Description |
|---|---|
AffineTransform |
clone()
Creates a "deep copy" of this AffineTransform, meaning the object returned by this method will be independent
of the object being cloned.
|
void |
concatenate(AffineTransform t)
Multiply matrix of two AffineTransform objects
|
AffineTransform |
createInverse()
Creates a new
AffineTransform object that is invert of this AffineTransform object. |
void |
deltaTransform(double[] src,
int srcOff,
double[] dst,
int dstOff,
int length)
Performs the delta transformation on the source array of points and stores the result in
the destination array of points.
|
Point |
deltaTransform(Point src,
Point dst)
Performs the transformation on the source point and stores the result in the destination point.
|
boolean |
equals(Object o)
Compares this AffineTransform with the specified Object.
|
double |
getDeterminant()
Gets the determinant of the matrix representation of this
AffineTransform. |
void |
getMatrix(double[] matrix)
Fills the matrix parameter with the values of this
AffineTransform instance. |
void |
getMatrix(float[] matrix)
Fills the matrix parameter with the values of this
AffineTransform instance. |
static AffineTransform |
getRotateInstance(double angle)
Get an affine transformation representing a counter-clockwise rotation over the passed angle
|
static AffineTransform |
getRotateInstance(double angle,
double x,
double y)
Get an affine transformation representing a counter-clockwise rotation over the passed angle,
using the passed point as the center of rotation
|
static AffineTransform |
getScaleInstance(double scx,
double scY)
Get a new
AffineTransform instance representing a scale over the passed values |
double |
getScaleX()
Gets the scale factor of the x-axis.
|
double |
getScaleY()
Gets the scale factor of the y-axis.
|
static AffineTransform |
getShearInstance(double shx,
double shy)
Get a new
AffineTransform instance representing a shear over the passed values |
double |
getShearX()
Gets the shear factor of the x-axis.
|
double |
getShearY()
Gets the shear factor of the y-axis.
|
static AffineTransform |
getTranslateInstance(double mx,
double my)
Get a new
AffineTransform instance representing a translation over the passed values |
double |
getTranslateX()
Gets translation factor of the x-axis.
|
double |
getTranslateY()
Gets translation factor of the y-axis.
|
int |
getType()
Method returns type of affine transformation.
|
int |
hashCode()
Returns a hash code value for the object.
|
void |
inverseTransform(double[] src,
int srcOff,
double[] dst,
int dstOff,
int length)
Performs the inverse transformation on the source array of points and stores the result
in the destination array of points.
|
void |
inverseTransform(float[] src,
int srcOff,
float[] dst,
int dstOff,
int length)
Performs the inverse transformation on the source array of points and stores the result
in the destination array of points.
|
Point |
inverseTransform(Point src,
Point dst)
Performs the inverse transformation on the source point and stores the result in the destination point.
|
boolean |
isIdentity()
Gets whether this
AffineTransform is an identity transformation. |
void |
preConcatenate(AffineTransform t)
Multiply matrix of two AffineTransform objects
|
void |
rotate(double angle)
Add a counter-clockwise rotation to this transformation
|
void |
rotate(double angle,
double px,
double py)
Add a counter-clockwise rotation to this transformation,
using the passed point as the center of rotation
|
void |
scale(double scx,
double scy) |
void |
setToIdentity()
Sets this
AffineTransform to the identity transformation. |
void |
setToRotation(double angle)
Set this affine transformation to represent a rotation over the passed angle
|
void |
setToRotation(double angle,
double px,
double py)
Set this affine transformation to represent a rotation over the passed angle,
using the passed point as the center of rotation
|
void |
setToScale(double scx,
double scy)
Sets this
AffineTransform to represent a scale transformation. |
void |
setToShear(double shx,
double shy)
Sets this
AffineTransform to represent a shear transformation. |
void |
setToTranslation(double mx,
double my)
Sets this
AffineTransform to represent a translation transformation. |
void |
setTransform(AffineTransform t)
Sets the values of this
AffineTransform instance to the values provided. |
void |
setTransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
Sets the values of this
AffineTransform instance to the values provided. |
void |
setTransform(float m00,
float m10,
float m01,
float m11,
float m02,
float m12)
Sets the values of this
AffineTransform instance to the values provided. |
void |
shear(double shx,
double shy) |
void |
transform(double[] src,
int srcOff,
double[] dst,
int dstOff,
int length)
Transform the array of points according to the values of this
AffineTransform object. |
void |
transform(double[] src,
int srcOff,
float[] dst,
int dstOff,
int length)
Transform the array of points according to the values of this
AffineTransform object. |
void |
transform(float[] src,
int srcOff,
double[] dst,
int dstOff,
int length)
Transform the array of points according to the values of this
AffineTransform object. |
void |
transform(float[] src,
int srcOff,
float[] dst,
int dstOff,
int length)
Transform the array of points according to the values of this
AffineTransform object. |
void |
transform(Point[] src,
int srcOff,
Point[] dst,
int dstOff,
int length)
Transform the array of points according to the values of this
AffineTransform object. |
Point |
transform(Point src,
Point dst)
Transform the point according to the values of this
AffineTransform object. |
void |
translate(double mx,
double my) |
public static final int TYPE_IDENTITY
getType().public static final int TYPE_TRANSLATION
getType().public static final int TYPE_UNIFORM_SCALE
getType().public static final int TYPE_GENERAL_SCALE
getType().public static final int TYPE_QUADRANT_ROTATION
getType().public static final int TYPE_GENERAL_ROTATION
getType().public static final int TYPE_GENERAL_TRANSFORM
getType().public static final int TYPE_FLIP
getType().public static final int TYPE_MASK_SCALE
getType().public static final int TYPE_MASK_ROTATION
getType().public AffineTransform()
AffineTransform instance.
The default type is for the transformation is TYPE_IDENTITYpublic AffineTransform(AffineTransform t)
AffineTransform instance with the values provided from the original
AffineTransform instance.t - The AffineTransform class to be used.public AffineTransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
AffineTransform instance with the values provided.
The default type is for the transformation is TYPE_UNKNOWNm00 - The value of the first row and first column of the matrix.m10 - The value of the second row and first column of the matrix.m01 - The value of the first row and second column of the matrix.m11 - The value of the second row and second column of the matrix.m02 - The value of the first row and third column of the matrix.m12 - The value of the second row and third column of the matrix.public AffineTransform(float[] matrix)
AffineTransform instance with the values provided.
The default type is for the transformation is TYPE_UNKNOWNmatrix - The array of values to be used for the transformation matrix.public AffineTransform(double[] matrix)
AffineTransform instance with the values provided.
The default type is for the transformation is TYPE_UNKNOWNmatrix - The array of values to be used for the transformation matrix.public int getType()
Transform matrix is m00 m01 m02 m10 m11 m12
According analytic geometry new basis vectors are (m00, m01) and (m10, m11), translation vector is (m02, m12). Original basis vectors are (1, 0) and (0, 1). Type transformations classification:
TYPE_IDENTITY - new basis equals original one and zero translation
TYPE_TRANSLATION - translation vector isn't zero
TYPE_UNIFORM_SCALE - vectors length of new basis equals
TYPE_GENERAL_SCALE - vectors length of new basis doesn't equal
TYPE_FLIP - new basis vector orientation differ from original one
TYPE_QUADRANT_ROTATION - new basis is rotated by 90, 180, 270, or 360 degrees
TYPE_GENERAL_ROTATION - new basis is rotated by arbitrary angle
TYPE_GENERAL_TRANSFORM - transformation can't be inversed
public double getScaleX()
public double getScaleY()
public double getShearX()
public double getShearY()
public double getTranslateX()
public double getTranslateY()
public boolean isIdentity()
AffineTransform is an identity transformation.true if this AffineTransform is an identity transformation, false otherwise.public void getMatrix(float[] matrix)
AffineTransform instance.matrix - the array to be filled with the values of this AffineTransform instance.public void getMatrix(double[] matrix)
AffineTransform instance.matrix - the array to be filled with the values of this AffineTransform instance.public double getDeterminant()
AffineTransform.AffineTransform.public void setTransform(float m00,
float m10,
float m01,
float m11,
float m02,
float m12)
AffineTransform instance to the values provided.
The type of the transformation is set to TYPE_UNKNOWN.m00 - The value of the first row and first column of the matrix.m10 - The value of the second row and first column of the matrix.m01 - The value of the first row and second column of the matrix.m11 - The value of the second row and second column of the matrix.m02 - The value of the first row and third column of the matrix.m12 - The value of the second row and third column of the matrix.public void setTransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
AffineTransform instance to the values provided.
The type of the transformation is set to TYPE_UNKNOWN.m00 - The value of the first row and first column of the matrix.m10 - The value of the second row and first column of the matrix.m01 - The value of the first row and second column of the matrix.m11 - The value of the second row and second column of the matrix.m02 - The value of the first row and third column of the matrix.m12 - The value of the second row and third column of the matrix.public void setTransform(AffineTransform t)
AffineTransform instance to the values provided.t - The AffineTransform instance to be used.public void setToIdentity()
AffineTransform to the identity transformation.public void setToTranslation(double mx,
double my)
AffineTransform to represent a translation transformation.mx - The value of the translation on the x-axis.my - The value of the translation on the y-axis.public void setToScale(double scx,
double scy)
AffineTransform to represent a scale transformation.scx - The value of the scale factor on the x-axis.scy - The value of the scale factor on the y-axis.public void setToShear(double shx,
double shy)
AffineTransform to represent a shear transformation.shx - The value of the shear factor on the x-axis.shy - The value of the shear factor on the y-axis.public void setToRotation(double angle)
angle - angle to rotate over in radianspublic void setToRotation(double angle,
double px,
double py)
angle - angle to rotate over in radianspx - x-coordinate of center of rotationpy - y-coordinate of center of rotationpublic static AffineTransform getTranslateInstance(double mx, double my)
AffineTransform instance representing a translation over the passed valuesmx - x-coordinate of translationmy - y-coordinate of translationAffineTransform representing the translationpublic static AffineTransform getScaleInstance(double scx, double scY)
AffineTransform instance representing a scale over the passed valuesscx - scale factor on the x-axisscY - scale factor on the y-axisAffineTransform representing the scalepublic static AffineTransform getShearInstance(double shx, double shy)
AffineTransform instance representing a shear over the passed valuesshx - shear factor on the x-axisshy - shear factor on the y-axisAffineTransform representing the shearpublic static AffineTransform getRotateInstance(double angle)
angle - angle in radians to rotate overAffineTransform representing the rotationpublic static AffineTransform getRotateInstance(double angle, double x, double y)
angle - angle in radians to rotate overx - x-coordinate of center of rotationy - y-coordinate of center of rotationAffineTransform representing the rotationpublic void translate(double mx,
double my)
public void scale(double scx,
double scy)
public void shear(double shx,
double shy)
public void rotate(double angle)
angle - angle in radians to rotate overpublic void rotate(double angle,
double px,
double py)
angle - angle in radians to rotate overpx - x-coordinate of center of rotationpy - y-coordinate of center of rotationpublic void concatenate(AffineTransform t)
t - - the AffineTransform object is a multiplier.public void preConcatenate(AffineTransform t)
t - - the AffineTransform object is a multiplicand.public AffineTransform createInverse() throws NoninvertibleTransformException
AffineTransform object that is invert of this AffineTransform object.AffineTransform object that is invert of this AffineTransform object.NoninvertibleTransformException - if this AffineTransform object cannot be inverted.public Point transform(Point src, Point dst)
AffineTransform object.src - The point to be transformed.dst - The point that will hold the result of the transformation.public void transform(Point[] src, int srcOff, Point[] dst, int dstOff, int length)
AffineTransform object.src - The array of points to be transformed.srcOff - The offset of the first point in the array.dst - The array of points that will hold the result of the transformation.dstOff - The offset of the first point in the destination array.length - The number of points to be transformed.public void transform(double[] src,
int srcOff,
double[] dst,
int dstOff,
int length)
AffineTransform object.src - The array of points to be transformed.srcOff - The offset of the first point in the array.dst - The array of points that will hold the result of the transformation.dstOff - The offset of the first point in the destination array.length - The number of points to be transformed.public void transform(float[] src,
int srcOff,
float[] dst,
int dstOff,
int length)
AffineTransform object.src - The array of points to be transformed.srcOff - The offset of the first point in the array.dst - The array of points that will hold the result of the transformation.dstOff - The offset of the first point in the destination array.length - The number of points to be transformed.public void transform(float[] src,
int srcOff,
double[] dst,
int dstOff,
int length)
AffineTransform object.src - The array of points to be transformed.srcOff - The offset of the first point in the array.dst - The array of points that will hold the result of the transformation.dstOff - The offset of the first point in the destination array.length - The number of points to be transformed.public void transform(double[] src,
int srcOff,
float[] dst,
int dstOff,
int length)
AffineTransform object.src - The array of points to be transformed.srcOff - The offset of the first point in the array.dst - The array of points that will hold the result of the transformation.dstOff - The offset of the first point in the destination array.length - The number of points to be transformed.public Point deltaTransform(Point src, Point dst)
src - The source point to be transformed.dst - The destination point that will hold the result of the transformation.public void deltaTransform(double[] src,
int srcOff,
double[] dst,
int dstOff,
int length)
src - The source array of data to be transformed.srcOff - The offset of the first point in the source array.dst - The destination array of data that will hold the result of the transformation.dstOff - The offset of the first point in the destination array.length - The number of points to be transformed.public Point inverseTransform(Point src, Point dst) throws NoninvertibleTransformException
src - The source point to be transformed.dst - The destination point that will hold the result of the transformation.NoninvertibleTransformException - if the matrix cannot be inverted.public void inverseTransform(double[] src,
int srcOff,
double[] dst,
int dstOff,
int length)
throws NoninvertibleTransformException
src - The source array of data to be transformed.srcOff - The offset of the first point in the source array.dst - The destination array of data that will hold the result of the transformation.dstOff - The offset of the first point in the destination array.length - The number of points to be transformed.NoninvertibleTransformException - if the matrix cannot be inverted.public void inverseTransform(float[] src,
int srcOff,
float[] dst,
int dstOff,
int length)
throws NoninvertibleTransformException
src - The source array of data to be transformed.srcOff - The offset of the first point in the source array.dst - The destination array of data that will hold the result of the transformation.dstOff - The offset of the first point in the destination array.length - The number of points to be transformed.NoninvertibleTransformException - if the matrix cannot be inverted.public AffineTransform clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic boolean equals(Object o)
Copyright © 1998–2025 Apryse Group NV. All rights reserved.