Package org.opengis.example.referencing
Class AffineTransform2D
- Object
-
- AffineTransform
-
- AffineTransform2D
-
- All Implemented Interfaces:
Serializable,Cloneable,MathTransform,MathTransform2D
public class AffineTransform2D extends AffineTransform implements MathTransform2D
AMathTransform2Dbacked by the Java2DAffineTransform.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
ProjectiveTransformrestricted 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:
- Serialized Form
-
-
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
Constructors Constructor Description AffineTransform2D()Creates a new transform initialized to the identity transform.AffineTransform2D(AffineTransform tr)Creates a new transform initialized to the values of the given transform.
-
Method Summary
Modifier and Type Method Description Matrixderivative(Point2D point)Gets the derivative of this transform at a point.Matrixderivative(DirectPosition point)Gets the derivative of this transform at a point.intgetSourceDimensions()Returns the source dimension, which is 2.intgetTargetDimensions()Returns the target dimension, which is 2.MathTransform2Dinverse()Returns the inverse of this affine transform.voidsetTransform(Matrix matrix)Sets this affine transform to the values of the given matrix.StringtoWKT()Unsupported operation.DirectPositiontransform(DirectPosition ptSrc, DirectPosition ptDst)Transforms the specifiedptSrcand 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 Detail
-
AffineTransform2D
public AffineTransform2D()
Creates a new transform initialized to the identity transform.
-
AffineTransform2D
public AffineTransform2D(AffineTransform tr)
Creates a new transform initialized to the values of the given transform.- Parameters:
tr- the transform to copy.
-
-
Method Detail
-
setTransform
public void setTransform(Matrix matrix) throws IllegalArgumentException
Sets this affine transform to the values of the given matrix. The matrix size must be 3×3 and the last row shall contains 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 can not be changed.- Specified by:
getSourceDimensionsin interfaceMathTransform
-
getTargetDimensions
public final int getTargetDimensions()
Returns the target dimension, which is 2. This number of dimensions can not be changed.- Specified by:
getTargetDimensionsin interfaceMathTransform
-
transform
public DirectPosition transform(DirectPosition ptSrc, DirectPosition ptDst) throws MismatchedDimensionException
Transforms the specifiedptSrcand stores the result inptDst. This method delegates its work toAffineTransform.transform(Point2D, Point2D).- Specified by:
transformin 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
ptSrcand storing the result inptDst, or a newly created point ifptDstwas null. - Throws:
MismatchedDimensionException- ifptSrcorptDstdoes not have exactly 2 dimensions.
-
derivative
public Matrix derivative(DirectPosition point) throws MismatchedDimensionException
Gets the derivative of this transform at a point. This method delegates its work toderivative(Point2D).- Specified by:
derivativein interfaceMathTransform- Parameters:
point- ignored (except for the dimension, which is checked as a matter of principle).- Returns:
- the derivative (never
null). - Throws:
MismatchedDimensionException- ifpointdoes not have the expected dimension.
-
derivative
public Matrix derivative(Point2D point)
Gets the derivative of this transform at a point. The derivative of an affine transform is constant everywhere.- Specified by:
derivativein interfaceMathTransform2D- Parameters:
point- ignored - may benull.- Returns:
- the derivative (never
null).
-
inverse
public MathTransform2D inverse() throws NoninvertibleTransformException
Returns the inverse of this affine transform.- Specified by:
inversein interfaceMathTransform- Specified by:
inversein interfaceMathTransform2D- Throws:
NoninvertibleTransformException
-
toWKT
public String toWKT() throws UnsupportedOperationException
Unsupported operation.- Specified by:
toWKTin interfaceMathTransform- Throws:
UnsupportedOperationException
-
-