Class AffineTransform2D

  • All Implemented Interfaces:
    Serializable, Cloneable, MathTransform, MathTransform2D

    public class AffineTransform2D
    extends AffineTransform
    implements 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:

    Since:
    3.1
    See Also:
    Serialized Form
    • 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:
        getSourceDimensions in interface MathTransform
      • getTargetDimensions

        public final int getTargetDimensions()
        Returns the target dimension, which is 2. This number of dimensions can not be changed.
        Specified by:
        getTargetDimensions in interface MathTransform
      • transform

        public DirectPosition transform​(DirectPosition ptSrc,
                                        DirectPosition ptDst)
                                 throws MismatchedDimensionException
        Transforms the specified ptSrc and stores the result in ptDst. This method delegates its work to AffineTransform.transform(Point2D, Point2D).
        Specified by:
        transform in interface MathTransform
        Parameters:
        ptSrc - the coordinate point to be transformed.
        ptDst - the coordinate point that stores the transform result, or null.
        Returns:
        the coordinate point after transforming ptSrc and storing the result in ptDst, or a newly created point if ptDst was null.
        Throws:
        MismatchedDimensionException - if ptSrc or ptDst does 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 to derivative(Point2D).
        Specified by:
        derivative in interface MathTransform
        Parameters:
        point - ignored (except for the dimension, which is checked as a matter of principle).
        Returns:
        the derivative (never null).
        Throws:
        MismatchedDimensionException - if point does 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:
        derivative in interface MathTransform2D
        Parameters:
        point - ignored - may be null.
        Returns:
        the derivative (never null).
      • inverse

        public MathTransform2D inverse()
                                throws NoninvertibleTransformException
        Returns the inverse of this affine transform.
        Specified by:
        inverse in interface MathTransform
        Specified by:
        inverse in interface MathTransform2D
        Throws:
        NoninvertibleTransformException