pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1649916 - in /pdfbox/trunk: examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateLandscapePDF.java pdfbox/src/main/java/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.java
Date Tue, 06 Jan 2015 19:43:19 GMT
Author: jahewson
Date: Tue Jan  6 19:43:18 2015
New Revision: 1649916

URL: http://svn.apache.org/r1649916
Log:
PDFBOX-2590: Deprecate concatenate2CTM

Modified:
    pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateLandscapePDF.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.java

Modified: pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateLandscapePDF.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateLandscapePDF.java?rev=1649916&r1=1649915&r2=1649916&view=diff
==============================================================================
--- pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateLandscapePDF.java
(original)
+++ pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateLandscapePDF.java
Tue Jan  6 19:43:18 2015
@@ -24,6 +24,7 @@ import org.apache.pdfbox.pdmodel.common.
 import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
 import org.apache.pdfbox.pdmodel.font.PDFont;
 import org.apache.pdfbox.pdmodel.font.PDType1Font;
+import org.apache.pdfbox.util.Matrix;
 
 /**
  * This is an example of how to create a page with a landscape orientation.
@@ -68,7 +69,7 @@ public class CreateLandscapePDF
             PDPageContentStream contentStream = new PDPageContentStream(doc, page, false,
false);
             // add the rotation using the current transformation matrix
             // including a translation of pageWidth to use the lower left corner as 0,0 reference
-            contentStream.concatenate2CTM(0, 1, -1, 0, pageWidth, 0);
+            contentStream.transform(new Matrix(0, 1, -1, 0, pageWidth, 0));
             contentStream.setFont( font, fontSize );
             contentStream.beginText();
             contentStream.newLineAtOffset(startX, startY);

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.java?rev=1649916&r1=1649915&r2=1649916&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/edit/PDPageContentStream.java
Tue Jan  6 19:43:18 2015
@@ -419,14 +419,12 @@ public class PDPageContentStream impleme
      */
     public void drawInlineImage(PDInlineImage inlineImage, float x, float y, float width,
float height) throws IOException
     {
-        AffineTransform transform = new AffineTransform(width, 0, 0, height, x, y);
-        
         if (inTextMode)
         {
             throw new IOException("Error: drawInlineImage is not allowed within a text block.");
         }
         saveGraphicsState();
-        concatenate2CTM(transform);
+        transform(new Matrix(width, 0, 0, height, x, y));
         appendRawCommands("BI\n");
         appendRawCommands("/W");
         appendRawCommands(SPACE);
@@ -497,7 +495,7 @@ public class PDPageContentStream impleme
         COSName objMapping = resources.add(xobject, xObjectPrefix);
         saveGraphicsState();
         appendRawCommands(SPACE);
-        concatenate2CTM(transform);
+        transform(new Matrix(transform));
         appendRawCommands(SPACE);
         appendCOSName(objMapping);
         appendRawCommands(SPACE);
@@ -682,7 +680,7 @@ public class PDPageContentStream impleme
     }
 
     /**
-     * The Cm operator. Concatenates the current transformation matrix with the given values.
+     * The cm operator. Concatenates the current transformation matrix with the given values.
      * @param a The a value of the matrix.
      * @param b The b value of the matrix.
      * @param c The c value of the matrix.
@@ -690,7 +688,9 @@ public class PDPageContentStream impleme
      * @param e The e value of the matrix.
      * @param f The f value of the matrix.
      * @throws IOException If there is an error writing to the stream.
+     * @deprecated Use {@link #transform} instead.
      */
+    @Deprecated
     public void concatenate2CTM(double a, double b, double c, double d, double e, double
f) throws IOException
     {
         appendRawCommands(a);
@@ -709,17 +709,31 @@ public class PDPageContentStream impleme
     }
 
     /**
-     * The Cm operator. Concatenates the current transformation matrix with the given
+     * The cm operator. Concatenates the current transformation matrix with the given
      * {@link AffineTransform}.
      * @param at the transformation matrix
      * @throws IOException If there is an error writing to the stream.
+     * @deprecated Use {@link #transform} instead.
      */
+    @Deprecated
     public void concatenate2CTM(AffineTransform at) throws IOException
     {
         appendMatrix(at);
         appendRawCommands(CONCATENATE_MATRIX);
     }
 
+    /**
+     * The cm operator. Concatenates the given matrix with the CTM.
+     *
+     * @param matrix the transformation matrix
+     * @throws IOException If there is an error writing to the stream.
+     */
+    public void transform(Matrix matrix) throws IOException
+    {
+        appendMatrix(matrix.createAffineTransform());
+        appendRawCommands(CONCATENATE_MATRIX);
+    }
+
     /**
      * This will draw a string at the current location on the screen.
      *



Mime
View raw message