You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/10/16 02:14:57 UTC

svn commit: r464329 - in /incubator/harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/geom/Area.java test/api/java/common/java/awt/geom/AreaTest.java

Author: ndbeyer
Date: Sun Oct 15 17:14:56 2006
New Revision: 464329

URL: http://svn.apache.org/viewvc?view=rev&rev=464329
Log:
Apply modified patch for HARMONY-1860: [classlib][awt] Empty Area returns NULL instead of PathIterator

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/Area.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/Area.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/Area.java?view=diff&rev=464329&r1=464328&r2=464329
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/Area.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/Area.java Sun Oct 15 17:14:56 2006
@@ -24,6 +24,7 @@
 import java.awt.Shape;
 import java.awt.geom.PathIterator;
 import java.awt.geom.Rectangle2D;
+import java.util.NoSuchElementException;
 
 public class Area implements Shape, Cloneable {
 
@@ -32,6 +33,33 @@
      */
     Shape s;
 
+    private static class NullIterator implements PathIterator {
+
+        NullIterator() {
+        }
+
+        public int getWindingRule() {
+            return WIND_NON_ZERO;
+        }
+
+        public boolean isDone() {
+            return true;
+        }
+
+        public void next() {
+            // nothing
+        }
+
+        public int currentSegment(double[] coords) {
+            throw new NoSuchElementException("Iterator out of bounds");
+        }
+
+        public int currentSegment(float[] coords) {
+            throw new NoSuchElementException("Iterator out of bounds");
+        }
+
+    }
+
     public Area() {
     }
 
@@ -88,11 +116,11 @@
     }
 
     public PathIterator getPathIterator(AffineTransform t) {
-        return s == null ? null : s.getPathIterator(t);
+        return s == null ? new NullIterator() : s.getPathIterator(t);
     }
 
     public PathIterator getPathIterator(AffineTransform t, double flatness) {
-        return s == null ? null : s.getPathIterator(t, flatness);
+        return s == null ? new NullIterator() : s.getPathIterator(t, flatness);
     }
 
     public void add(Area area) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java?view=diff&rev=464329&r1=464328&r2=464329
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java Sun Oct 15 17:14:56 2006
@@ -20,9 +20,7 @@
  */
 package java.awt.geom;
 
-import junit.framework.TestCase;
-
-public class AreaTest extends TestCase {
+public class AreaTest extends PathIteratorTestCase {
 
     public AreaTest(String name) {
         super(name);
@@ -75,6 +73,14 @@
         } catch (NullPointerException e) {
             // expected
         }
+    }
+    
+    public void testGetPathIterator() {
+        // Regression test HARMONY-1860
+        Area a = new Area();
+        PathIterator path = a.getPathIterator(null);
+        checkPathRule(path, PathIterator.WIND_NON_ZERO);
+        checkPathDone(path, true);
     }
 
 }