I've separated the specific PDFRender functionality from the CTM class
and created a small utility class for the renderer to use.

This solves the problem I was having using the CTM and PDF classes
outside of the FOP context.

-k
Index: org/apache/fop/area/CTM.java
+AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0
RCS file: /home/cvspublic/xml-fop/src/org/apache/fop/area/CTM.java,v
retrieving revision 1.4
diff -u -3 -p -r1.4 CTM.java
--- org/apache/fop/area/CTM.java	18 Jun 2002 13:42:55 -0000	1.4
+-+-+- org/apache/fop/area/CTM.java	30 Jul 2002 11:49:31 -0000
+AEAAQA -207,11 +-207,7 +AEAAQA public class CTM implements Serializable
 	return +ACIAWwAi +- a +- +ACI +ACI +- b +- +ACI +ACI +- c +- +ACI +ACI +- d +- +ACI +ACI +- e +- +ACI +ACI +- f +- +ACIAXQAiADs
     +AH0
 
-    public String toPDFctm() +AHs
-	return a +- +ACI +ACI +- b +- +ACI +ACI +- c +- +ACI +ACI +- d +- +ACI +ACI +- e/1000f +- +ACI +ACI +- f/1000f+ADs
-    +AH0
-
     public double+AFsAXQ toArray() +AHs
-        return new double+AFsAXQ +AHs-a, b, c, d, e / 1000.0, f / 1000.0+AH0AOw
+-        return new double+AFsAXQ +AHs-a, b, c, d, e , f+AH0AOw
     +AH0
 +AH0
Index: org/apache/fop/render/pdf/PDFRenderer.java
+AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0APQA9AD0
RCS file: /home/cvspublic/xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java,v
retrieving revision 1.111
diff -u -3 -p -r1.111 PDFRenderer.java
--- org/apache/fop/render/pdf/PDFRenderer.java	23 Jul 2002 11:06:51 -0000	1.111
+-+-+- org/apache/fop/render/pdf/PDFRenderer.java	30 Jul 2002 11:49:34 -0000
+AEAAQA -11,6 +-11,7 +AEAAQA package org.apache.fop.render.pdf+ADs
 import org.apache.fop.render.PrintRenderer+ADs
 import org.apache.fop.render.XMLHandler+ADs
 import org.apache.fop.render.RendererContext+ADs
+-import org.apache.fop.render.pdf.CTMHelper+ADs
 import org.apache.fop.fo.FOUserAgent+ADs
 import org.apache.fop.image.+ACoAOw
 import org.apache.fop.apps.FOPException+ADs
+AEAAQA -243,11 +-244,11 +AEAAQA public class PDFRenderer extends PrintRe
     protected void startVParea(CTM ctm) +AHs
 	// Set the given CTM in the graphics state
         currentState.push()+ADs
-        currentState.setTransform(new AffineTransform(ctm.toArray()))+ADs
+-        currentState.setTransform(new AffineTransform(CTMHelper.toPDFArray(ctm)))+ADs
 
 	currentStream.add(+ACI-q+AFw-n+ACI)+ADs
 	// multiply with current CTM
-	currentStream.add(ctm.toPDFctm() +- +ACI cm+AFw-n+ACI)+ADs
+-	currentStream.add(CTMHelper.toPDFString(ctm) +- +ACI cm+AFw-n+ACI)+ADs
 	// Set clip?
   currentStream.add(+ACI-BT+AFw-n+ACI)+ADs
     +AH0
/+ACo
 +ACo +ACQ-Id:  +ACQ
 +ACo Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
 +ACo 
 +ACo For details on use and redistribution please refer to the
 +ACo LICENSE file included with these sources.
 +ACo-/
package org.apache.fop.render.pdf+ADs

import org.apache.fop.area.CTM+ADs

/+ACoAKg
 +ACo CTMHelper converts FOP transformation matrixis to those suitable for use by the PDFRender. The e and f elements
 +ACo of the matrix will be divided by 1000 as FOP uses millipoints as it's default user space and PDF uses
 +ACo points.
 +ACo 
 +ACo +AEA-see org.apache.fop.area.CTM
 +ACo 
 +ACo +AEA-author +ADw-a href+AD0AIg-kevin+AEA-rocketred.com+AD4-Kevin O'Neill+ADw-/a+AD4
 +ACo-/
public final class CTMHelper
+AHs
   /+ACoAKg
    +ACo +ADw-p+AD4-Converts the sourceMatrix to a string for use in the PDFRender cm operations.+ADw-/p+AD4
    +ACo +ADw-p+AD4-For example:
    +ACo +ADw-pre+AD4
    +ACo    org.apache.fop.area.CTM ctm +AD0 new org.apache.fop.area.CTM(1.0, 0.0, 0.0, 1.0, 1000.0, 1000.0)+ADs
    +ACo    String pdfMatrix +AD0  org.apache.fop.render.pdf.CTMHelper.toPDFString(ctm)+ADs
    +ACo +ADw-/pre+AD4
    +ACo will return the string +ACIAPA-code+AD4-1.0 0.0 0.0 1.0 1.0 1.0+ADw-/code+AD4AIg.  
    +ACo 
    +ACo +AEA-param sourceMatrix - The matrix to convert.
    +ACo 
    +ACo +AEA-return  a space seperated string containing the matrix elements.
    +ACo 
    +ACo +AEA-throws IllegalArgumentException if the sourceMatrix parameter is null. 
    +ACo-/
   public static String toPDFString(CTM sourceMatrix)
   +AHs
      if (null +AD0APQ sourceMatrix)
      +AHs
         throw new IllegalArgumentException(+ACI-sourceMatrix must not be null+ACI)+ADs
      +AH0
      
      final double matrix+AFsAXQ +AD0 toPDFArray(sourceMatrix)+ADs

      return matrix+AFs-0+AF0 +- +ACI +ACI +- matrix+AFs-1+AF0 +- +ACI +ACI +- matrix+AFs-2+AF0 +- +ACI +ACI +- matrix+AFs-3+AF0 +- +ACI +ACI +- matrix+AFs-4+AF0 +- +ACI +ACI +- matrix+AFs-5+AF0AOw
   +AH0

   /+ACoAKg
    +ACo +ADw-p+AD4-Creates a new CTM based in the sourceMatrix.+ADw-/p+AD4
    +ACo +ADw-p+AD4-For example:
    +ACo +ADw-pre+AD4
    +ACo    org.apache.fop.area.CTM inCTM +AD0 new org.apache.fop.area.CTM(1.0, 0.0, 0.0, 1.0, 1000.0, 1000.0)+ADs
    +ACo    org.apache.fop.area.CTM outCTM org.apache.fop.render.pdf.CTMHelper.toPDFCTM(ctm)+ADs
    +ACo +ADw-/pre+AD4
    +ACo will return a new CTM where a +AD0APQ 1.0, b +AD0APQ 0.0, c +AD0APQ 0.0, d +AD0APQ 1.0, e +AD0APQ 1.0 and f +AD0APQ 1.0.  
    +ACo 
    +ACo +AEA-param sourceMatrix - The matrix to convert.
    +ACo 
    +ACo +AEA-return  a new converted matrix.
    +ACo 
    +ACo +AEA-throws IllegalArgumentException if the sourceMatrix parameter is null. 
    +ACo-/
   public static CTM toPDFCTM(CTM sourceMatrix)
   +AHs
      if (null +AD0APQ sourceMatrix)
      +AHs
         throw new IllegalArgumentException(+ACI-sourceMatrix must not be null+ACI)+ADs
      +AH0
      
      final double matrix+AFsAXQ +AD0 toPDFArray(sourceMatrix)+ADs

      return new CTM(matrix+AFs-0+AF0, matrix+AFs-1+AF0, matrix+AFs-2+AF0, matrix+AFs-3+AF0, matrix+AFs-4+AF0, matrix+AFs-5+AF0)+ADs
   +AH0

   /+ACoAKg
    +ACo +ADw-p+AD4-Creates an array of six doubles from the source CTM.+ADw-/p+AD4
    +ACo +ADw-p+AD4-For example:
    +ACo +ADw-pre+AD4
    +ACo    org.apache.fop.area.CTM inCTM +AD0 new org.apache.fop.area.CTM(1.0, 0.0, 0.0, 1.0, 1000.0, 1000.0)+ADs
    +ACo    double matrix+AFsAXQ +AD0 org.apache.fop.render.pdf.CTMHelper.toPDFArray(ctm)+ADs
    +ACo +ADw-/pre+AD4
    +ACo will return a new array where matrix+AFs-0+AF0 +AD0APQ 1.0, matrix+AFs-1+AF0 +AD0APQ 0.0, matrix+AFs-2+AF0 +AD0APQ 0.0, matrix+AFs-3+AF0 +AD0APQ 1.0,
    +ACo matrix+AFs-4+AF0 +AD0APQ 1.0 and matrix+AFs-5+AF0 +AD0APQ 1.0.  
    +ACo 
    +ACo +AEA-param sourceMatrix - The matrix to convert.
    +ACo 
    +ACo +AEA-return  an array of doubles containing the converted matrix.
    +ACo 
    +ACo +AEA-throws IllegalArgumentException if the sourceMatrix parameter is null. 
    +ACo-/
   public static double+AFsAXQ toPDFArray(CTM sourceMatrix)
   +AHs
      if (null +AD0APQ sourceMatrix)
      +AHs
         throw new IllegalArgumentException(+ACI-sourceMatrix must not be null+ACI)+ADs
      +AH0
      
      final double matrix+AFsAXQ +AD0 sourceMatrix.toArray()+ADs
      
      return new double+AFsAXQ +AHs-matrix+AFs-0+AF0, matrix+AFs-1+AF0, matrix+AFs-2+AF0, matrix+AFs-3+AF0, matrix+AFs-4+AF0 / 1000.0, matrix+AFs-5+AF0 / 1000.0+AH0AOw
   +AH0

+AH0

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to