org.apache.fop.render.pdf

Class CTMHelper


public final class CTMHelper
extends java.lang.Object

CTMHelper converts FOP transformation matrices to those suitable for use by the PDFRenderer. The e and f elements of the matrix will be divided by 1000 as FOP uses millipoints as it's default user space and PDF uses points.
See Also:
CTM

Method Summary

static double[]
toPDFArray(CTM sourceMatrix)
Creates an array of six doubles from the source CTM.
static CTM
toPDFCTM(CTM sourceMatrix)
Creates a new CTM based in the sourceMatrix.
static String
toPDFString(AffineTransform transform, boolean convertMillipoints)
Converts the AffineTransform instance to a string for use in the PDFRenderer cm operations.
static String
toPDFString(CTM sourceMatrix)
Converts the sourceMatrix to a string for use in the PDFRenderer cm operations.

Method Details

toPDFArray

public static double[] toPDFArray(CTM sourceMatrix)
Creates an array of six doubles from the source CTM.

For example:

    org.apache.fop.area.CTM inCTM = 
          new org.apache.fop.area.CTM(1.0, 0.0, 0.0, 1.0, 1000.0, 1000.0);
    double matrix[] = org.apache.fop.render.pdf.CTMHelper.toPDFArray(ctm);
 
will return a new array where matrix[0] == 1.0, matrix[1] == 0.0, matrix[2] == 0.0, matrix[3] == 1.0, matrix[4] == 1.0 and matrix[5] == 1.0.
Parameters:
sourceMatrix - - The matrix to convert.
Returns:
an array of doubles containing the converted matrix.

toPDFCTM

public static CTM toPDFCTM(CTM sourceMatrix)
Creates a new CTM based in the sourceMatrix.

For example:

    org.apache.fop.area.CTM inCTM = 
          new org.apache.fop.area.CTM(1.0, 0.0, 0.0, 1.0, 1000.0, 1000.0);
    org.apache.fop.area.CTM outCTM = 
          org.apache.fop.render.pdf.CTMHelper.toPDFCTM(ctm);
 
will return a new CTM where a == 1.0, b == 0.0, c == 0.0, d == 1.0, e == 1.0 and f == 1.0.
Parameters:
sourceMatrix - - The matrix to convert.
Returns:
a new converted matrix.

toPDFString

public static String toPDFString(AffineTransform transform,
                                 boolean convertMillipoints)
Converts the AffineTransform instance to a string for use in the PDFRenderer cm operations.
Parameters:
transform - The matrix to convert.
convertMillipoints - Indicates that the matrix needs to be converted from millipoints to points.
Returns:
a space seperated string containing the matrix elements.

toPDFString

public static String toPDFString(CTM sourceMatrix)
Converts the sourceMatrix to a string for use in the PDFRenderer cm operations.

For example:

    org.apache.fop.area.CTM ctm = 
          new org.apache.fop.area.CTM(1.0, 0.0, 0.0, 1.0, 1000.0, 1000.0);
    String pdfMatrix =  org.apache.fop.render.pdf.CTMHelper.toPDFString(ctm);
 
will return the string "1.0 0.0 0.0 1.0 1.0 1.0".
Parameters:
sourceMatrix - - The matrix to convert.
Returns:
a space seperated string containing the matrix elements.

Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.