Package org.eclipse.gef.geometry.planar

# Class AffineTransform

java.lang.Object
org.eclipse.gef.geometry.planar.AffineTransform

All Implemented Interfaces:
  `Cloneable`

public class AffineTransform extends Object implements Cloneable

The `AffineTransform` class provides methods to create and modify 2-dimensional affine transformations.

It delegates to the `AffineTransform` functionality.

## Constructor Summary

Constructors
Constructor
Description
`AffineTransform()`
Creates a new `AffineTransform` with its transformation matrix set to the identity matrix.
`AffineTransform(double[] flatmatrix)`
Creates a new `AffineTransform` with its transformation matrix set to the values of the passed-in array.
`AffineTransform(double m00, double m10, double m01, double m11, double m02, double m12)`
Creates a new `AffineTransform` with its transformation matrix set to the specified values.

## Method Summary

Modifier and Type
Method
Description
`Object`
`clone()`
`AffineTransform`
`concatenate(AffineTransform Tx)`
Concatenates this `AffineTransform` and the given `AffineTransform`, multiplying the transformation matrix of this `AffineTransform` from the left with the transformation matrix of the other `AffineTransform`.
`void`
`deltaTransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)`
Transforms an array of `Point`s specified by their coordinate values with this `AffineTransform` without applying the translation components of the transformation matrix of this `AffineTransform`.
`Point`
`deltaTransform(Point pt)`
Transforms the given `Point` with this `AffineTransform` without applying the translation components of the transformation matrix of this `AffineTransform`.
`boolean`
`equals(Object obj)`
`AffineTransform`
`getCopy()`
Returns a copy of this `AffineTransform`.
`double`
`getDeterminant()`
Computes the determinant of the transformation matrix of this `AffineTransform`.
`AffineTransform`
`getInverse()`
Creates a new `AffineTransform` that represents the inverse transformation of this `AffineTransform`.
`double`
`getM00()`
Returns the matrix component in the first row and first column.
`double`
`getM01()`
Returns the matrix component in the first row and second column.
`double`
`getM10()`
Returns the matrix component in the second row and first column.
`double`
`getM11()`
Returns the matrix component in the second row and second column.
`double[]`
`getMatrix()`
Returns the 6 specifiable elements of the transformation matrix of this `AffineTransform`.
`Angle`
`getRotation()`
Returns the rotation component of this `AffineTransform`.
`double`
`getScaleX()`
Returns the x coordinate scaling of this `AffineTransform`'s transformation matrix.
`double`
`getScaleY()`
Returns the y coordinate scaling of this `AffineTransform`'s transformation matrix.
`Point`
`getTransformed(Point ptSrc)`
Transforms the given `Point` with this `AffineTransform` by multiplying the transformation matrix of this `AffineTransform` with the given `Point`.
`Point[]`
`getTransformed(Point[] points)`
Transforms the given array of `Point`s with this `AffineTransform` by multiplying the transformation matrix of this `AffineTransform` individually with each of the given `Point` s.
`double`
`getTranslateX()`
Returns the x coordinate translation of this `AffineTransform`'s transformation matrix.
`double`
`getTranslateY()`
Returns the y coordinate translation of this `AffineTransform`'s transformation matrix.
`int`
`getType()`
Returns the type of transformation represented by this `AffineTransform`.
`int`
`hashCode()`
`void`
`inverseTransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)`
Inverse transforms an array of `Point`s specified by their coordinate values with this `AffineTransform`.
`Point`
`inverseTransform(Point pt)`
Inverse transforms the given `Point` with this `AffineTransform`.
`AffineTransform`
`invert()`
Inverts this `AffineTransform`.
`boolean`
`isIdentity()`
Checks if the transformation matrix of this `AffineTransform` equals the identity matrix.
`AffineTransform`
`preConcatenate(AffineTransform Tx)`
Concatenates this `AffineTransform` and the given `AffineTransform` in reverse order, multiplying the transformation matrix of this `AffineTransform` from the right with the transformation matrix of the other `AffineTransform`.
`AffineTransform`
`quadrantRotate(int numquadrants)`
Adds a rotation by an integer multiple of 90deg to the transformation matrix of this `AffineTransform`.
`AffineTransform`
`quadrantRotate(int numquadrants, double anchorx, double anchory)`
Adds a rotation by an integer multiple of 90deg around the `Point` specified by the given x and y coordinates to the transformation matrix of this `AffineTransform`.
`AffineTransform`
`rotate(double theta)`
Adds a rotation with the given angle (in radians) to the transformation matrix of this `AffineTransform`.
`AffineTransform`
`rotate(double vecx, double vecy)`
Adds a rotation to the transformation matrix of this `AffineTransform`.
`AffineTransform`
`rotate(double theta, double anchorx, double anchory)`
Adds a rotation with the given angle (in radians) around the `Point` specified by the given x and y coordinates to the transformation matrix of this `AffineTransform`.
`AffineTransform`
`rotate(double vecx, double vecy, double anchorx, double anchory)`
Adds a rotation around a `Point` to the transformation matrix of this `AffineTransform`.
`AffineTransform`
`scale(double sx, double sy)`
Adds an x and y scaling to the transformation matrix of this `AffineTransform`.
`AffineTransform`
`setToIdentity()`
Sets the transformation matrix of this `AffineTransform` to the identity matrix.
`AffineTransform`
`setToQuadrantRotation(int numquadrants)`
Sets the transformation matrix of this `AffineTransform` to a pure rotation matrix where the rotation angle is an integer multiple of 90deg.
`AffineTransform`
`setToQuadrantRotation(int numquadrants, double anchorx, double anchory)`
Sets the transformation matrix of this `AffineTransform` to a pure rotation and translation matrix where the rotation angle is an integer multiple of 90deg and the rotation is around the `Point` specified by the given x and y coordinates.
`AffineTransform`
`setToRotation(double theta)`
Sets the transformation matrix of this `AffineTransform` to a pure rotation matrix by the given angle specified in radians.
`AffineTransform`
`setToRotation(double vecx, double vecy)`
Sets the transformation matrix of this `AffineTransform` to a pure rotation matrix.
`AffineTransform`
`setToRotation(double theta, double anchorx, double anchory)`
Sets the transformation matrix of this `AffineTransform` to a pure rotation and translation matrix.
`AffineTransform`
`setToRotation(double vecx, double vecy, double anchorx, double anchory)`
Sets the transformation matrix of this `AffineTransform` to a pure rotation and translation matrix.
`AffineTransform`
`setToScale(double sx, double sy)`
Sets the transformation matrix of this `AffineTransform` to a pure scaling matrix.
`AffineTransform`
`setToShear(double shx, double shy)`
Sets the transformation matrix of this `AffineTransform` to a pure shearing matrix.
`AffineTransform`
`setToTranslation(double tx, double ty)`
Sets the transformation matrix of this `AffineTransform` to a pure translation matrix that translates `Point`s by the given x and y values.
`AffineTransform`
`setTransform(double m00, double m10, double m01, double m11, double m02, double m12)`
Sets the respective values of the transformation matrix of this `AffineTransform` to the supplied ones.
`AffineTransform`
`setTransform(AffineTransform Tx)`
Sets the transformation matrix of this `AffineTransform` to the transformation matrix of the given `AffineTransform`.
`AffineTransform`
`shear(double shx, double shy)`
Adds an x and y shearing to the transformation matrix of this `AffineTransform`.
`String`
`toString()`
`AffineTransform`
`translate(double tx, double ty)`
Sets the translation values of the x and y coordinates of the transformation matrix of this `AffineTransform`.

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### AffineTransform

public AffineTransform()
Creates a new `AffineTransform` with its transformation matrix set to the identity matrix.

### AffineTransform

public AffineTransform(double m00, double m10, double m01, double m11, double m02, double m12)
Creates a new `AffineTransform` with its transformation matrix set to the specified values. Note that rotation is a combination of shearing and scaling.

Parameters:
  `m00` - the value of the transformation matrix in row 0 and column 0 (x coordinate scaling)
  `m10` - the value of the transformation matrix in row 1 and column 0 (y coordinate shearing)
  `m01` - the value of the transformation matrix in row 0 and column 1 (x coordinate shearing)
  `m11` - the value of the transformation matrix in row 1 and column 1 (y coordinate scaling)
  `m02` - the value of the transformation matrix in row 0 and column 2 (x coordinate translation)
  `m12` - the value of the transformation matrix in row 1 and column 2 (y coordinate translation)

### AffineTransform

public AffineTransform(double[] flatmatrix)
Creates a new `AffineTransform` with its transformation matrix set to the values of the passed-in array. See the `AffineTransform(double, double, double, double, double, double)` or the `AffineTransform(double[])` method for a specification of the values in the array.

Parameters:
  `flatmatrix` - the values for the transformation matrix
See Also:
  - `AffineTransform(double, double, double, double, double, double)`

## Method Details

### clone

public Object clone()

Overrides:
  `clone` in class `Object`

### concatenate

public AffineTransform concatenate(AffineTransform Tx)
Concatenates this `AffineTransform` and the given `AffineTransform`, multiplying the transformation matrix of this `AffineTransform` from the left with the transformation matrix of the other `AffineTransform`.

Parameters:
  `Tx` - the `AffineTransform` that is concatenated with this `AffineTransform`
Returns:
  `this` for convenience

### deltaTransform

public void deltaTransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
Transforms an array of `Point`s specified by their coordinate values with this `AffineTransform` without applying the translation components of the transformation matrix of this `AffineTransform`.

Parameters:
  `srcPts` - the array of x and y coordinates specifying the `Point`s that are transformed
  `srcOff` - the index of the srcPts array where the x coordinate of the first `Point` to transform is found
  `dstPts` - the destination array of x and y coordinates for the result of the transformation
  `dstOff` - the index of the dstPts array where the x coordinate of the first transformed `Point` is stored
  `numPts` - the number of `Point`s to transform

### deltaTransform

public Point deltaTransform(Point pt)
Transforms the given `Point` with this `AffineTransform` without applying the translation components of the transformation matrix of this `AffineTransform`.

Parameters:
  `pt` - the `Point` to transform
Returns:
  a new, transformed `Point`

### equals

public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

### getCopy

public AffineTransform getCopy()
Returns a copy of this `AffineTransform`.

Returns:
  a copy of this `AffineTransform`

### getDeterminant

public double getDeterminant()
Computes the determinant of the transformation matrix of this `AffineTransform`.

Returns:
  the determinant of the transformation matrix of this `AffineTransform`

### getInverse

public AffineTransform getInverse()
Creates a new `AffineTransform` that represents the inverse transformation of this `AffineTransform`.

Returns:
  a new `AffineTransform` that represents the inverse transformation of this `AffineTransform`

### getM00

public double getM00()
Returns the matrix component in the first row and first column.

Returns:
  The matrix component in the first row and first column.

### getM01

public double getM01()
Returns the matrix component in the first row and second column.

Returns:
  The matrix component in the first row and second column.

### getM10

public double getM10()
Returns the matrix component in the second row and first column.

Returns:
  The matrix component in the second row and first column.

### getM11

public double getM11()
Returns the matrix component in the second row and second column.

Returns:
  The matrix component in the second row and second column.

### getMatrix

public double[] getMatrix()
Returns the 6 specifiable elements of the transformation matrix of this `AffineTransform`.

Returns:
  the 6 specifiable elements of the transformation matrix of this `AffineTransform`

### getRotation

public Angle getRotation()
Returns the rotation component of this `AffineTransform`.

Returns:
  The rotation component of this `AffineTransform`.

### getScaleX

public double getScaleX()
Returns the x coordinate scaling of this `AffineTransform`'s transformation matrix.

Returns:
  the x coordinate scaling of this `AffineTransform`'s transformation matrix

### getScaleY

public double getScaleY()
Returns the y coordinate scaling of this `AffineTransform`'s transformation matrix.

Returns:
  the y coordinate scaling of this `AffineTransform`'s transformation matrix

### getTransformed

public Point getTransformed(Point ptSrc)
Transforms the given `Point` with this `AffineTransform` by multiplying the transformation matrix of this `AffineTransform` with the given `Point`.

Parameters:
  `ptSrc` - the `Point` to transform
Returns:
  a new, transformed `Point`

### getTransformed

public Point[] getTransformed(Point[] points)
Transforms the given array of `Point`s with this `AffineTransform` by multiplying the transformation matrix of this `AffineTransform` individually with each of the given `Point` s.

Parameters:
  `points` - array of `Point`s to transform
Returns:
  an array of new, transformed `Point`s

### getTranslateX

public double getTranslateX()
Returns the x coordinate translation of this `AffineTransform`'s transformation matrix.

Returns:
  the x coordinate translation of this `AffineTransform`'s transformation matrix

### getTranslateY

public double getTranslateY()
Returns the y coordinate translation of this `AffineTransform`'s transformation matrix.

Returns:
  the y coordinate translation of this `AffineTransform`'s transformation matrix

### getType

public int getType()
Returns the type of transformation represented by this `AffineTransform`. See the `AffineTransform.getType()` method for a specification of the return type of this method.

Returns:
  the type of transformation represented by this `AffineTransform`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### inverseTransform

public void inverseTransform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts) throws NoninvertibleTransformException
Inverse transforms an array of `Point`s specified by their coordinate values with this `AffineTransform`.

Parameters:
  `srcPts` - the array of x and y coordinates specifying the `Point`s that are inverse transformed
  `srcOff` - the index of the srcPts array where the x coordinate of the first `Point` to inverse transform is found
  `dstPts` - the destination array of x and y coordinates for the result of the inverse transformation
  `dstOff` - the index of the dstPts array where the x coordinate of the first inverse transformed `Point` is stored
  `numPts` - the number of `Point`s to inverse transform
Throws:
  `NoninvertibleTransformException` - when this `AffineTransform` is not invertible.

### inverseTransform

public Point inverseTransform(Point pt) throws NoninvertibleTransformException
Inverse transforms the given `Point` with this `AffineTransform`.

Parameters:
  `pt` - the `Point` to inverse transform
Returns:
  a new, inverse transformed `Point`
Throws:
  `NoninvertibleTransformException` - when this `AffineTransform` is not invertible.

### invert

public AffineTransform invert() throws NoninvertibleTransformException
Inverts this `AffineTransform`.

Returns:
  `this` for convenience
Throws:
  `NoninvertibleTransformException` - when this `AffineTransform` is not invertible.

### isIdentity

public boolean isIdentity()
Checks if the transformation matrix of this `AffineTransform` equals the identity matrix.

Returns:
  `true` if the transformation matrix of this `AffineTransform` equals the identity matrix, otherwise `false`

### preConcatenate

public AffineTransform preConcatenate(AffineTransform Tx)
Concatenates this `AffineTransform` and the given `AffineTransform` in reverse order, multiplying the transformation matrix of this `AffineTransform` from the right with the transformation matrix of the other `AffineTransform`.

Parameters:
  `Tx` - the `AffineTransform` that is concatenated with this `AffineTransform` in reverse order
Returns:
  `this` for convenience

### quadrantRotate

public AffineTransform quadrantRotate(int numquadrants)
Adds a rotation by an integer multiple of 90deg to the transformation matrix of this `AffineTransform`. The integer multiple of 90deg is specified by the given number of quadrants.

Parameters:
  `numquadrants` - the integer that defines the number of quadrants to rotate by
Returns:
  `this` for convenience

### quadrantRotate

public AffineTransform quadrantRotate(int numquadrants, double anchorx, double anchory)
Adds a rotation by an integer multiple of 90deg around the `Point` specified by the given x and y coordinates to the transformation matrix of this `AffineTransform`.

Parameters:
  `numquadrants` - the integer that defines the number of quadrants to rotate by
  `anchorx` - the x coordinate of the `Point` to rotate around
  `anchory` - the y coordinate of the `Point` to rotate around
Returns:
  `this` for convenience

### rotate

public AffineTransform rotate(double theta)
Adds a rotation with the given angle (in radians) to the transformation matrix of this `AffineTransform`.

Parameters:
  `theta` - the rotation angle in radians
Returns:
  `this` for convenience

### rotate

public AffineTransform rotate(double vecx, double vecy)
Adds a rotation to the transformation matrix of this `AffineTransform`. The given coordinates specify a `Vector` whose `Angle` to the x-axis is the applied rotation `Angle`.

Parameters:
  `vecx` - the x coordinate of the `Vector` specifying the rotation `Angle`
  `vecy` - the y coordinate of the `Vector` specifying the rotation `Angle`
Returns:
  `this` for convenience

### rotate

public AffineTransform rotate(double theta, double anchorx, double anchory)
Adds a rotation with the given angle (in radians) around the `Point` specified by the given x and y coordinates to the transformation matrix of this `AffineTransform`.

Parameters:
  `theta` - the rotation angle in radians
  `anchorx` - the x coordinate of the `Point` to rotate around
  `anchory` - the y coordinate of the `Point` to rotate around
Returns:
  `this` for convenience

### rotate

public AffineTransform rotate(double vecx, double vecy, double anchorx, double anchory)
Adds a rotation around a `Point` to the transformation matrix of this `AffineTransform`. The given coordinates specify a `Vector` whose `Angle` to the x-axis is the applied rotation `Angle` and the anchor `Point` for the rotation.

Parameters:
  `vecx` - the x coordinate of the `Vector` specifying the rotation `Angle`
  `vecy` - the y coordinate of the `Vector` specifying the rotation `Angle`
  `anchorx` - the x coordinate of the `Point` to rotate around
  `anchory` - the y coordinate of the `Point` to rotate around
Returns:
  `this` for convenience

### scale

public AffineTransform scale(double sx, double sy)
Adds an x and y scaling to the transformation matrix of this `AffineTransform`.

Parameters:
  `sx` - the x scaling factor added to the transformation matrix of this `AffineTransform`
  `sy` - the y scaling factor added to the transformation matrix of this `AffineTransform`
Returns:
  `this` for convenience

### setToIdentity

public AffineTransform setToIdentity()
Sets the transformation matrix of this `AffineTransform` to the identity matrix.

Returns:
  `this` for convenience

### setToQuadrantRotation

public AffineTransform setToQuadrantRotation(int numquadrants)
Sets the transformation matrix of this `AffineTransform` to a pure rotation matrix where the rotation angle is an integer multiple of 90deg.

Parameters:
  `numquadrants` - the integer that defines the number of quadrants to rotate by
Returns:
  `this` for convenience

### setToQuadrantRotation

public AffineTransform setToQuadrantRotation(int numquadrants, double anchorx, double anchory)
Sets the transformation matrix of this `AffineTransform` to a pure rotation and translation matrix where the rotation angle is an integer multiple of 90deg and the rotation is around the `Point` specified by the given x and y coordinates.

Parameters:
  `numquadrants` - the integer that defines the number of quadrants to rotate by
  `anchorx` - the x coordinate of the `Point` to rotate around
  `anchory` - the y coordinate of the `Point` to rotate around
Returns:
  `this` for convenience

### setToRotation

public AffineTransform setToRotation(double theta)
Sets the transformation matrix of this `AffineTransform` to a pure rotation matrix by the given angle specified in radians.

Parameters:
  `theta` - the rotation angle (in radians)
Returns:
  `this` for convenience

### setToRotation

public AffineTransform setToRotation(double vecx, double vecy)
Sets the transformation matrix of this `AffineTransform` to a pure rotation matrix. The given x and y coordinates specify a `Vector` whose `Angle` to the x-axis defines the rotation `Angle`.

Parameters:
  `vecx` - the x coordinate of the `Vector` whose `Angle` to the x-axis defines the rotation `Angle`
  `vecy` - the y coordinate of the `Vector` whose `Angle` to the x-axis defines the rotation `Angle`
Returns:
  `this` for convenience

### setToRotation

public AffineTransform setToRotation(double theta, double anchorx, double anchory)
Sets the transformation matrix of this `AffineTransform` to a pure rotation and translation matrix. Thus, the resulting transformation matrix rotates `Point`s by the given angle (in radians) around the `Point` specified by the given x and y coordinates.

Parameters:
  `theta` - the rotation angle (in radians)
  `anchorx` - the x coordinate of the `Point` to rotate around
  `anchory` - the y coordinate of the `Point` to rotate around
Returns:
  `this` for convenience

### setToRotation

public AffineTransform setToRotation(double vecx, double vecy, double anchorx, double anchory)
Sets the transformation matrix of this `AffineTransform` to a pure rotation and translation matrix. The firstly given x and y coordinates specify a `Vector` whose `Angle` to the x-axis defines the rotation `Angle`. The secondly given x and y coordinates specify the `Point` to rotate around.

Parameters:
  `vecx` - the x coordinate of the `Vector` whose `Angle` to the x-axis defines the rotation `Angle`
  `vecy` - the y coordinate of the `Vector` whose `Angle` to the x-axis defines the rotation `Angle`
  `anchorx` - the x coordinate of the `Point` to rotate around
  `anchory` - the y coordinate of the `Point` to rotate around
Returns:
  `this` for convenience

### setToScale

public AffineTransform setToScale(double sx, double sy)
Sets the transformation matrix of this `AffineTransform` to a pure scaling matrix.

Parameters:
  `sx` - the x scaling factor
  `sy` - the y scaling factor
Returns:
  `this` for convenience

### setToShear

public AffineTransform setToShear(double shx, double shy)
Sets the transformation matrix of this `AffineTransform` to a pure shearing matrix.

Parameters:
  `shx` - the x shearing factor
  `shy` - the y shearing factor
Returns:
  `this` for convenience

### setToTranslation

public AffineTransform setToTranslation(double tx, double ty)
Sets the transformation matrix of this `AffineTransform` to a pure translation matrix that translates `Point`s by the given x and y values.

Parameters:
  `tx` - the x translation value
  `ty` - the y translation value
Returns:
  `this` for convenience

### setTransform

public AffineTransform setTransform(AffineTransform Tx)
Sets the transformation matrix of this `AffineTransform` to the transformation matrix of the given `AffineTransform`.

Parameters:
  `Tx` - the `AffineTransform` specifying the new transformation matrix of this `AffineTransform`
Returns:
  `this` for convenience

### setTransform

public AffineTransform setTransform(double m00, double m10, double m01, double m11, double m02, double m12)
Sets the respective values of the transformation matrix of this `AffineTransform` to the supplied ones. Note that rotation is a combination of shearing and scaling.

Parameters:
  `m00` - the value of the transformation matrix in row 0 and column 0 (x coordinate scaling)
  `m10` - the value of the transformation matrix in row 1 and column 0 (y coordinate shearing)
  `m01` - the value of the transformation matrix in row 0 and column 1 (x coordinate shearing)
  `m11` - the value of the transformation matrix in row 1 and column 1 (y coordinate scaling)
  `m02` - the value of the transformation matrix in row 0 and column 2 (x coordinate translation)
  `m12` - the value of the transformation matrix in row 1 and column 2 (y coordinate translation)
Returns:
  `this` for convenience

### shear

public AffineTransform shear(double shx, double shy)
Adds an x and y shearing to the transformation matrix of this `AffineTransform`.

Parameters:
  `shx` - the x shearing factor added to the transformation matrix of this `AffineTransform`
  `shy` - the y shearing factor added to the transformation matrix of this `AffineTransform`
Returns:
  `this` for convenience

### toString

public String toString()

Overrides:
  `toString` in class `Object`

### translate

public AffineTransform translate(double tx, double ty)
Sets the translation values of the x and y coordinates of the transformation matrix of this `AffineTransform`.

Parameters:
  `tx` - the x coordinate translation
  `ty` - the y coordinate translation
Returns:
  `this` for convenience