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
Constructor | Description |
---|---|
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
Field | Description |
---|---|
IdentityTransform |
Methods
Method | Description |
---|---|
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:
Parameter | Type | Description |
---|---|---|
m11 | float | The value in the first row and first column of the new Matrix. |
m12 | float | The value in the first row and second column of the new Matrix. |
m21 | float | The value in the second row and first column of the new Matrix. |
m22 | float | The value in the second row and second column of the new Matrix. |
dx | float | The value in the third row and first column of the new Matrix. |
dy | float | The 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:
Parameter | Type | Description |
---|---|---|
rect | Rectangle | A Rectangle structure that represents the rectangle to be transformed. |
plgpts | Point[] | 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:
Parameter | Type | Description |
---|---|---|
rect | RectangleF | A RectangleF structure that represents the rectangle to be transformed. |
plgpts | PointF[] | 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:
Parameter | Type | Description |
---|---|---|
offsetX | float | The x value by which to translate this Matrix. |
offsetY | float | The 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:
Parameter | Type | Description |
---|---|---|
offsetX | float | The x value by which to translate this Matrix. |
offsetY | float | The y value by which to translate this Matrix. |
order | int | A 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:
Parameter | Type | Description |
---|---|---|
pts | PointF[] | 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:
Parameter | Type | Description |
---|---|---|
scaleX | float | The value by which to scale this Matrix in the x-axis direction. |
scaleY | float | The 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:
Parameter | Type | Description |
---|---|---|
scaleX | float | The value by which to scale this Matrix in the x-axis direction. |
scaleY | float | The value by which to scale this Matrix in the y-axis direction. |
order | int | A 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:
Parameter | Type | Description |
---|---|---|
shearX | float | The horizontal shear factor. |
shearY | float | The 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:
Parameter | Type | Description |
---|---|---|
shearX | float | The horizontal shear factor. |
shearY | float | The vertical shear factor. |
order | int | A 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:
Parameter | Type | Description |
---|---|---|
angle | float | The angle (extent) of the rotation, in degrees. |
point | PointF | A 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:
Parameter | Type | Description |
---|---|---|
angle | float | The angle of the rotation, in degrees. |
point | PointF | A PointF that represents the center of the rotation. |
order | int | A 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:
Parameter | Type | Description |
---|---|---|
pts | PointF[] | 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:
Parameter | Type | Description |
---|---|---|
pts | Point[] | 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:
Parameter | Type | Description |
---|---|---|
matrix | Matrix | The 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:
Parameter | Type | Description |
---|---|---|
matrix | Matrix | The Matrix by which this Matrix is to be multiplied. |
order | int | The 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:
Parameter | Type | Description |
---|---|---|
angle | float | The 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:
Parameter | Type | Description |
---|---|---|
angle | float | The angle of the rotation, in degrees. |
order | int | A 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.