[ ChangeLog ]
authorGraydon Hoare <graydon@redhat.com>
Fri, 18 Jul 2003 19:20:33 +0000 (19:20 +0000)
committerGraydon Hoare <graydon@gcc.gnu.org>
Fri, 18 Jul 2003 19:20:33 +0000 (19:20 +0000)
2003-07-18  Graydon Hoare  <graydon@redhat.com>

* java/awt/geom/CubicCurve2D.java,
java/awt/geom/Line2D.java,
java/awt/geom/QuadCurve2D.java,
java/awt/geom/Rectangle2D.java:
Fix path some calculations, make path iterators follow
a consistent style.

From-SVN: r69567

libjava/ChangeLog
libjava/java/awt/geom/CubicCurve2D.java
libjava/java/awt/geom/Line2D.java
libjava/java/awt/geom/QuadCurve2D.java
libjava/java/awt/geom/Rectangle2D.java

index 3adf7a52200e8558199063ff437ccf9e7efae12e..e65465028c89ca6875eaf2e9df1f8788d631fb56 100644 (file)
@@ -1,3 +1,12 @@
+2003-07-18  Graydon Hoare  <graydon@redhat.com>
+
+       * java/awt/geom/CubicCurve2D.java,
+       java/awt/geom/Line2D.java,
+       java/awt/geom/QuadCurve2D.java,
+       java/awt/geom/Rectangle2D.java: 
+       Fix path some calculations, make path iterators follow
+       a consistent style.
+
 2003-07-18  Mark Wielaard  <mark@klomp.org>
 
        * java/util/logging/Handler.java (isLoggable): Check record level
index 2d303c7f6a754e3f68af7f8134a4ae591e8076e0..2bc0b358b190bcd3c9166428e176f89d3b762812 100644 (file)
@@ -204,7 +204,7 @@ public abstract class CubicCurve2D implements Shape, Cloneable
     return new PathIterator()
     {
       /** Current coordinate. */
-      private int current;
+      private int current = 0;
 
       public int getWindingRule()
       {
@@ -213,7 +213,7 @@ public abstract class CubicCurve2D implements Shape, Cloneable
 
       public boolean isDone()
       {
-        return current < 2;
+        return current >= 2;
       }
 
       public void next()
@@ -223,52 +223,56 @@ public abstract class CubicCurve2D implements Shape, Cloneable
 
       public int currentSegment(float[] coords)
       {
-        if (current == 0)
+        int result;
+        switch (current)
           {
+          case 0:
             coords[0] = (float) getX1();
             coords[1] = (float) getY1();
-            if (at != null)
-              at.transform(coords, 0, coords, 0, 1);
-            return SEG_MOVETO;
-          }
-        if (current == 1)
-          {
+            result = SEG_MOVETO;
+            break;            
+          case 1:
             coords[0] = (float) getCtrlX1();
             coords[1] = (float) getCtrlY1();
             coords[2] = (float) getCtrlX2();
             coords[3] = (float) getCtrlY2();
             coords[4] = (float) getX2();
             coords[5] = (float) getY2();
-            if (at != null)
-              at.transform(coords, 0, coords, 0, 3);
-            return SEG_CUBICTO;
+            result = SEG_CUBICTO;
+            break;
+          default:
+            throw new NoSuchElementException("cubic iterator out of bounds");            
           }
-        throw new NoSuchElementException("cubic iterator out of bounds");
+        if (at != null)
+          at.transform(coords, 0, coords, 0, 3);
+        return result;
       }
 
       public int currentSegment(double[] coords)
       {
-        if (current == 0)
+        int result;
+        switch (current)
           {
+          case 0:
             coords[0] = getX1();
             coords[1] = getY1();
-            if (at != null)
-              at.transform(coords, 0, coords, 0, 1);
-            return SEG_MOVETO;
-          }
-        if (current == 1)
-          {
+            result = SEG_MOVETO;
+            break;
+          case 1:
             coords[0] = getCtrlX1();
             coords[1] = getCtrlY1();
             coords[2] = getCtrlX2();
             coords[3] = getCtrlY2();
             coords[4] = getX2();
             coords[5] = getY2();
-            if (at != null)
-              at.transform(coords, 0, coords, 0, 3);
-            return SEG_CUBICTO;
-          }
-        throw new NoSuchElementException("cubic iterator out of bounds");
+            result = SEG_CUBICTO;
+            break;
+          default:
+            throw new NoSuchElementException("cubic iterator out of bounds");
+          }        
+        if (at != null)
+          at.transform(coords, 0, coords, 0, 3);
+        return result;
       }
     };
   }
index d2dd65c4341908b095bc7cdfb47a8462f6bab676..15b2ecae80cd0971cd411349b787103c190f9392 100644 (file)
@@ -668,7 +668,7 @@ public abstract class Line2D implements Shape, Cloneable
     return new PathIterator()
     {
       /** Current coordinate. */
-      private int current;
+      private int current = 0;
 
       public int getWindingRule()
       {
@@ -677,7 +677,7 @@ public abstract class Line2D implements Shape, Cloneable
 
       public boolean isDone()
       {
-        return current < 2;
+        return current >= 2;
       }
 
       public void next()
index 05748fc979de7bd1df65c1a476ec66747ce69eed..6aed05907562853b787c1d4916906c4d9842f44e 100644 (file)
@@ -215,7 +215,7 @@ public abstract class QuadCurve2D implements Shape, Cloneable
     return new PathIterator()
     {
       /** Current coordinate. */
-      private int current;
+      private int current = 0;
 
       public int getWindingRule()
       {
@@ -224,7 +224,7 @@ public abstract class QuadCurve2D implements Shape, Cloneable
 
       public boolean isDone()
       {
-        return current < 2;
+        return current >= 2;
       }
 
       public void next()
@@ -234,48 +234,52 @@ public abstract class QuadCurve2D implements Shape, Cloneable
 
       public int currentSegment(float[] coords)
       {
-        if (current == 0)
+        int result;
+        switch (current)
           {
+          case 0:
             coords[0] = (float) getX1();
             coords[1] = (float) getY1();
-            if (at != null)
-              at.transform(coords, 0, coords, 0, 1);
-            return SEG_MOVETO;
-          }
-        if (current == 1)
-          {
+            result = SEG_MOVETO;
+            break;
+          case 1:
             coords[0] = (float) getCtrlX();
             coords[1] = (float) getCtrlY();
             coords[2] = (float) getX2();
             coords[3] = (float) getY2();
-            if (at != null)
-              at.transform(coords, 0, coords, 0, 2);
-            return SEG_QUADTO;
+            result = SEG_QUADTO;
+            break;
+          default:
+            throw new NoSuchElementException("quad iterator out of bounds");
           }
-        throw new NoSuchElementException("quad iterator out of bounds");
+        if (at != null)
+          at.transform(coords, 0, coords, 0, 2);
+        return result;
       }
 
       public int currentSegment(double[] coords)
       {
-        if (current == 0)
+        int result;
+        switch (current)
           {
+          case 0:
             coords[0] = getX1();
             coords[1] = getY1();
-            if (at != null)
-              at.transform(coords, 0, coords, 0, 1);
-            return SEG_MOVETO;
-          }
-        if (current == 1)
-          {
+            result = SEG_MOVETO;
+            break;
+          case 1:
             coords[0] = getCtrlX();
             coords[1] = getCtrlY();
             coords[2] = getX2();
             coords[3] = getY2();
-            if (at != null)
-              at.transform(coords, 0, coords, 0, 2);
-            return SEG_QUADTO;
+            result = SEG_QUADTO;
+            break;
+          default:
+            throw new NoSuchElementException("quad iterator out of bounds");
           }
-        throw new NoSuchElementException("quad iterator out of bounds");
+        if (at != null)
+          at.transform(coords, 0, coords, 0, 2);
+        return result;
       }
     };
   }
index e0a278a575dc837c2d53653f477de43c8eb3df8d..e63e1bad13498f504cb69e1fac125d6845c3ac70 100644 (file)
@@ -395,7 +395,7 @@ public abstract class Rectangle2D extends RectangularShape
     return new PathIterator()
     {
       /** Current coordinate. */
-      private int current = (maxx >= minx && maxy >= miny) ? 6 : 0;
+      private int current = (maxx <= minx && maxy <= miny) ? 6 : 0;
 
       public int getWindingRule()
       {