Class AffineTransform2D

  • All Implemented Interfaces:
    Serializable, Cloneable, Matrix, Cloneable

    public class AffineTransform2D
    extends AffineTransform
    implements Matrix
    An affine matrix of fixed 3×3 size. Here, the term "affine" means a matrix with the last row fixed to [0,0,1] values. Such matrices are used for affine transformations in a 2D space.

    This class both extends the Java2D AffineTransform class and implements the Matrix interface. It allows interoperbility for code that need to pass the same matrix to both Java2D API and more generic API working with coordinates of arbitrary dimension.

    This class do not implements the XMatrix interface because the inherited invert() method (new in J2SE 1.6) declares a checked exception, setZero() would be an unsupported operation (because it is not possible to change the value at (2,2)), transpose() would fails in most cases, and isAffine() would be useless.

    Since:
    2.3
    Author:
    Martin Desruisseaux (IRD)
    See Also:
    Serialized Form
    • Constructor Detail

      • AffineTransform2D

        public AffineTransform2D()
        Creates a new identity matrix.
      • AffineTransform2D

        public AffineTransform2D​(AffineTransform transform)
        Constructs a 3×3 matrix from the specified affine transform.
      • AffineTransform2D

        public AffineTransform2D​(Matrix matrix)
        Creates a new matrix initialized to the same value than the specified one. The specified matrix size must be 3×3.
    • Method Detail

      • getNumRow

        public final int getNumRow()
        Returns the number of rows in this matrix, which is always 3 in this implementation.
        Specified by:
        getNumRow in interface Matrix
        Returns:
        The number of rows in this matrix.
      • getNumCol

        public final int getNumCol()
        Returns the number of colmuns in this matrix, which is always 3 in this implementation.
        Specified by:
        getNumCol in interface Matrix
        Returns:
        The number of columns in this matrix.
      • getElement

        public double getElement​(int row,
                                 int column)
        Retrieves the value at the specified row and column of this matrix.
        Specified by:
        getElement in interface Matrix
        Parameters:
        row - The row number to be retrieved (zero indexed).
        column - The column number to be retrieved (zero indexed).
        Returns:
        The value at the indexed element.
      • setElement

        public void setElement​(int row,
                               int column,
                               double value)
        Modifies the value at the specified row and column of this matrix.
        Specified by:
        setElement in interface Matrix
        Parameters:
        row - The row number to be retrieved (zero indexed).
        column - The column number to be retrieved (zero indexed).
        value - The new matrix element value.
      • toString

        public String toString()
        Returns a string representation of this matrix. The returned string is implementation dependent. It is usually provided for debugging purposes only.
        Overrides:
        toString in class AffineTransform