You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by je...@apache.org on 2007/12/11 14:50:08 UTC

svn commit: r603244 - /xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java

Author: jeremias
Date: Tue Dec 11 05:50:07 2007
New Revision: 603244

URL: http://svn.apache.org/viewvc?rev=603244&view=rev
Log:
Formatting method for matrices and rectangles to arrays.

Modified:
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java?rev=603244&r1=603243&r2=603244&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java Tue Dec 11 05:50:07 2007
@@ -22,8 +22,9 @@
 import java.awt.Color;
 import java.awt.color.ColorSpace;
 import java.awt.geom.AffineTransform;
-import java.io.OutputStream;
+import java.awt.geom.Rectangle2D;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.text.DateFormat;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
@@ -436,25 +437,46 @@
                      matrix[2], matrix[3], 
                      matrix[4], matrix[5]);
     }
-                                
+
+    /**
+     * Formats a transformation matrix.
+     * @param at the AffineTransform with the matrix
+     * @return the formatted transformation matrix (example: "[1 0 0 1 0 0]")
+     */
+    public String formatMatrix(AffineTransform at) {
+        double[] matrix = new double[6];
+        at.getMatrix(matrix);
+        return "[" + formatDouble5(matrix[0]) + " "
+            + formatDouble5(matrix[1]) + " "
+            + formatDouble5(matrix[2]) + " "
+            + formatDouble5(matrix[3]) + " "
+            + formatDouble5(matrix[4]) + " "
+            + formatDouble5(matrix[5]) + "]";
+    }
+    
     /**
      * Concats the transformations matric.
      * @param at the AffineTransform whose matrix to use
      * @exception IOException In case of an I/O problem
      */
     public void concatMatrix(AffineTransform at) throws IOException {
-        double[] matrix = new double[6];
-        at.getMatrix(matrix);
         getCurrentState().concatMatrix(at);
-        writeln("[" + formatDouble5(matrix[0]) + " "
-                + formatDouble5(matrix[1]) + " "
-                + formatDouble5(matrix[2]) + " "
-                + formatDouble5(matrix[3]) + " "
-                + formatDouble5(matrix[4]) + " "
-                + formatDouble5(matrix[5]) + "] concat");
+        writeln(formatMatrix(at) + " concat");
     }
                
     /**
+     * Formats a Rectangle2D to an array.
+     * @param rect the rectangle
+     * @return the formatted array
+     */
+    public String formatRectangleToArray(Rectangle2D rect) {
+        return "[" + formatDouble(rect.getX()) + " "
+        + formatDouble(rect.getY()) + " "
+        + formatDouble(rect.getWidth()) + " "
+        + formatDouble(rect.getHeight()) + "]";
+    }
+    
+    /**
      * Adds a rectangle to the current path.
      * @param x upper left corner
      * @param y upper left corner
@@ -641,5 +663,5 @@
     public boolean isResourceSupplied(PSResource res) {
         return getResourceTracker().isResourceSupplied(res);
     }
-    
+
 }



---------------------------------------------------------------------
Apache XML Graphics Project URL: http://xmlgraphics.apache.org/
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org