Class CTM

java.lang.Object
org.apache.fop.area.CTM
All Implemented Interfaces:
Serializable

public class CTM extends Object implements Serializable
Describe a PDF or PostScript style coordinate transformation matrix (CTM). The matrix encodes translations, scaling and rotations of the coordinate system used to render pages.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private double
     
    private double
     
    private double
     
    private static final CTM
     
    private static final CTM
     
    private static final CTM
     
    private double
     
    private double
     
    private double
     
    private static final long
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    CTM()
    Create the identity matrix
     
    CTM(double x, double y)
    Initialize a CTM to the identity matrix with a translation specified by x and y
     
    CTM(double a, double b, double c, double d, double e, double f)
    Initialize a CTM from the passed arguments.
     
    Initialize a CTM with the values of an AffineTransform.
    protected
    CTM(CTM ctm)
    Initialize a CTM with the values of another CTM.
  • Method Summary

    Modifier and Type
    Method
    Description
    static CTM
    getCTMandRelDims(int absRefOrient, WritingMode writingMode, Rectangle2D absVPrect, FODimension reldims)
    Construct a coordinate transformation matrix (CTM).
    static CTM
    getWMctm(WritingMode wm, int ipd, int bpd)
    Return a CTM which will transform coordinates for a particular writing-mode into normalized first quandrant coordinates.
    multiply(CTM premult)
    Multiply new passed CTM with this one and generate a new result CTM.
    rotate(double angle)
    Rotate this CTM by "angle" radians and return a new result CTM.
    scale(double x, double y)
    Scale this CTM by the passed x and y values and return a new result CTM.
    Returns this CTM as an AffineTransform object.
    double[]
    Get an array containing the values of this transform.
    Get string for this transform.
    Transform a rectangle by the CTM to produce a rectangle in the transformed coordinate system.
    translate(double x, double y)
    Translate this CTM by the passed x and y values and return a new result CTM.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • a

      private double a
    • b

      private double b
    • c

      private double c
    • d

      private double d
    • e

      private double e
    • f

      private double f
    • CTM_LRTB

      private static final CTM CTM_LRTB
    • CTM_RLTB

      private static final CTM CTM_RLTB
    • CTM_TBRL

      private static final CTM CTM_TBRL
  • Constructor Details

    • CTM

      public CTM()
      Create the identity matrix
    • CTM

      public CTM(double a, double b, double c, double d, double e, double f)
      Initialize a CTM from the passed arguments.
      Parameters:
      a - the x scale
      b - the x shear
      c - the y shear
      d - the y scale
      e - the x shift
      f - the y shift
    • CTM

      public CTM(double x, double y)
      Initialize a CTM to the identity matrix with a translation specified by x and y
      Parameters:
      x - the x shift
      y - the y shift.
    • CTM

      protected CTM(CTM ctm)
      Initialize a CTM with the values of another CTM.
      Parameters:
      ctm - another CTM
    • CTM

      public CTM(AffineTransform at)
      Initialize a CTM with the values of an AffineTransform.
      Parameters:
      at - the transformation matrix
  • Method Details

    • getWMctm

      public static CTM getWMctm(WritingMode wm, int ipd, int bpd)
      Return a CTM which will transform coordinates for a particular writing-mode into normalized first quandrant coordinates.
      Parameters:
      wm - A writing mode constant from fo.properties.WritingMode, ie. one of LR_TB, RL_TB, TB_RL, TB_LR.
      ipd - The inline-progression dimension of the reference area whose CTM is being set..
      bpd - The block-progression dimension of the reference area whose CTM is being set.
      Returns:
      a new CTM with the required transform
    • multiply

      public CTM multiply(CTM premult)
      Multiply new passed CTM with this one and generate a new result CTM.
      Parameters:
      premult - The CTM to multiply with this one. The new one will be the first multiplicand.
      Returns:
      CTM The result of multiplying premult * this.
    • rotate

      public CTM rotate(double angle)
      Rotate this CTM by "angle" radians and return a new result CTM. This is used to account for reference-orientation.
      Parameters:
      angle - The angle in radians. Positive angles are measured counter- clockwise.
      Returns:
      CTM The result of rotating this CTM.
    • translate

      public CTM translate(double x, double y)
      Translate this CTM by the passed x and y values and return a new result CTM.
      Parameters:
      x - The amount to translate along the x axis.
      y - The amount to translate along the y axis.
      Returns:
      CTM The result of translating this CTM.
    • scale

      public CTM scale(double x, double y)
      Scale this CTM by the passed x and y values and return a new result CTM.
      Parameters:
      x - The amount to scale along the x axis.
      y - The amount to scale along the y axis.
      Returns:
      CTM The result of scaling this CTM.
    • transform

      public Rectangle2D transform(Rectangle2D inRect)
      Transform a rectangle by the CTM to produce a rectangle in the transformed coordinate system.
      Parameters:
      inRect - The rectangle in the original coordinate system
      Returns:
      Rectangle2D The rectangle in the transformed coordinate system.
    • toString

      public String toString()
      Get string for this transform.
      Overrides:
      toString in class Object
      Returns:
      a string with the transform values
    • toArray

      public double[] toArray()
      Get an array containing the values of this transform. This creates and returns a new transform with the values in it.
      Returns:
      an array containing the transform values
    • toAffineTransform

      public AffineTransform toAffineTransform()
      Returns this CTM as an AffineTransform object.
      Returns:
      the AffineTransform representation
    • getCTMandRelDims

      public static CTM getCTMandRelDims(int absRefOrient, WritingMode writingMode, Rectangle2D absVPrect, FODimension reldims)
      Construct a coordinate transformation matrix (CTM).
      Parameters:
      absRefOrient - absolute reference orientation
      writingMode - the writing mode
      absVPrect - absolute viewpoint rectangle
      reldims - relative dimensions
      Returns:
      CTM the coordinate transformation matrix (CTM)