Matrix

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.ms.System.IDisposable

public final class Matrix implements System.IDisposable

Encapsulates a 3-by-3 affine matrix that represents a geometric transform. This class cannot be inherited.

Constructors

ConstructorDescription
Matrix()Initializes a new instance of the Matrix class as the identity matrix.
Matrix(float m11, float m12, float m21, float m22, float dx, float dy)Initializes a new instance of the Matrix class with the specified elements.
Matrix(Rectangle rect, Point[] plgpts)Initializes a new instance of the Matrix class to the geometric transform defined by the specified rectangle and array of points.
Matrix(RectangleF rect, PointF[] plgpts)Initializes a new instance of the Matrix class to the geometric transform defined by the specified rectangle and array of points.

Fields

FieldDescription
IdentityTransform

Methods

MethodDescription
getElements()Gets an array of floating-point values that represents the elements of this Matrix.
isIdentity()Gets a value indicating whether this Matrix is the identity matrix.
isInvertible()Gets a value indicating whether this Matrix is invertible.
getOffsetX()Gets the x translation value (the dx value, or the element in the third row and first column) of this Matrix.
getOffsetY()Gets the y translation value (the dy value, or the element in the third row and second column) of this Matrix.
dispose()Releases all resources used by this Matrix.
deepClone()Creates an exact copy of this Matrix.
invert()Inverts this Matrix, if it is invertible.
translate(float offsetX, float offsetY)Applies the specified translation vector (offsetX and offsetY) to this Matrix by prepending the translation vector.
translate(float offsetX, float offsetY, int order)Applies the specified translation vector to this Matrix in the specified order.
transformVectors(PointF[] pts)Multiplies each vector in an array by the matrix.
scale(float scaleX, float scaleY)Applies the specified scale vector to this Matrix by prepending the scale vector.
scale(float scaleX, float scaleY, int order)Applies the specified scale vector (scaleX and scaleY) to this Matrix using the specified order.
shear(float shearX, float shearY)Applies the specified shear vector to this Matrix by prepending the shear transformation.
shear(float shearX, float shearY, int order)Applies the specified shear vector to this Matrix in the specified order.
rotateAt(float angle, PointF point)Applies a clockwise rotation to this Matrix around the point specified in the point parameter, and by prepending the rotation.
rotateAt(float angle, PointF point, int order)Applies a clockwise rotation about the specified point to this Matrix in the specified order.
transformPoints(PointF[] pts)Applies the geometric transform represented by this Matrix to a specified array of points.
transformPoints(Point[] pts)Applies the geometric transform represented by this Matrix to a specified array of points.
multiply(Matrix matrix)Multiplies this Matrix by the matrix specified in the matrix parameter, by prepending the specified Matrix.
multiply(Matrix matrix, int order)Multiplies this Matrix by the matrix specified in the matrix parameter, and in the order specified in the order parameter.
rotate(float angle)Prepend to this Matrix a clockwise rotation, around the origin and by the specified angle.
rotate(float angle, int order)Applies a clockwise rotation of an amount specified in the angle parameter, around the origin (zero x and y coordinates) for this Matrix.
reset()Resets this Matrix to have the elements of the identity matrix.

Matrix()

public Matrix()

Initializes a new instance of the Matrix class as the identity matrix.

Matrix(float m11, float m12, float m21, float m22, float dx, float dy)

public Matrix(float m11, float m12, float m21, float m22, float dx, float dy)

Initializes a new instance of the Matrix class with the specified elements.

Parameters:

ParameterTypeDescription
m11floatThe value in the first row and first column of the new Matrix.
m12floatThe value in the first row and second column of the new Matrix.
m21floatThe value in the second row and first column of the new Matrix.
m22floatThe value in the second row and second column of the new Matrix.
dxfloatThe value in the third row and first column of the new Matrix.
dyfloatThe value in the third row and second column of the new Matrix.

Matrix(Rectangle rect, Point[] plgpts)

public Matrix(Rectangle rect, Point[] plgpts)

Initializes a new instance of the Matrix class to the geometric transform defined by the specified rectangle and array of points.

Parameters:

ParameterTypeDescription
rectRectangleA Rectangle structure that represents the rectangle to be transformed.
plgptsPoint[]An array of three Point structures that represents the points of a parallelogram to which the upper-left, upper-right, and lower-left corners of the rectangle is to be transformed. The lower-right corner of the parallelogram is implied by the first three corners.

Matrix(RectangleF rect, PointF[] plgpts)

public Matrix(RectangleF rect, PointF[] plgpts)

Initializes a new instance of the Matrix class to the geometric transform defined by the specified rectangle and array of points.

Parameters:

ParameterTypeDescription
rectRectangleFA RectangleF structure that represents the rectangle to be transformed.
plgptsPointF[]An array of three PointF structures that represents the points of a parallelogram to which the upper-left, upper-right, and lower-left corners of the rectangle is to be transformed. The lower-right corner of the parallelogram is implied by the first three corners.

IdentityTransform

public static final Matrix IdentityTransform

getElements()

public float[] getElements()

Gets an array of floating-point values that represents the elements of this Matrix.

Returns: float[] - an array of floating-point values that represents the elements of this Matrix.

isIdentity()

public boolean isIdentity()

Gets a value indicating whether this Matrix is the identity matrix.

Returns: boolean - a value indicating whether this Matrix is the identity matrix.

isInvertible()

public boolean isInvertible()

Gets a value indicating whether this Matrix is invertible.

Returns: boolean - a value indicating whether this Matrix is invertible.

getOffsetX()

public float getOffsetX()

Gets the x translation value (the dx value, or the element in the third row and first column) of this Matrix.

Returns: float - the x translation value (the dx value, or the element in the third row and first column) of this Matrix.

getOffsetY()

public float getOffsetY()

Gets the y translation value (the dy value, or the element in the third row and second column) of this Matrix.

Returns: float - the y translation value (the dy value, or the element in the third row and second column) of this Matrix.

dispose()

public void dispose()

Releases all resources used by this Matrix.


This method actually does nothing. It’s just for compatibility with System.Drawing API.

deepClone()

public Matrix deepClone()

Creates an exact copy of this Matrix.

Returns: Matrix - The Matrix that this method creates.

invert()

public void invert()

Inverts this Matrix, if it is invertible.

translate(float offsetX, float offsetY)

public void translate(float offsetX, float offsetY)

Applies the specified translation vector (offsetX and offsetY) to this Matrix by prepending the translation vector.

Parameters:

ParameterTypeDescription
offsetXfloatThe x value by which to translate this Matrix.
offsetYfloatThe y value by which to translate this Matrix.

translate(float offsetX, float offsetY, int order)

public void translate(float offsetX, float offsetY, int order)

Applies the specified translation vector to this Matrix in the specified order.

Parameters:

ParameterTypeDescription
offsetXfloatThe x value by which to translate this Matrix.
offsetYfloatThe y value by which to translate this Matrix.
orderintA MatrixOrder that specifies the order (append or prepend) in which the translation is applied to this Matrix.

transformVectors(PointF[] pts)

public void transformVectors(PointF[] pts)

Multiplies each vector in an array by the matrix. The translation elements of this matrix (third row) are ignored.

Parameters:

ParameterTypeDescription
ptsPointF[]An array of PointF structures that represents the points to transform.

scale(float scaleX, float scaleY)

public void scale(float scaleX, float scaleY)

Applies the specified scale vector to this Matrix by prepending the scale vector.

Parameters:

ParameterTypeDescription
scaleXfloatThe value by which to scale this Matrix in the x-axis direction.
scaleYfloatThe value by which to scale this Matrix in the y-axis direction.

scale(float scaleX, float scaleY, int order)

public void scale(float scaleX, float scaleY, int order)

Applies the specified scale vector (scaleX and scaleY) to this Matrix using the specified order.

Parameters:

ParameterTypeDescription
scaleXfloatThe value by which to scale this Matrix in the x-axis direction.
scaleYfloatThe value by which to scale this Matrix in the y-axis direction.
orderintA MatrixOrder that specifies the order (append or prepend) in which the scale vector is applied to this Matrix.

shear(float shearX, float shearY)

public void shear(float shearX, float shearY)

Applies the specified shear vector to this Matrix by prepending the shear transformation.

Parameters:

ParameterTypeDescription
shearXfloatThe horizontal shear factor.
shearYfloatThe vertical shear factor.

shear(float shearX, float shearY, int order)

public void shear(float shearX, float shearY, int order)

Applies the specified shear vector to this Matrix in the specified order.

Parameters:

ParameterTypeDescription
shearXfloatThe horizontal shear factor.
shearYfloatThe vertical shear factor.
orderintA MatrixOrder that specifies the order (append or prepend) in which the shear is applied.

rotateAt(float angle, PointF point)

public void rotateAt(float angle, PointF point)

Applies a clockwise rotation to this Matrix around the point specified in the point parameter, and by prepending the rotation.

Parameters:

ParameterTypeDescription
anglefloatThe angle (extent) of the rotation, in degrees.
pointPointFA PointF that represents the center of the rotation.

rotateAt(float angle, PointF point, int order)

public void rotateAt(float angle, PointF point, int order)

Applies a clockwise rotation about the specified point to this Matrix in the specified order.

Parameters:

ParameterTypeDescription
anglefloatThe angle of the rotation, in degrees.
pointPointFA PointF that represents the center of the rotation.
orderintA MatrixOrder that specifies the order (append or prepend) in which the rotation is applied.

transformPoints(PointF[] pts)

public void transformPoints(PointF[] pts)

Applies the geometric transform represented by this Matrix to a specified array of points.

Parameters:

ParameterTypeDescription
ptsPointF[]An array of PointF structures that represents the points to transform.

transformPoints(Point[] pts)

public void transformPoints(Point[] pts)

Applies the geometric transform represented by this Matrix to a specified array of points.

Parameters:

ParameterTypeDescription
ptsPoint[]An array of Point structures that represents the points to transform.

multiply(Matrix matrix)

public void multiply(Matrix matrix)

Multiplies this Matrix by the matrix specified in the matrix parameter, by prepending the specified Matrix.

Parameters:

ParameterTypeDescription
matrixMatrixThe Matrix by which this Matrix is to be multiplied.

multiply(Matrix matrix, int order)

public void multiply(Matrix matrix, int order)

Multiplies this Matrix by the matrix specified in the matrix parameter, and in the order specified in the order parameter.

Parameters:

ParameterTypeDescription
matrixMatrixThe Matrix by which this Matrix is to be multiplied.
orderintThe MatrixOrder that represents the order of the multiplication.

rotate(float angle)

public void rotate(float angle)

Prepend to this Matrix a clockwise rotation, around the origin and by the specified angle.

Parameters:

ParameterTypeDescription
anglefloatThe angle of the rotation, in degrees.

rotate(float angle, int order)

public void rotate(float angle, int order)

Applies a clockwise rotation of an amount specified in the angle parameter, around the origin (zero x and y coordinates) for this Matrix.

Parameters:

ParameterTypeDescription
anglefloatThe angle of the rotation, in degrees.
orderintA MatrixOrder that specifies the order (append or prepend) in which the rotation is applied to this Matrix.

reset()

public void reset()

Resets this Matrix to have the elements of the identity matrix.