Object
AffineTransform
AffineTransform2D
- All Implemented Interfaces:
Serializable
,Cloneable
,MathTransform
,MathTransform2D
A
MathTransform2D
backed by the Java2D AffineTransform
.
Affine transforms are very commons in GIS - they can be used for scaling, flipping the y axis, applying unit conversions, etc.. The standard Java2D library provides an efficient general-purpose implementation of affine transform. This class extends the Java2D class for efficiency and for inter-operability with Java2D.
This affine transform is a special case of ProjectiveTransform
restricted to
the following cases:
- The number of source and target dimensions are 2.
- The last matrix row contains the [0 0 1] values.
- Since:
- 3.1
- See Also:
-
Field Summary
Fields inherited from class AffineTransform
TYPE_FLIP, TYPE_GENERAL_ROTATION, TYPE_GENERAL_SCALE, TYPE_GENERAL_TRANSFORM, TYPE_IDENTITY, TYPE_MASK_ROTATION, TYPE_MASK_SCALE, TYPE_QUADRANT_ROTATION, TYPE_TRANSLATION, TYPE_UNIFORM_SCALE
-
Constructor Summary
ConstructorDescriptionCreates a new transform initialized to the identity transform.Creates a new transform initialized to the values of the given transform. -
Method Summary
Modifier and TypeMethodDescriptionderivative
(Point2D point) Gets the derivative of this transform at a point.derivative
(DirectPosition point) Gets the derivative of this transform at a point.final int
Returns the source dimension, which is 2.final int
Returns the target dimension, which is 2.inverse()
Returns the inverse of this affine transform.void
setTransform
(Matrix matrix) Sets this affine transform to the values of the given matrix.toWKT()
Unsupported operation.transform
(DirectPosition ptSrc, DirectPosition ptDst) Transforms the specifiedptSrc
and stores the result inptDst
.Methods inherited from class AffineTransform
clone, concatenate, createInverse, createTransformedShape, deltaTransform, deltaTransform, equals, getDeterminant, getMatrix, getQuadrantRotateInstance, getQuadrantRotateInstance, getRotateInstance, getRotateInstance, getRotateInstance, getRotateInstance, getScaleInstance, getScaleX, getScaleY, getShearInstance, getShearX, getShearY, getTranslateInstance, getTranslateX, getTranslateY, getType, hashCode, inverseTransform, inverseTransform, invert, isIdentity, preConcatenate, quadrantRotate, quadrantRotate, rotate, rotate, rotate, rotate, scale, setToIdentity, setToQuadrantRotation, setToQuadrantRotation, setToRotation, setToRotation, setToRotation, setToRotation, setToScale, setToShear, setToTranslation, setTransform, setTransform, shear, toString, transform, transform, transform, transform, transform, transform, translate
Methods inherited from interface MathTransform
isIdentity, transform, transform, transform, transform
Methods inherited from interface MathTransform2D
createTransformedShape, transform
-
Constructor Details
-
AffineTransform2D
public AffineTransform2D()Creates a new transform initialized to the identity transform. -
AffineTransform2D
Creates a new transform initialized to the values of the given transform.- Parameters:
tr
- the transform to copy.
-
-
Method Details
-
setTransform
Sets this affine transform to the values of the given matrix. The matrix size must be 3×3 and the last row shall contain the [0 0 1] values.- Parameters:
matrix
- the matrix to copy in this affine transform.- Throws:
IllegalArgumentException
- if the matrix size is not 3×3, or the transform is not affine.
-
getSourceDimensions
public final int getSourceDimensions()Returns the source dimension, which is 2. This number of dimensions cannot be changed.- Specified by:
getSourceDimensions
in interfaceMathTransform
- Returns:
- the number of dimensions of input points.
- See Also:
-
getTargetDimensions
public final int getTargetDimensions()Returns the target dimension, which is 2. This number of dimensions cannot be changed.- Specified by:
getTargetDimensions
in interfaceMathTransform
- Returns:
- the number of dimensions of output points.
- See Also:
-
transform
public DirectPosition transform(DirectPosition ptSrc, DirectPosition ptDst) throws MismatchedDimensionException Transforms the specifiedptSrc
and stores the result inptDst
. This method delegates its work toAffineTransform.transform(Point2D, Point2D)
.- Specified by:
transform
in interfaceMathTransform
- Parameters:
ptSrc
- the coordinate point to be transformed.ptDst
- the coordinate point that stores the transform result, ornull
.- Returns:
- the coordinate point after transforming
ptSrc
and storing the result inptDst
, or a newly created point ifptDst
was null. - Throws:
MismatchedDimensionException
- ifptSrc
orptDst
does not have exactly 2 dimensions.
-
derivative
Gets the derivative of this transform at a point. This method delegates its work toderivative(Point2D)
.- Specified by:
derivative
in interfaceMathTransform
- Parameters:
point
- ignored (except for the dimension, which is checked as a matter of principle).- Returns:
- the derivative (never
null
). - Throws:
MismatchedDimensionException
- ifpoint
does not have the expected dimension.
-
derivative
Gets the derivative of this transform at a point. The derivative of an affine transform is constant everywhere.- Specified by:
derivative
in interfaceMathTransform2D
- Parameters:
point
- ignored - may benull
.- Returns:
- the derivative (never
null
).
-
inverse
Returns the inverse of this affine transform.- Specified by:
inverse
in interfaceMathTransform
- Specified by:
inverse
in interfaceMathTransform2D
- Returns:
- the inverse transform.
- Throws:
NoninvertibleTransformException
- if the transform cannot be inverted.- See Also:
-
toWKT
Unsupported operation.- Specified by:
toWKT
in interfaceMathTransform
- Returns:
- the Well-Known Text (WKT) for this object.
- Throws:
UnsupportedOperationException
- if this object cannot be formatted as WKT.- See Also:
-