org.foray.ps
Class PsMatrix

java.lang.Object
  extended by org.foray.ps.PsObjectComposite
      extended by org.foray.ps.PsArray
          extended by org.foray.ps.PsMatrix
All Implemented Interfaces:
PsObject

public class PsMatrix
extends PsArray

A PostScript matrix, which is a specialized PostScript array.


Field Summary
static byte[] IDENTITY_ELEMENTS
          The non-zero elements of an identity array.
static byte QTY_PS_MATRIX_ELEMENTS
          The number of elements in a PostScript matrix.
 
Constructor Summary
PsMatrix(PsNumber[] value, boolean executable)
          Constructor.
 
Method Summary
static PsMatrix concatMatrices(PsInterpreter4a interpreter, PsMatrix matrix1, PsMatrix matrix2)
          Multiplies the two matrices together and returns the product matrix.
 Dimension2D deltaTransform(Dimension2D distanceVector)
          Performs a delta transform on a distance vector based on this matrix.
protected static PsMatrix identMatrix(PsMatrix matrix)
          Create an ident matrix.
 Dimension2D inverseDeltaTransform(Dimension2D distanceVector)
          Performs an inverse delta transform on a distance vector based on this matrix.
 Point2D inverseTransform(Point2D point)
          Performs an inverse transform on a point based on this matrix.
 boolean isIdentityMatrix()
          Indicates whether this matrix is an identity matrix, that is {1, 0, 0, 1, 0, 0}.
static PsMatrix makeTranslateMatrix(PsInterpreter4a interpreter, PsNumber x, PsNumber y)
          Create a new translate matrix.
 void setMatrixValue(PsMatrix newMatrixValue)
          Sets the matrix value.
 Point2D transform(Point2D point)
          Transforms a point based on this matrix.
 
Methods inherited from class org.foray.ps.PsArray
convertToMatrix, duplicate, get, getTypeName, isComparable, isComposite, isExecutable, set, setExecutable, size
 
Methods inherited from class org.foray.ps.PsObjectComposite
getAccess, setAccess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QTY_PS_MATRIX_ELEMENTS

public static final byte QTY_PS_MATRIX_ELEMENTS
The number of elements in a PostScript matrix.

See Also:
Constant Field Values

IDENTITY_ELEMENTS

public static final byte[] IDENTITY_ELEMENTS
The non-zero elements of an identity array.

Constructor Detail

PsMatrix

public PsMatrix(PsNumber[] value,
                boolean executable)
Constructor.

Parameters:
value - The initial matrix value.
executable - Indicates whether this matrix is executable or not.
Method Detail

setMatrixValue

public void setMatrixValue(PsMatrix newMatrixValue)
Sets the matrix value.

Parameters:
newMatrixValue - The new matrix value.

identMatrix

protected static PsMatrix identMatrix(PsMatrix matrix)
Create an ident matrix.

Parameters:
matrix - The matrix into which the ident values should be placed, or null if a new one should be created.
Returns:
The new or updated matrix object.

transform

public Point2D transform(Point2D point)
Transforms a point based on this matrix.

Parameters:
point - The point to be transformed.
Returns:
The transformed point.

inverseTransform

public Point2D inverseTransform(Point2D point)
Performs an inverse transform on a point based on this matrix.

Parameters:
point - The point to be inverse transformed.
Returns:
The transformed point.

deltaTransform

public Dimension2D deltaTransform(Dimension2D distanceVector)
Performs a delta transform on a distance vector based on this matrix.

Parameters:
distanceVector - The distance vector to be delta transformed.
Returns:
The transformed point.

inverseDeltaTransform

public Dimension2D inverseDeltaTransform(Dimension2D distanceVector)
Performs an inverse delta transform on a distance vector based on this matrix.

Parameters:
distanceVector - The distance vector to be delta transformed.
Returns:
The transformed point.

concatMatrices

public static PsMatrix concatMatrices(PsInterpreter4a interpreter,
                                      PsMatrix matrix1,
                                      PsMatrix matrix2)
                               throws PsInterpreterException4a
Multiplies the two matrices together and returns the product matrix.

Parameters:
interpreter - The PsInterpreter controlling error messages.
matrix1 - The first matrix.
matrix2 - The second matrix.
Returns:
The product matrix.
Throws:
PsInterpreterException4a - If either matrix1 or matrix2 are not exactly 6 elements long.

makeTranslateMatrix

public static PsMatrix makeTranslateMatrix(PsInterpreter4a interpreter,
                                           PsNumber x,
                                           PsNumber y)
Create a new translate matrix.

Parameters:
interpreter - The parent interpreter.
x - The x value.
y - The y value.
Returns:
The new array.

isIdentityMatrix

public boolean isIdentityMatrix()
Indicates whether this matrix is an identity matrix, that is {1, 0, 0, 1, 0, 0}.

Returns:
True iff this matrix is an identity matrix.


Copyright © 2017. All rights reserved.