Sven de Marothy wrote:

On Wed, 14 Jun 2006, David Gilbert wrote:

I'm requesting approval for this patch, just in case I'm missing something
important.

As I understand the getPathIterator(AffineTransform) method defined in the
Shape interface, if you want the path returned without transformation, you can
pass in null for the AffineTransform.  So it is wasteful to create a new
identity transform as we seem to be doing here.


Seems sane to me.

-Sven


Thanks. I committed this along with a similar change to PostscriptGraphics2D (the revised patch is attached):

2006-06-15  David Gilbert  <[EMAIL PROTECTED]>

   * gnu/java/awt/peer/gtk/CairoGraphics2D.java
   (draw(Shape)): Pass null transform to getPathIterator(),
   (getClip): Likewise,
   * gnu/java/print/PostscriptGraphics2D.java
   (drawStringShape): Pass null transform to getPathIterator(),
   (writeShape): Likewise,
   * java/awt/Shape.java: Small updates to API docs.

Regards,

Dave
Index: gnu/java/awt/peer/gtk/CairoGraphics2D.java
===================================================================
RCS file: 
/sources/classpath/classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,v
retrieving revision 1.23
diff -u -r1.23 CairoGraphics2D.java
--- gnu/java/awt/peer/gtk/CairoGraphics2D.java  14 Jun 2006 13:51:04 -0000      
1.23
+++ gnu/java/awt/peer/gtk/CairoGraphics2D.java  15 Jun 2006 08:36:25 -0000
@@ -776,7 +776,7 @@
     else
       {
         GeneralPath p = new GeneralPath();
-        PathIterator pi = clip.getPathIterator(new AffineTransform());
+        PathIterator pi = clip.getPathIterator(null);
         p.append(pi, false);
         return p;
       }
@@ -904,8 +904,7 @@
         // See CubicSegment.getDisplacedSegments().
         if (stroke instanceof BasicStroke)
           {
-            PathIterator flatten = s.getPathIterator(new AffineTransform(),
-                                                       1.0);
+            PathIterator flatten = s.getPathIterator(null, 1.0);
             GeneralPath p = new GeneralPath();
             p.append(flatten, false);
             s = p;
Index: gnu/java/awt/print/PostScriptGraphics2D.java
===================================================================
RCS file: 
/sources/classpath/classpath/gnu/java/awt/print/PostScriptGraphics2D.java,v
retrieving revision 1.1
diff -u -r1.1 PostScriptGraphics2D.java
--- gnu/java/awt/print/PostScriptGraphics2D.java        20 May 2006 07:56:42 
-0000      1.1
+++ gnu/java/awt/print/PostScriptGraphics2D.java        15 Jun 2006 08:36:25 
-0000
@@ -668,7 +668,7 @@
     saveAndInvertAxis();
 
     // draw the shape s with an inverted Y axis.
-    PathIterator pi = s.getPathIterator(new AffineTransform());
+    PathIterator pi = s.getPathIterator(null);
     float[] coords = new float[6];
 
     while (! pi.isDone())
@@ -872,7 +872,7 @@
   /** write a shape to the file */
   private void writeShape(Shape s)
   {
-    PathIterator pi = s.getPathIterator(new AffineTransform());
+    PathIterator pi = s.getPathIterator(null);
     float[] coords = new float[6];
 
     while (! pi.isDone())
Index: java/awt/Shape.java
===================================================================
RCS file: /sources/classpath/classpath/java/awt/Shape.java,v
retrieving revision 1.8
diff -u -r1.8 Shape.java
--- java/awt/Shape.java 2 Jul 2005 20:32:26 -0000       1.8
+++ java/awt/Shape.java 15 Jun 2006 08:36:31 -0000
@@ -1,5 +1,5 @@
 /* Shape.java -- the classic Object-Oriented shape interface
-   Copyright (C) 1999, 2002, 2005  Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002, 2005, 2006,  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -176,7 +176,8 @@
    * not required, that the Shape isolate iterations from future changes to
    * the boundary, and document this fact.
    *
-   * @param transform an optional transform to apply to the iterator
+   * @param transform an optional transform to apply to the 
+   *                  iterator (<code>null</code> permitted).
    * @return a new iterator over the boundary
    * @since 1.2
    */
@@ -185,7 +186,7 @@
   /**
    * Return an iterator along the flattened version of the shape boundary.
    * Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE points are returned in the
-   * iterator. The flatness paramter controls how far points are allowed to
+   * iterator. The flatness parameter controls how far points are allowed to
    * differ from the real curve; although a limit on accuracy may cause this
    * parameter to be enlarged if needed.
    *
@@ -194,10 +195,11 @@
    * use. It is recommended, but not required, that the Shape isolate
    * iterations from future changes to the boundary, and document this fact.
    *
-   * @param transform an optional transform to apply to the iterator
+   * @param transform an optional transform to apply to the 
+   *                  iterator (<code>null</code> permitted).
    * @param flatness the maximum distance for deviation from the real boundary
    * @return a new iterator over the boundary
    * @since 1.2
    */
   PathIterator getPathIterator(AffineTransform transform, double flatness);
-} // interface Shape
+} 

Reply via email to