Matrix

Inheritance: java.lang.Object

public final class Matrix

Class represents transformation matrix.

Constructors

ConstructorDescription
Matrix()Constructor creates stanrard 1 to 1 matrix: [ A B C D E F ] = [ 1, 0, 0, 1, 0, 0]
Matrix(double[] matrixArray)Constructor accepts a matrix with following array representation: [ A B C D E F ]
Matrix(float[] matrixArray)Constructor accepts a matrix with following array representation: [ A B C D E F ]
Matrix(Matrix matrix)Constructor accepts a matrix to create a copy
Matrix(System.Drawing.Drawing2D.Matrix matrix)Constructor accepts a matrix to create a copy
Matrix(double a, double b, double c, double d, double e, double f)Initializes transformation matrix with specified coefficients.

Methods

MethodDescription
getData()Gets data of Matrix as array.
getA()Get A member of the transformation matrix.
setA(double value)Set A member of the transformation matrix.
getB()Get B member of the transformation matrix.
setB(double value)Set B member of the transformation matrix.
getC()Get C member of the transformation matrix.
setC(double value)Set C member of the transformation matrix.
getD()Get D member of the transformation matrix.
setD(double value)Set D member of the transformation matrix.
getE()Get E member of the transformation matrix.
setE(double value)Set E member of the transformation matrix.
getF()Get F member of the transformation matrix.
setF(double value)Set F member of the transformation matrix.
isIdentity()Checks whether this matrix is identity.
getElements()Elements of the matrix.
toString()Returns text representation of the matrix.
equals(Object obj)Compares matrix agains other object.
getMatrix(ITrailerable trailer)Translates matrix into PDF array obect.
rotation(double alpha)Creates matrix for given rotation angle.
rotation(int rotation)Creates matrix for given rotation.
skew(double alpha, double beta)Creates matrix for given rotation angle.
scale(double x, double y)Creates matrix for given scale.
scale(double x, double y, double[] x1, double[] y1)Scales x and y with the matrix using the following formula: x1 = A*x + C*y; y1 = B*x + D*y;
unScale(double x1, double y1, double[] x, double[] y)Scales back x1 and y1 and returns x and y before the matrix transformation using the following formula: x = (D * x1 - C * y1) / (A * D - C * B); y = (A* y1 - B* x1) / (A* D - C* B);
getAngle(int rotation)Transaltes rotation into angle (degrees)
multiply(Matrix other)Multiplies the matrix by other matrix.
add(Matrix other)Adds matrix to other matrix.
transform(Point p)Transforms point using this matrix.
transform(double x, double y, double[] x1, double[] y1)Transforms coordinates using this matrix.
unTransform(double x1, double y1, double[] x, double[] y)Transforms back x1 and y1 and returns x and y before the matrix transformation using the following formula: x = (D * x1 - C * y1 + C * F) / (A * D - C * B) y = (A * y1 - B * x1 + B * E) / (A * D - C * B).
transform(Rectangle rect)Transforms rectangle.
reverse()Calculates reverse matrix.
hashCode()Hash-code for object.
isInt16(double value)For Internal usage only
isInt16Values()For Internal usage only

Matrix()

public Matrix()

Constructor creates stanrard 1 to 1 matrix: [ A B C D E F ] = [ 1, 0, 0, 1, 0, 0]


Matrix m = new Matrix();

Matrix(double[] matrixArray)

public Matrix(double[] matrixArray)

Constructor accepts a matrix with following array representation: [ A B C D E F ]


double[] c = new double[] { 1, 0, 0, 1, 10, 20 };
 Matrix m = new Matrix(c);

Parameters:

ParameterTypeDescription
matrixArraydouble[]Matrix data array.

Matrix(float[] matrixArray)

public Matrix(float[] matrixArray)

Constructor accepts a matrix with following array representation: [ A B C D E F ]


double[] c = new double[] { 1, 0, 0, 1, 10, 20 };
 Matrix m = new Matrix(c);

Parameters:

ParameterTypeDescription
matrixArrayfloat[]Matrix data array.

Matrix(Matrix matrix)

public Matrix(Matrix matrix)

Constructor accepts a matrix to create a copy

Parameters:

ParameterTypeDescription
matrixMatrixMatrix object.

Matrix(System.Drawing.Drawing2D.Matrix matrix)

public Matrix(System.Drawing.Drawing2D.Matrix matrix)

Constructor accepts a matrix to create a copy

Parameters:

ParameterTypeDescription
matrixcom.aspose.ms.System.Drawing.Drawing2D.MatrixMatrix object.

Matrix(double a, double b, double c, double d, double e, double f)

public Matrix(double a, double b, double c, double d, double e, double f)

Initializes transformation matrix with specified coefficients.


Matrix m = new Matrix(1, 0, 0, 1, 3, 3);

Parameters:

ParameterTypeDescription
adoubleA matrix value.
bdoubleB matrix value.
cdoubleC matrix value.
ddoubleD matrix value.
edoubleE matrix value.
fdoubleF matrix value.

getData()

public final double[] getData()

Gets data of Matrix as array.

Returns: double[] - array of double values

getA()

public double getA()

Get A member of the transformation matrix.

Returns: double - double value

setA(double value)

public void setA(double value)

Set A member of the transformation matrix.

Parameters:

ParameterTypeDescription
valuedoubledouble value

getB()

public double getB()

Get B member of the transformation matrix.

Returns: double - double value

setB(double value)

public void setB(double value)

Set B member of the transformation matrix.

Parameters:

ParameterTypeDescription
valuedoubledouble value

getC()

public double getC()

Get C member of the transformation matrix.

Returns: double - double value

setC(double value)

public void setC(double value)

Set C member of the transformation matrix.

Parameters:

ParameterTypeDescription
valuedoubledouble value

getD()

public double getD()

Get D member of the transformation matrix.

Returns: double - double value

setD(double value)

public void setD(double value)

Set D member of the transformation matrix.

Parameters:

ParameterTypeDescription
valuedoubledouble value

getE()

public double getE()

Get E member of the transformation matrix.

Returns: double - double value

setE(double value)

public void setE(double value)

Set E member of the transformation matrix.

Parameters:

ParameterTypeDescription
valuedoubledouble value

getF()

public double getF()

Get F member of the transformation matrix.

Returns: double - double value

setF(double value)

public void setF(double value)

Set F member of the transformation matrix.

Parameters:

ParameterTypeDescription
valuedoubledouble value

isIdentity()

public final boolean isIdentity()

Checks whether this matrix is identity.

Returns: boolean - boolean value

getElements()

public float[] getElements()

Elements of the matrix.

Returns: float[] - float[] array

toString()

public String toString()

Returns text representation of the matrix.

Returns: java.lang.String - String representation for the matrix

equals(Object obj)

public boolean equals(Object obj)

Compares matrix agains other object.

Parameters:

ParameterTypeDescription
objjava.lang.ObjectObject to compare.

Returns: boolean - Returns true is other object is Matrix and all matrix member are equal to correspondim members of the matrix

getMatrix(ITrailerable trailer)

public IPdfArray getMatrix(ITrailerable trailer)

Translates matrix into PDF array obect.

Parameters:

ParameterTypeDescription
trailerITrailerableTrailerable object

Returns: IPdfArray - Result of converting

rotation(double alpha)

public static Matrix rotation(double alpha)

Creates matrix for given rotation angle.


Matrix m = Matrix.Rotation(Math.PI / 2);

Parameters:

ParameterTypeDescription
alphadoubleRotation angle in radians.

Returns: Matrix - Transformation matrix.

rotation(int rotation)

public static Matrix rotation(int rotation)

Creates matrix for given rotation.

Parameters:

ParameterTypeDescription
rotationintRotation. Valid values are: None, on90, on180, on270

Returns: Matrix - Matrix instance with rotation.

skew(double alpha, double beta)

public static Matrix skew(double alpha, double beta)

Creates matrix for given rotation angle.

Matrix m = Matrix.skew(Math.PI / 2, Math.PI / 2);

Parameters:

ParameterTypeDescription
alphadoubleSkew x angle in radians.
betadoubleSkew y angle in radians.

Returns: Matrix - Transformation matrix.

scale(double x, double y)

public static Matrix scale(double x, double y)

Creates matrix for given scale.


Matrix m = Matrix.scale(x, y);

Parameters:

ParameterTypeDescription
xdoubleScale x.
ydoubleScale y.

Returns: Matrix - Transformation matrix.

scale(double x, double y, double[] x1, double[] y1)

public final void scale(double x, double y, double[] x1, double[] y1)

Scales x and y with the matrix using the following formula: x1 = A*x + C*y; y1 = B*x + D*y;

Parameters:

ParameterTypeDescription
xdoubleInput X coordinate
ydoubleInput Y coordinate
x1double[]Output X coordinate
y1double[]Output Y coordinate

unScale(double x1, double y1, double[] x, double[] y)

public final void unScale(double x1, double y1, double[] x, double[] y)

Scales back x1 and y1 and returns x and y before the matrix transformation using the following formula: x = (D * x1 - C * y1) / (A * D - C * B); y = (A* y1 - B* x1) / (A* D - C* B);

Parameters:

ParameterTypeDescription
x1doubleInput X coordinate
y1doubleInput Y coordinate
xdouble[]Output X coordinate
ydouble[]Output Y coordinate

getAngle(int rotation)

public static double getAngle(int rotation)

Transaltes rotation into angle (degrees)


double angle = Matrix.getAngle(Rotation.on90);
 Matrix m = Matrix.rotation(angle);

Parameters:

ParameterTypeDescription
rotationintRotation value.

Returns: double - Angle value.

multiply(Matrix other)

public Matrix multiply(Matrix other)

Multiplies the matrix by other matrix.


Matrix a = new Matrix(new double[] { 1, 0, 0, 1, 10, 20 });
 Matrix b = new Matrix(new double[] { 0, -1, 1, 0, 0, 0 } );
 Matrix c= a.multiply(b);

Parameters:

ParameterTypeDescription
otherMatrixMultiplier matrix.

Returns: Matrix - Result of multiplication.

add(Matrix other)

public Matrix add(Matrix other)

Adds matrix to other matrix.

Parameters:

ParameterTypeDescription
otherMatrixMatrix to be added.

Returns: Matrix - Result of matrix add.

transform(Point p)

public Point transform(Point p)

Transforms point using this matrix.

Matrix m = new Matrix(new double[] { 1, 0, 0, 1, 10, 20 } );
 Point p = new Point(5, 5);
 Point p1 = m.transform(p);

Parameters:

ParameterTypeDescription
pPointPoint which will be transformed.

Returns: Point - Transformation result.

transform(double x, double y, double[] x1, double[] y1)

public final void transform(double x, double y, double[] x1, double[] y1)

Transforms coordinates using this matrix.

Matrix m = new Matrix(new double[] { 1, 0, 0, 1, 10, 20 } );
 double x, y, x1, y1;
 m.transform(double x, double y, out double x1, out double y1);

Parameters:

ParameterTypeDescription
xdoubleX coordinate.
ydoubleY coordinate.
x1double[]Transformed X coordinate.
y1double[]Transformed Y coordinate.

unTransform(double x1, double y1, double[] x, double[] y)

public final void unTransform(double x1, double y1, double[] x, double[] y)

Transforms back x1 and y1 and returns x and y before the matrix transformation using the following formula: x = (D * x1 - C * y1 + C * F) / (A * D - C * B) y = (A * y1 - B * x1 + B * E) / (A * D - C * B).

Parameters:

ParameterTypeDescription
x1doubleInput X coordinate
y1doubleInput Y coordinate
xdouble[]Output X coordinate
ydouble[]Output Y coordinate

transform(Rectangle rect)

public Rectangle transform(Rectangle rect)

Transforms rectangle. If angle is not 90 * N degrees then bounding rectangle is returned.


Matrix m = new Matrix(new double[] { 1, 0, 0, 1, 10, 20 } );
 Rectangle r = new Rectangle(0, 0, 100, 100);
 Rectangle r1 = m.transform(r1);

Parameters:

ParameterTypeDescription
rectRectangleRectangle to be transformed.

Returns: Rectangle - Transformed rectangle.

reverse()

public Matrix reverse()

Calculates reverse matrix.


Matrix m = Matrix.rotation(Math.PI / 2);
 Matrix m1 = m.reverse();

Returns: Matrix - Reverse matrix.

hashCode()

public int hashCode()

Hash-code for object.

Returns: int - Hash-code.

isInt16(double value)

public static boolean isInt16(double value)

For Internal usage only

Parameters:

ParameterTypeDescription
valuedoubledouble value

Returns: boolean - boolean value

isInt16Values()

public boolean isInt16Values()

For Internal usage only

Returns: boolean - boolean value