Class java.awt.geom.AffineTransform
java.lang.Object
|
+----java.awt.geom.AffineTransform
- public class AffineTransform
- extends Object
- implements Cloneable
This class represents a 2D affine transform which performs a linear
mapping from 2D coordinates to other 2D coordinates in a manner which
preserves the "straightness" and "parallelness" of lines. Affine
transformations can be constructed using sequences of translations,
scales, flips, rotations, and shears.
Such a coordinate transformation can be represented by a 3 row by
3 column matrix with an implied last row of [ 0 0 1 ] which
transforms source coordinates (x, y)
into
destination coordinates (x', y')
by considering
them to be a column vector and multiplying the coordinate vector
by the matrix according to the following process.
[ x'] [ m00 m01 m02 ] [ x ] [ m00x + m01y + m02 ]
[ y'] = [ m10 m11 m12 ] [ y ] = [ m10x + m11y + m12 ]
[ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ]
Field Summary
|
static int
|
ANY_ROTATION_MASK
This flag is a bit mask for any of the rotation flag bits.
|
static int
|
ANY_SCALE_MASK
This flag is a bit mask for any of the scale flag bits.
|
static int
|
GENERAL_ROTATION
This flag bit indicates that the transform defined by this object
performs a rotation by an arbitrary angle in addition to the
conversions indicated by other flag bits.
|
static int
|
GENERAL_SCALE
This flag bit indicates that the transform defined by this object
performs a general scale in addition to the conversions indicated
by other flag bits.
|
static int
|
GENERAL_TRANSFORM
This flag bit indicates that the transform defined by this object
performs an arbitrary conversion of the input coordinates.
|
static int
|
IDENTITY
This constant indicates that the transform defined by this object
is an identity transform.
|
static int
|
QUADRANT_ROTATION
This flag bit indicates that the transform defined by this object
performs a quadrant rotation by some multiple of 90 degrees in
addition to the conversions indicated by other flag bits.
|
static int
|
TRANSLATION
This flag bit indicates that the transform defined by this object
performs a translation in addition to the conversions indicated
by other flag bits.
|
static int
|
UNIFORM_SCALE
This flag bit indicates that the transform defined by this object
performs a uniform scale in addition to the conversions indicated
by other flag bits.
|
Constructor Summary
|
AffineTransform()
Constructs a new AffineTransform representing the Identity
transformation.
|
AffineTransform(AffineTransform Tx)
Constructs a new AffineTransform representing a copy of
another AffineTransform object.
|
AffineTransform(float m00,
float m10,
float m01,
float m11,
float m02,
float m12)
Constructs a new AffineTransform from 6 floating point values
representing the 6 specifiable entries of the 3x3 transformation matrix.
|
AffineTransform(float[] flatmatrix)
Constructs a new AffineTransform from an array of floating point
values representing either the 4 non-translation or the 6 specifiable
entries of
the 3x3 transformation matrix.
|
AffineTransform(float[][] matrix)
Constructs a new AffineTransform from a 2-dimensional array of
floating point values representing either the 4 non-translation or the
6 specifiable entries of the 3x3 transformation matrix.
|
AffineTransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
Constructs a new AffineTransform from 6 double precision values
representing the 6 specifiable entries of the 3x3 transformation matrix.
|
AffineTransform(double[] flatmatrix)
Constructs a new AffineTransform from an array of double precision
values representing either the 4 non-translation or the 6 specifiable
entries of
the 3x3 transformation matrix.
|
AffineTransform(double[][] matrix)
Constructs a new AffineTransform from a 2-dimensional array of
double precision values representing either the 4 non-translation or the
6 specifiable entries of the 3x3 transformation matrix.
|
Method Summary
|
Object
|
clone()
Returns a copy of this AffineTransform object.
|
void
|
concatenate(AffineTransform Tx)
Concatenates an AffineTransform Tx to this AffineTransform Cx
in the most commonly useful way to provide a new user space
which is mapped to the former user space by Tx.
|
AffineTransform
|
createInverse()
Returns an AffineTransform object representing the inverse
transformation.
|
Shape
|
createTransformedShape(Shape pSrc)
Transforms a shape object by this transform.
|
Point2D
|
deltaTransform(Point2D ptSrc,
Point2D ptDst)
Transforms the relative distance vector specified by ptSrc and
stores the result in ptDst.
|
void
|
deltaTransform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Transforms an array of relative distance vectors by this
transform.
|
boolean
|
equals(Object obj)
|
double
|
getDeterminant()
Returns the determinant of the matrix representation of the transform.
|
void
|
getMatrix(double[] flatmatrix)
Retrieves the 6 specifiable values in the 3x3 affine transformation
matrix into
an array of double precisions values.
|
void
|
getMatrix(double[][] matrix)
Retrieves the 6 specifiable values in the 3x3 affine transformation
matrix into
a 2-dimensional array of double precision values.
|
static AffineTransform
|
getRotateInstance(double theta)
Returns a transform representing a rotation transformation.
|
static AffineTransform
|
getRotateInstance(double theta,
double x,
double y)
Returns a transform representing a translated rotation transformation.
|
static AffineTransform
|
getScaleInstance(double sx,
double sy)
Returns a transform representing a scaling transformation.
|
double
|
getScaleX()
Returns the X coordinate scaling element (m00) of the 3x3
affine transformation matrix.
|
double
|
getScaleY()
Returns the Y coordinate scaling element (m11) of the 3x3
affine transformation matrix.
|
static AffineTransform
|
getShearInstance(double shx,
double shy)
Returns a transform representing a shearing transformation.
|
double
|
getShearX()
Returns the X coordinate shearing element (m01) of the 3x3
affine transformation matrix.
|
double
|
getShearY()
Returns the Y coordinate shearing element (m10) of the 3x3
affine transformation matrix.
|
static AffineTransform
|
getTranslateInstance(double tx,
double ty)
Returns a transform representing a translation transformation.
|
double
|
getTranslateX()
Returns the X coordinate translation element (m02) of the 3x3
affine transformation matrix.
|
double
|
getTranslateY()
Returns the Y coordinate translation element (m12) of the 3x3
affine transformation matrix.
|
int
|
getType()
Retrieves the flag bits describing the conversion properties of
this transform.
|
Point2D
|
inverseTransform(Point2D ptSrc,
Point2D ptDst)
Inverse transforms the specified ptSrc and stores the result in ptDst.
|
void
|
inverseTransform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Inverse transforms an array of double precision coordinates by
this transform.
|
boolean
|
isIdentity()
Returns the boolean true value if this AffineTransform is an
identity transform.
|
void
|
preConcatenate(AffineTransform Tx)
Concatenates an AffineTransform Tx to this AffineTransform Cx
in a less commonly used way such that Tx modifies the
coordinate transformation relative to the absolute pixel
space rather than relative to the existing user space.
|
void
|
rotate(double theta)
Concatenates this transform with a rotation transformation.
|
void
|
rotate(double theta,
double x,
double y)
Concatenates this transform with a translated rotation transformation.
|
void
|
scale(double sx,
double sy)
Concatenates this transform with a scaling transformation.
|
void
|
setToIdentity()
Resets this transform to the Identity transform.
|
void
|
setToRotation(double theta)
Sets this transform to a rotation transformation.
|
void
|
setToRotation(double theta,
double x,
double y)
Sets this transform to a translated rotation transformation.
|
void
|
setToScale(double sx,
double sy)
Sets this transform to a scaling transformation.
|
void
|
setToShear(double shx,
double shy)
Sets this transform to a shearing transformation.
|
void
|
setToTranslation(double tx,
double ty)
Sets this transform to a translation transformation.
|
void
|
setTransform(AffineTransform Tx)
Sets this transform to a copy of the transform in the indicated
AffineTransform object.
|
void
|
setTransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
Sets this transform to the matrix specified by the 6
double precision values.
|
void
|
shear(double shx,
double shy)
Concatenates this transform with a shearing transformation.
|
String
|
toString()
Returns a String that represents the value of this Object.
|
Point2D
|
transform(Point2D ptSrc,
Point2D ptDst)
Transforms the specified ptSrc and stores the result in ptDst.
|
void
|
transform(Point2D[] ptSrc,
int srcOff,
Point2D[] ptDst,
int dstOff,
int numPts)
Transforms an array of point objects by this transform.
|
void
|
transform(float[] srcPts,
int srcOff,
float[] dstPts,
int dstOff,
int numPts)
Transforms an array of floating point coordinates by this transform.
|
void
|
transform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Transforms an array of double precision coordinates by this transform.
|
void
|
transform(float[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
Transforms an array of floating point coordinates by this transform,
storing the results into an array of doubles.
|
void
|
transform(double[] srcPts,
int srcOff,
float[] dstPts,
int dstOff,
int numPts)
Transforms an array of double precision coordinates by this transform,
storing the results into an array of floats.
|
void
|
translate(double tx,
double ty)
Concatenates this transform with a translation transformation.
|
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
IDENTITY
public static final int IDENTITY
- This constant indicates that the transform defined by this object
is an identity transform.
An identity transform is one in which the output coordinates are
always the same as the input coordinates.
If this transform is anything other than the identity transform,
the type will be a combination of the appropriate flag bits for
the various coordinate conversions that this transform performs.
- See Also:
- TRANSLATION, UNIFORM_SCALE, GENERAL_SCALE, QUADRANT_ROTATION, GENERAL_ROTATION, GENERAL_TRANSFORM, getType
TRANSLATION
public static final int TRANSLATION
- This flag bit indicates that the transform defined by this object
performs a translation in addition to the conversions indicated
by other flag bits.
A translation moves the coordinates by a constant amount in x
and y without changing the length or angle of vectors.
- See Also:
- IDENTITY, UNIFORM_SCALE, GENERAL_SCALE, QUADRANT_ROTATION, GENERAL_ROTATION, GENERAL_TRANSFORM, getType
UNIFORM_SCALE
public static final int UNIFORM_SCALE
- This flag bit indicates that the transform defined by this object
performs a uniform scale in addition to the conversions indicated
by other flag bits.
A uniform scale multiplies the length of vectors by the same amount
in both the x and y directions without changing the angle between
vectors.
This flag bit is mutually exclusive with the GENERAL_SCALE flag.
- See Also:
- IDENTITY, TRANSLATION, GENERAL_SCALE, QUADRANT_ROTATION, GENERAL_ROTATION, GENERAL_TRANSFORM, getType
GENERAL_SCALE
public static final int GENERAL_SCALE
- This flag bit indicates that the transform defined by this object
performs a general scale in addition to the conversions indicated
by other flag bits.
A general scale multiplies the length of vectors by different
amounts in the x and y directions without changing the angle
between vectors.
This flag bit is mutually exclusive with the UNIFORM_SCALE flag.
- See Also:
- IDENTITY, TRANSLATION, UNIFORM_SCALE, QUADRANT_ROTATION, GENERAL_ROTATION, GENERAL_TRANSFORM, getType
ANY_SCALE_MASK
public static final int ANY_SCALE_MASK
- This flag is a bit mask for any of the scale flag bits.
QUADRANT_ROTATION
public static final int QUADRANT_ROTATION
- This flag bit indicates that the transform defined by this object
performs a quadrant rotation by some multiple of 90 degrees in
addition to the conversions indicated by other flag bits.
A rotation changes the angles of vectors by the same amount
regardless of the original direction of the vector without
changing the length of the vector.
This flag bit is mutually exclusive with the GENERAL_ROTATION flag.
- See Also:
- IDENTITY, TRANSLATION, UNIFORM_SCALE, GENERAL_SCALE, GENERAL_ROTATION, GENERAL_TRANSFORM, getType
GENERAL_ROTATION
public static final int GENERAL_ROTATION
- This flag bit indicates that the transform defined by this object
performs a rotation by an arbitrary angle in addition to the
conversions indicated by other flag bits.
A rotation changes the angles of vectors by the same amount
regardless of the original direction of the vector without
changing the length of the vector.
This flag bit is mutually exclusive with the QUADRANT_ROTATION flag.
- See Also:
- IDENTITY, TRANSLATION, UNIFORM_SCALE, GENERAL_SCALE, QUADRANT_ROTATION, GENERAL_TRANSFORM, getType
ANY_ROTATION_MASK
public static final int ANY_ROTATION_MASK
- This flag is a bit mask for any of the rotation flag bits.
GENERAL_TRANSFORM
public static final int GENERAL_TRANSFORM
- This flag bit indicates that the transform defined by this object
performs an arbitrary conversion of the input coordinates.
This flag bit is mutually exclusive with any of the other flags.
- See Also:
- IDENTITY, TRANSLATION, UNIFORM_SCALE, GENERAL_SCALE, QUADRANT_ROTATION, GENERAL_ROTATION, getType
AffineTransform
public AffineTransform()
- Constructs a new AffineTransform representing the Identity
transformation.
AffineTransform
public AffineTransform(AffineTransform Tx)
- Constructs a new AffineTransform representing a copy of
another AffineTransform object.
- Parameters:
Tx
- the AffineTransform object from which to copy the
transformation
AffineTransform
public AffineTransform(float m00,
float m10,
float m01,
float m11,
float m02,
float m12)
- Constructs a new AffineTransform from 6 floating point values
representing the 6 specifiable entries of the 3x3 transformation matrix.
AffineTransform
public AffineTransform(float[] flatmatrix)
- Constructs a new AffineTransform from an array of floating point
values representing either the 4 non-translation or the 6 specifiable
entries of
the 3x3 transformation matrix. The values are retrieved from the
array as { m00 m10 m01 m11 [m02 m12] }.
- Parameters:
flatmatrix
- The float array containing the values to be set
in the new AffineTransform object. The length of the array is
assumed to be at least 4. If the length of the array is
less than 6, only the first 4 values are taken. If the length of
the array is greater than 6, the first 6 values are taken.
AffineTransform
public AffineTransform(float[][] matrix)
- Constructs a new AffineTransform from a 2-dimensional array of
floating point values representing either the 4 non-translation or the
6 specifiable entries of the 3x3 transformation matrix. The values are
retrieved from the 2-dimensional array using the row index as
the first subscript and the column index as the second.
- Parameters:
matrix
- The matrix used to construct the new AffineTransform
object. Matrix is assumed to be at least 2x2. If the matrix
is smaller than 2x3, only the left upper 2x2 matrix is taken. If the
matrix is larger than 2x3, the left upper 2x3 matrix is taken.
AffineTransform
public AffineTransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
- Constructs a new AffineTransform from 6 double precision values
representing the 6 specifiable entries of the 3x3 transformation matrix.
AffineTransform
public AffineTransform(double[] flatmatrix)
- Constructs a new AffineTransform from an array of double precision
values representing either the 4 non-translation or the 6 specifiable
entries of
the 3x3 transformation matrix. The values are retrieved from the
array as { m00 m10 m01 m11 [m02 m12] }.
- Parameters:
flatmatrix
- The double array containing the values to be set
in the new AffineTransform object. The length of the array is
assumed to be at least 4. If the length of the array is
less than 6, only the first 4 values are taken. If the length of
the array is greater than 6, the first 6 values are taken.
AffineTransform
public AffineTransform(double[][] matrix)
- Constructs a new AffineTransform from a 2-dimensional array of
double precision values representing either the 4 non-translation or the
6 specifiable entries of the 3x3 transformation matrix. The values are
retrieved from the 2-dimensional array using the row index as
the first subscript and the column index as the second.
- Parameters:
matrix
- The matrix used to construct the new AffineTransform
object. Matrix is assumed to be at least 2x2. If the matrix
is smaller than 2x3, only the left upper 2x2 matrix is taken. If the
matrix is larger than 2x3, the left upper 2x3 matrix is taken.
getTranslateInstance
public static AffineTransform getTranslateInstance(double tx,
double ty)
- Returns a transform representing a translation transformation.
The matrix representing by the returned transform transform will be:
[ 1 0 tx ]
[ 0 1 ty ]
[ 0 0 1 ]
- Parameters:
tx
- The distance by which coordinates are translated in the
X axis direction
ty
- The distance by which coordinates are translated in the
Y axis direction
getRotateInstance
public static AffineTransform getRotateInstance(double theta)
- Returns a transform representing a rotation transformation.
The matrix representing by the returned transform transform will be:
[ cos(theta) -sin(theta) 0 ]
[ sin(theta) cos(theta) 0 ]
[ 0 0 1 ]
Rotating with a positive angle theta rotates points on the positive
x axis toward the positive y axis.
- Parameters:
theta
- The angle of rotation in radians.
getRotateInstance
public static AffineTransform getRotateInstance(double theta,
double x,
double y)
- Returns a transform representing a translated rotation transformation.
This is equivalent to the following sequence of calls:
AffineTransform Tx = new AffineTransform();
Tx.setToTranslation(x, y);
Tx.rotate(theta);
Tx.translate(-x, -y);
The matrix representing by the returned transform transform will be:
[ cos(theta) -sin(theta) x-x*cos+y*sin ]
[ sin(theta) cos(theta) y-x*sin-y*cos ]
[ 0 0 1 ]
Rotating with a positive angle theta rotates points on the positive
x axis toward the positive y axis.
- Parameters:
theta
- The angle of rotation in radians.
x
- The x coordinate of the origin of the rotation
y
- The x coordinate of the origin of the rotation
getScaleInstance
public static AffineTransform getScaleInstance(double sx,
double sy)
- Returns a transform representing a scaling transformation.
The matrix representing by the returned transform transform will be:
[ sx 0 0 ]
[ 0 sy 0 ]
[ 0 0 1 ]
- Parameters:
sx
- The factor by which coordinates are scaled along the
X axis direction
sy
- The factor by which coordinates are scaled along the
Y axis direction
getShearInstance
public static AffineTransform getShearInstance(double shx,
double shy)
- Returns a transform representing a shearing transformation.
The matrix representing by the returned transform transform will be:
[ 1 shx 0 ]
[ shy 1 0 ]
[ 0 0 1 ]
- Parameters:
shx
- The factor by which coordinates are shifted towards the
positive X axis direction according to their Y coordinate
shy
- The factor by which coordinates are shifted towards the
positive Y axis direction according to their X coordinate
getType
public int getType()
- Retrieves the flag bits describing the conversion properties of
this transform. The return value will be a combination of the
appriopriate conversion flag bits.
- Returns:
- the OR combination of any of the indicated flags that
apply to this transform
- See Also:
- TRANSLATION, UNIFORM_SCALE, GENERAL_SCALE, QUADRANT_ROTATION, GENERAL_ROTATION, GENERAL_TRANSFORM
getDeterminant
public double getDeterminant()
- Returns the determinant of the matrix representation of the transform.
The determinant is useful both to determine if the transform can
be inverted and also to get a single value representing the
combined X and Y scaling of the transform.
If the determinant is non-zero, then this transform will be
invertable and the various methods which depend on the inverse
transform will not need to throw a NoninvertibleTransformException.
If the determinant is zero, then this transform can not be
inverted since the transform maps all input coordinates onto
a line or a point.
If the determinant is near enough to zero, then inverse transform
operations may not carry enough precision to produce meaningful
results.
If this transform represents a uniform scale, as indicated by
the getType method, then the determinant will also represent
the square of the uniform scale factor by which all of the
points are expanded from or contracted towards the origin.
If this transform represents a non-uniform scale or more general
transform, then the determinant is not likely to represent a
value useful for any other purpose than determining if inverse
transforms are possible.
Mathematically, the determinant is calculated using the formula:
| m00 m01 m02 |
| m10 m11 m12 | = m00 * m11 - m01 * m10
| 0 0 1 |
- Returns:
- the determinant of the matrix used to transform the
coordinates
- See Also:
- getType, createInverse, inverseTransform, UNIFORM_SCALE
getMatrix
public void getMatrix(double[] flatmatrix)
- Retrieves the 6 specifiable values in the 3x3 affine transformation
matrix into
an array of double precisions values. The values are stored into
the array as { m00 m10 m01 m11 m02 m12 }.
- Parameters:
flatmatrix
- The double array used to store the returned values.
The length of the array is assumed to be at least 6.
- See Also:
- getScaleX, getScaleY, getShearX, getShearY, getTranslateX, getTranslateY
getMatrix
public void getMatrix(double[][] matrix)
- Retrieves the 6 specifiable values in the 3x3 affine transformation
matrix into
a 2-dimensional array of double precision values. The values are
stored into the 2-dimensional array using the row index as the
first subscript and the column index as the second.
- Parameters:
matrix
- The 2-dimensional double array to store the returned
values. The array is assumed to be at least 2x3.
- See Also:
- getScaleX, getScaleY, getShearX, getShearY, getTranslateX, getTranslateY
getScaleX
public double getScaleX()
- Returns the X coordinate scaling element (m00) of the 3x3
affine transformation matrix.
- See Also:
- getMatrix
getScaleY
public double getScaleY()
- Returns the Y coordinate scaling element (m11) of the 3x3
affine transformation matrix.
- See Also:
- getMatrix
getShearX
public double getShearX()
- Returns the X coordinate shearing element (m01) of the 3x3
affine transformation matrix.
- See Also:
- getMatrix
getShearY
public double getShearY()
- Returns the Y coordinate shearing element (m10) of the 3x3
affine transformation matrix.
- See Also:
- getMatrix
getTranslateX
public double getTranslateX()
- Returns the X coordinate translation element (m02) of the 3x3
affine transformation matrix.
- See Also:
- getMatrix
getTranslateY
public double getTranslateY()
- Returns the Y coordinate translation element (m12) of the 3x3
affine transformation matrix.
- See Also:
- getMatrix
translate
public void translate(double tx,
double ty)
- Concatenates this transform with a translation transformation.
This is equivalent to calling concatenate(T), where T is an
AffineTransform represented by the following matrix:
[ 1 0 tx ]
[ 0 1 ty ]
[ 0 0 1 ]
rotate
public void rotate(double theta)
- Concatenates this transform with a rotation transformation.
This is equivalent to calling concatenate(R), where R is an
AffineTransform represented by the following matrix:
[ cos(theta) -sin(theta) 0 ]
[ sin(theta) cos(theta) 0 ]
[ 0 0 1 ]
Rotating with a positive angle theta rotates points on the positive
x axis toward the positive y axis.
- Parameters:
theta
- The angle of rotation in radians.
rotate
public void rotate(double theta,
double x,
double y)
- Concatenates this transform with a translated rotation transformation.
This is equivalent to the following sequence of calls:
translate(x, y);
rotate(theta);
translate(-x, -y);
Rotating with a positive angle theta rotates points on the positive
x axis toward the positive y axis.
- Parameters:
theta
- The angle of rotation in radians.
x
- The x coordinate of the origin of the rotation
y
- The x coordinate of the origin of the rotation
scale
public void scale(double sx,
double sy)
- Concatenates this transform with a scaling transformation.
This is equivalent to calling concatenate(S), where S is an
AffineTransform represented by the following matrix:
[ sx 0 0 ]
[ 0 sy 0 ]
[ 0 0 1 ]
shear
public void shear(double shx,
double shy)
- Concatenates this transform with a shearing transformation.
This is equivalent to calling concatenate(SH), where SH is an
AffineTransform represented by the following matrix:
[ 1 shx 0 ]
[ shy 1 0 ]
[ 0 0 1 ]
- Parameters:
shx
- The factor by which coordinates are shifted towards the
positive X axis direction according to their Y coordinate
shy
- The factor by which coordinates are shifted towards the
positive Y axis direction according to their X coordinate
setToIdentity
public void setToIdentity()
- Resets this transform to the Identity transform.
setToTranslation
public void setToTranslation(double tx,
double ty)
- Sets this transform to a translation transformation.
The matrix representing this transform becomes:
[ 1 0 tx ]
[ 0 1 ty ]
[ 0 0 1 ]
- Parameters:
tx
- The distance by which coordinates are translated in the
X axis direction
ty
- The distance by which coordinates are translated in the
Y axis direction
setToRotation
public void setToRotation(double theta)
- Sets this transform to a rotation transformation.
The matrix representing this transform becomes:
[ cos(theta) -sin(theta) 0 ]
[ sin(theta) cos(theta) 0 ]
[ 0 0 1 ]
Rotating with a positive angle theta rotates points on the positive
x axis toward the positive y axis.
- Parameters:
theta
- The angle of rotation in radians.
setToRotation
public void setToRotation(double theta,
double x,
double y)
- Sets this transform to a translated rotation transformation.
This is equivalent to the following sequence of calls:
setToTranslation(x, y);
rotate(theta);
translate(-x, -y);
The matrix representing this transform becomes:
[ cos(theta) -sin(theta) x-x*cos+y*sin ]
[ sin(theta) cos(theta) y-x*sin-y*cos ]
[ 0 0 1 ]
Rotating with a positive angle theta rotates points on the positive
x axis toward the positive y axis.
- Parameters:
theta
- The angle of rotation in radians.
x
- The x coordinate of the origin of the rotation
y
- The x coordinate of the origin of the rotation
setToScale
public void setToScale(double sx,
double sy)
- Sets this transform to a scaling transformation.
The matrix representing this transform becomes:
[ sx 0 0 ]
[ 0 sy 0 ]
[ 0 0 1 ]
- Parameters:
sx
- The factor by which coordinates are scaled along the
X axis direction
sy
- The factor by which coordinates are scaled along the
Y axis direction
setToShear
public void setToShear(double shx,
double shy)
- Sets this transform to a shearing transformation.
The matrix representing this transform becomes:
[ 1 shx 0 ]
[ shy 1 0 ]
[ 0 0 1 ]
- Parameters:
shx
- The factor by which coordinates are shifted towards the
positive X axis direction according to their Y coordinate
shy
- The factor by which coordinates are shifted towards the
positive Y axis direction according to their X coordinate
setTransform
public void setTransform(AffineTransform Tx)
- Sets this transform to a copy of the transform in the indicated
AffineTransform object.
- Parameters:
Tx
- the AffineTransform object from which to copy the transform
setTransform
public void setTransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
- Sets this transform to the matrix specified by the 6
double precision values.
concatenate
public void concatenate(AffineTransform Tx)
- Concatenates an AffineTransform Tx to this AffineTransform Cx
in the most commonly useful way to provide a new user space
which is mapped to the former user space by Tx.
Cx is updated to perform the combined transformation.
Transforming a point p by the updated transform Cx' is
equivalent to first transforming p by Tx and then transforming
the result by the original transform Cx. In other words,
Cx'(p) = Cx(Tx(p)). In matrix notation, if this transform Cx
is represented by the matrix [this] and Tx is represented by
the matrix [Tx], then this method does the following:
[this] = [this] x [Tx]
- Parameters:
Tx
- The AffineTransform object to be concatenated with
this AffineTransform object.
- See Also:
- preConcatenate
preConcatenate
public void preConcatenate(AffineTransform Tx)
- Concatenates an AffineTransform Tx to this AffineTransform Cx
in a less commonly used way such that Tx modifies the
coordinate transformation relative to the absolute pixel
space rather than relative to the existing user space.
Cx is updated to perform the combined transformation.
Transforming a point p by the updated transform Cx' is
equivalent to first transforming p by the original transform
Cx and then transforming the result by Tx. In other words,
Cx'(p) = Tx(Cx(p)). In matrix notation, if this transform Cx
is represented by the matrix [this] and Tx is represented by
the matrix [Tx], then this method does the following:
[this] = [Tx] x [this]
- Parameters:
Tx
- The AffineTransform object to be concatenated with
this AffineTransform object.
- See Also:
- concatenate
createInverse
public AffineTransform createInverse() throws NoninvertibleTransformException
- Returns an AffineTransform object representing the inverse
transformation.
- Throws:
- NoninvertibleTransformException - if the matrix cannot be
inverted.
transform
public Point2D transform(Point2D ptSrc,
Point2D ptDst)
- Transforms the specified ptSrc and stores the result in ptDst.
If ptDst is null, a new Point2D object will be allocated before
storing. In either case, ptDst containing the transformed point
is returned for convenience.
Note that ptSrc and ptDst can the same. In this case, the input
point will be overwritten with the transformed point.
transform
public void transform(Point2D[] ptSrc,
int srcOff,
Point2D[] ptDst,
int dstOff,
int numPts)
- Transforms an array of point objects by this transform.
- Parameters:
ptSrc
- The array containing the source point objects.
ptDst
- The array where the transform point objects are returned.
srcOff
- The offset to the first point object to be transformed
in the source array.
dstOff
- The offset to the location where the first transformed
point object is stored in the destination array.
numPts
- The number of point objects to be transformed.
transform
public void transform(float[] srcPts,
int srcOff,
float[] dstPts,
int dstOff,
int numPts)
- Transforms an array of floating point coordinates by this transform.
- Parameters:
ptSrc
- The array containing the source point coordinates.
Each point is stored as a pair of x,y coordinates.
ptDst
- The array where the transformed point coordinates are
returned. Each point is stored as a pair of x,y coordinates.
srcOff
- The offset to the first point to be transformed
in the source array.
dstOff
- The offset to the location where the first transformed
point is stored in the destination array.
numPts
- The number of points to be transformed.
transform
public void transform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
- Transforms an array of double precision coordinates by this transform.
- Parameters:
srcPts
- The array containing the source point coordinates.
Each point is stored as a pair of x,y coordinates.
dstPts
- The array where the transformed point coordinates are
returned. Each point is stored as a pair of x,y coordinates.
srcOff
- The offset to the first point to be transformed
in the source array.
dstOff
- The offset to the location where the first transformed
point is stored in the destination array.
numPts
- The number of point objects to be transformed.
transform
public void transform(float[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
- Transforms an array of floating point coordinates by this transform,
storing the results into an array of doubles.
- Parameters:
ptSrc
- The array containing the source point coordinates.
Each point is stored as a pair of x,y coordinates.
ptDst
- The array where the transformed point coordinates are
returned. Each point is stored as a pair of x,y coordinates.
srcOff
- The offset to the first point to be transformed
in the source array.
dstOff
- The offset to the location where the first transformed
point is stored in the destination array.
numPts
- The number of points to be transformed.
transform
public void transform(double[] srcPts,
int srcOff,
float[] dstPts,
int dstOff,
int numPts)
- Transforms an array of double precision coordinates by this transform,
storing the results into an array of floats.
- Parameters:
srcPts
- The array containing the source point coordinates.
Each point is stored as a pair of x,y coordinates.
dstPts
- The array where the transformed point coordinates are
returned. Each point is stored as a pair of x,y coordinates.
srcOff
- The offset to the first point to be transformed
in the source array.
dstOff
- The offset to the location where the first transformed
point is stored in the destination array.
numPts
- The number of point objects to be transformed.
inverseTransform
public Point2D inverseTransform(Point2D ptSrc,
Point2D ptDst) throws NoninvertibleTransformException
- Inverse transforms the specified ptSrc and stores the result in ptDst.
If ptDst is null, a new Point2D object will be allocated before
storing. In either case, ptDst containing the transformed point
is returned for convenience.
Note that ptSrc and ptDst can the same. In this case, the input
point will be overwritten with the transformed point.
- Parameters:
ptSrc
- The point to be inverse transformed.
ptDst
- The resulting transformed point.
- Throws:
- NoninvertibleTransformException - if the matrix cannot be
inverted.
inverseTransform
public void inverseTransform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts) throws NoninvertibleTransformException
- Inverse transforms an array of double precision coordinates by
this transform.
- Parameters:
srcPts
- The array containing the source point coordinates.
Each point is stored as a pair of x,y coordinates.
dstPts
- The array where the transformed point coordinates are
returned. Each point is stored as a pair of x,y coordinates.
srcOff
- The offset to the first point to be transformed
in the source array.
dstOff
- The offset to the location where the first transformed
point is stored in the destination array.
numPts
- The number of point objects to be transformed.
- Throws:
- NoninvertibleTransformException - if the matrix cannot be
inverted.
deltaTransform
public Point2D deltaTransform(Point2D ptSrc,
Point2D ptDst)
- Transforms the relative distance vector specified by ptSrc and
stores the result in ptDst.
A relative distance vector is transformed without applying the
translation components of the affine transformation matrix
using the following equations:
[ x'] [ m00 m01 (m02) ] [ x ] [ m00x + m01y ]
[ y'] = [ m10 m11 (m12) ] [ y ] = [ m10x + m11y ]
[ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ]
If ptDst is null, a new Point2D object will be allocated before
storing. In either case, ptDst containing the transformed point
is returned for convenience.
Note that ptSrc and ptDst can the same. In this case, the input
point will be overwritten with the transformed point.
- Parameters:
ptSrc
- The distance vector to be inverse transformed.
ptDst
- The resulting transformed distance vector.
deltaTransform
public void deltaTransform(double[] srcPts,
int srcOff,
double[] dstPts,
int dstOff,
int numPts)
- Transforms an array of relative distance vectors by this
transform.
A relative distance vector is transformed without applying the
translation components of the affine transformation matrix
using the following equations:
[ x'] [ m00 m01 (m02) ] [ x ] [ m00x + m01y ]
[ y'] = [ m10 m11 (m12) ] [ y ] = [ m10x + m11y ]
[ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ]
- Parameters:
srcPts
- The array containing the source distance vectors.
Each vector is stored as a pair of relative x,y coordinates.
dstPts
- The array where the transformed distance vectors are
returned. Each vector is stored as a pair of relative x,y coordinates.
srcOff
- The offset to the first vector to be transformed
in the source array.
dstOff
- The offset to the location where the first transformed
vector is stored in the destination array.
numPts
- The number of vector coordinate pairs to be transformed.
createTransformedShape
public Shape createTransformedShape(Shape pSrc)
- Transforms a shape object by this transform.
toString
public String toString()
- Returns a String that represents the value of this Object.
- Overrides:
- toString in class Object
isIdentity
public boolean isIdentity()
- Returns the boolean true value if this AffineTransform is an
identity transform. Returns false otherwise.
clone
public Object clone()
- Returns a copy of this AffineTransform object.
- Overrides:
- clone in class Object
equals
public boolean equals(Object obj)
- Overrides:
- equals in class Object
Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.