Class Matrix

java.lang.Object
com.datalogics.PDFL.Matrix

public class Matrix extends Object
A transformation matrix in a PDF file is specified by six numbers. The matrix is usually in the form of an array containing the six elements [a b c d h v].

A translation is specified as [ 1 0 0 1 tx ty], where tx and ty are the distance to translate from the origin of the coordinate system in the horizontal and vertical dimension, respectively.

A scaling is obtained by [sx 0 0 sy 0 0]. This scales the coordinates so that 1 unit in the horizontal and vertical dimension of the new coordinate system is the same size as sx and sy units, respectively, as in the previous coordinate system.

A rotation is produced by [ cos T sin T -sin T cos T 0 0 ], which has the effect of rotating the coordinate system axes by an angle T (degrees) counterclockwise.

This material indicates that the matrix specifying a transformation is premultiplied with the current transformation matrix, i.e.,

M' = Mt * M

The implementation of the Scale, Rotate, and Translate convenience functions of Matrix reflect the same order of operations, so that they are consistent with the PDF Reference manual. They are also consistent with the scale, rotate, and translate operators in PostScript, from which the coordinate system model in PDF is derived.

  • Constructor Summary

    Constructors
    Constructor
    Description
    the default constructor creates a transformation matrix to translate the rectangle 1 element (1/72nd of an inch) from the origin.
    Matrix(double na, double nb, double nc, double nd, double nh, double nv)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Concatenate a matrix onto an existing matrix.
    void
     
    boolean
     
    double
     
    double
     
    double
     
    double
     
    double
     
    double
     
    Invert the Matrix object and return a new Matrix object.
    static Matrix
    Multiply two transformation matrices.
    rotate(double T)
    Rotate a matrix by T degrees counterclockwise units.
    scale(double sx, double sy)
    Scale a matrix by (sx,sy) units.
    void
    setA(double value)
     
    void
    setB(double value)
     
    void
    setC(double value)
     
    void
    setD(double value)
     
    void
    setH(double value)
     
    void
    setV(double value)
     
     
    translate(double tx, double ty)
    Translate a matrix by (tx,ty) units.

    Methods inherited from class java.lang.Object

    getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Matrix

      public Matrix()
      the default constructor creates a transformation matrix to translate the rectangle 1 element (1/72nd of an inch) from the origin.
    • Matrix

      public Matrix(double na, double nb, double nc, double nd, double nh, double nv)
  • Method Details

    • delete

      public void delete()
    • equals

      public boolean equals(Object rhs)
      Overrides:
      equals in class Object
    • setA

      public void setA(double value)
    • getA

      public double getA()
    • setB

      public void setB(double value)
    • getB

      public double getB()
    • setC

      public void setC(double value)
    • getC

      public double getC()
    • setD

      public void setD(double value)
    • getD

      public double getD()
    • setH

      public void setH(double value)
    • getH

      public double getH()
    • setV

      public void setV(double value)
    • getV

      public double getV()
    • scale

      public Matrix scale(double sx, double sy)
      Scale a matrix by (sx,sy) units. Scaling is done by creating the matrix [sx 0 0 sy 0 0], and calling the Concat function with that matrix.

      Parameters:
      sx - X scaling factor
      sy - Y scaling factor
      Returns:
      the result [sx 0 0 sy 0 0] * M
    • translate

      public Matrix translate(double tx, double ty)
      Translate a matrix by (tx,ty) units. Translation is done by creating the matrix [ 1 0 0 1 tx ty ], and calling the Concat function with that matrix.

      Parameters:
      tx - X translation distance
      ty - Y translation distance
      Returns:
      the result [1 0 0 1 tx ty] * M
    • rotate

      public Matrix rotate(double T)
      Rotate a matrix by T degrees counterclockwise units. Rotation is done by creating the matrix [ cos T sin T -sin T cos T 0 0 ], and calling the Concat function with that matrix.

      Parameters:
      T - The rotation, counterclockwise
      Returns:
      the result [cos T sin T -sin T 0 0] * M
    • concat

      public Matrix concat(Matrix Mt)
      Concatenate a matrix onto an existing matrix. The product returned is:

      M' = Mt * M

      This corresponds to the action of the cm operator.

      Returns:
      the transformed matrix
    • multiply

      public static Matrix multiply(Matrix m1, Matrix m2)
      Multiply two transformation matrices.

      Parameters:
      m1 - a matrix
      m2 - a matrix
      Returns:
      the matrix product m1 x m2
    • invert

      public Matrix invert()
      Invert the Matrix object and return a new Matrix object.
    • toString

      public String toString()
      Overrides:
      toString in class Object