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(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.
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.
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(Rectangle rect)Transformes 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(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

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.

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(Rectangle rect)

public Rectangle transform(Rectangle rect)

Transformes 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