You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2007/06/18 09:37:03 UTC

svn commit: r548243 [2/5] - in /harmony/enhanced/classlib/branches/java6: ./ make/ modules/archive/src/main/java/java/util/jar/ modules/awt/ modules/awt/src/main/java/common/java/awt/geom/ modules/awt/src/main/java/common/org/apache/harmony/awt/geom/ m...

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/build.xml?view=diff&rev=548243&r1=548242&r2=548243
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/build.xml (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/build.xml Mon Jun 18 00:36:49 2007
@@ -138,7 +138,7 @@
     </target>
 
     <target name="build-native"
-        depends="-build-native-unix,-build-native-windows">
+        depends="-build-native-unix,-build-native-windows,-build-native-x86">
         <make dir="${hy.awt.src.main.native}/lcmm/${hy.os.family}" />
         <!-- Copy the built shared libs over to the jre/bin dir -->
         <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
@@ -178,16 +178,6 @@
                 <exclude name="*${manifest.suffix}"/>
             </fileset>
         </copy>
-
-        <make dir="${hy.awt.src.main.native}/fontlib/${hy.os.family}" />
-        <!-- Copy the built shared libs over to the jre/bin dir -->
-        <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
-            <fileset dir="${hy.awt.src.main.native}/fontlib">
-                <include name="*${shlib.suffix}*"/>
-                <include name="*${progdb.suffix}*" if="is.windows" />
-                <exclude name="*${manifest.suffix}"/>
-            </fileset>
-        </copy>
     </target>
 
     <target name="-build-native-unix" if="is.unix">
@@ -230,6 +220,18 @@
         </copy>
     </target>
 
+    <target name="-build-native-x86" if="is.x86">
+        <make dir="${hy.awt.src.main.native}/fontlib/${hy.os.family}" />
+        <!-- Copy the built shared libs over to the jre/bin dir -->
+        <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
+            <fileset dir="${hy.awt.src.main.native}/fontlib">
+                <include name="*${shlib.suffix}*"/>
+                <include name="*${progdb.suffix}*" if="is.windows" />
+                <exclude name="*${manifest.suffix}"/>
+            </fileset>
+        </copy>
+    </target>
+
     <target name="clean-native"
             depends="-clean-native-unix,-clean-native-windows">
         <make dir="${hy.awt.src.main.native}/lcmm/${hy.os.family}"
@@ -239,6 +241,8 @@
         <make dir="${hy.awt.src.main.native}/gl/${hy.os.family}"
               target="clean"/>
         <make dir="${hy.awt.src.main.native}/oglwrapper/${hy.os.family}"
+              target="clean"/>
+        <make dir="${hy.awt.src.main.native}/fontlib/${hy.os.family}"
               target="clean"/>
     </target>
 

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/geom/Area.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/geom/Area.java?view=diff&rev=548243&r1=548242&r2=548243
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/geom/Area.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/main/java/common/java/awt/geom/Area.java Mon Jun 18 00:36:49 2007
@@ -14,199 +14,1287 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/**
- * @author Denis M. Kishenko
- * @version $Revision$
- */
 package java.awt.geom;
 
 import java.awt.Rectangle;
 import java.awt.Shape;
-import java.awt.geom.PathIterator;
-import java.awt.geom.Rectangle2D;
 import java.util.NoSuchElementException;
 
+import org.apache.harmony.awt.gl.Crossing;
+import org.apache.harmony.awt.geom.CrossingHelper;
+import org.apache.harmony.awt.geom.CurveCrossingHelper;
+import org.apache.harmony.awt.geom.GeometryUtil;
+import org.apache.harmony.awt.geom.IntersectPoint;
 import org.apache.harmony.awt.internal.nls.Messages;
 
+
 public class Area implements Shape, Cloneable {
 
     /**
-     * The source Shape object
+     * the coordinates array of the shape vertices
      */
-    Shape s;
-
-    private static class NullIterator implements PathIterator {
-
-        NullIterator() {
-        }
-
-        public int getWindingRule() {
-            return WIND_NON_ZERO;
-        }
-
-        public boolean isDone() {
-            return true;
-        }
+	private double coords[] = new double[20];
+	
+	/**
+	 * the coordinates quantity
+	 */
+	private int coordsSize = 0;
+	
+	/**
+	 * the rules array for the drawing of the shape edges
+	 */
+	private int rules[] = new int[10];
+	
+	/**
+	 * the rules quantity
+	 */
+	private int rulesSize = 0;
+	
+	/**
+	 * offsets[i] - index in array of coords and i - index in array of rules
+	 */
+	private int offsets[] = new int[10];
+	
+	/**
+	 * the quantity of MOVETO rule occurences
+	 */
+	private int moveToCount = 0;
+	
+	/**
+	 * true if the shape is polygon
+	 */
+	private boolean isPolygonal = true;
+
+	public Area() {
+	}
+
+	public Area(Shape s) {
+		double segmentCoords[] = new double[6];
+		double lastMoveX = 0.0;
+		double lastMoveY = 0.0;
+		int rulesIndex = 0;
+		int coordsIndex = 0;
+		
+		for (PathIterator pi = s.getPathIterator(null); 
+		        !pi.isDone(); pi.next()) {
+			coords = adjustSize(coords, coordsIndex + 6);
+			rules = adjustSize(rules, rulesIndex + 1);
+			offsets = adjustSize(offsets, rulesIndex + 1);
+			rules[rulesIndex] = pi.currentSegment(segmentCoords);
+			offsets[rulesIndex] = coordsIndex;
+			
+			switch (rules[rulesIndex]) {
+                case PathIterator.SEG_MOVETO:
+                    coords[coordsIndex++] = segmentCoords[0];
+                    coords[coordsIndex++] = segmentCoords[1];
+                    lastMoveX = segmentCoords[0];
+                    lastMoveY = segmentCoords[1];
+                    ++moveToCount;
+                    break;
+                case PathIterator.SEG_LINETO:
+                    if ((segmentCoords[0] != lastMoveX) || 
+                    		(segmentCoords[1] != lastMoveY)) {
+                        coords[coordsIndex++] = segmentCoords[0];
+                        coords[coordsIndex++] = segmentCoords[1];
+                    } else {
+                        --rulesIndex;
+                    }
+                    break;
+                case PathIterator.SEG_QUADTO:
+                    System.arraycopy(segmentCoords, 0, coords, coordsIndex, 4);
+                    coordsIndex += 4;
+                    isPolygonal = false;
+                    break;
+                case PathIterator.SEG_CUBICTO:
+                    System.arraycopy(segmentCoords, 0, coords, coordsIndex, 6);
+                    coordsIndex += 6;
+                    isPolygonal = false;
+                    break;
+                case PathIterator.SEG_CLOSE:
+                    break;
+            }
+            ++rulesIndex;
+		}
+		
+		if ((rulesIndex != 0) && 
+				(rules[rulesIndex - 1] != PathIterator.SEG_CLOSE)) {
+			rules[rulesIndex] = PathIterator.SEG_CLOSE;
+			offsets[rulesIndex] = coordsSize;
+		}
+		
+		rulesSize = rulesIndex;
+		coordsSize = coordsIndex;
+	}
+
+	public boolean contains(double x, double y) {
+        return !isEmpty() &&
+                   containsExact(x, y) > 0;
+    }
+
+	public boolean contains(double x, double y, double width, double height) {
+		int crossCount = Crossing.intersectPath(getPathIterator(null), x, y,
+				width, height);
+		return crossCount != Crossing.CROSSING &&
+			       Crossing.isInsideEvenOdd(crossCount);
+	}
+
+	public boolean contains(Point2D p) {
+		return contains(p.getX(), p.getY());
+	}
+
+	public boolean contains(Rectangle2D r) {
+		return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+	}
+
+	public boolean equals(Area obj) {
+		if (this == obj) {
+			return true;
+		}
+		
+		if (obj == null) {
+			return false;
+		}
+		
+		Area area = (Area)clone();
+		area.subtract(obj);
+		return area.isEmpty();
+	}
+
+	public boolean intersects(double x, double y, double width, double height) {
+		if ((width <= 0.0) || (height <= 0.0)) {
+			return false;
+		} else if (!getBounds2D().intersects(x, y, width, height)) {
+			return false;
+		}
+		
+		int crossCount = Crossing.intersectShape(this, x, y, width, height);
+		return Crossing.isInsideEvenOdd(crossCount);
+	}
+
+	public boolean intersects(Rectangle2D r) {
+		return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
+	}
+
+	public Rectangle getBounds() {
+		return getBounds2D().getBounds();
+	}
+
+	public Rectangle2D getBounds2D() {
+		double maxX = coords[0];
+		double maxY = coords[1];
+		double minX = coords[0];
+		double minY = coords[1];
+
+		for (int i = 0; i < coordsSize;) {
+			minX = Math.min(minX, coords[i]);
+			maxX = Math.max(maxX, coords[i++]);
+			minY = Math.min(minY, coords[i]);
+			maxY = Math.max(maxY, coords[i++]);
+		}
+		
+		return new Rectangle2D.Double(minX, minY, maxX - minX, maxY - minY);
+	}
+
+	public PathIterator getPathIterator(AffineTransform t) {
+		return new AreaPathIterator(this, t);
+	}
+	
+	public PathIterator getPathIterator(AffineTransform t, double flatness) {
+		return new FlatteningPathIterator(getPathIterator(t), flatness);
+	}
+	
+	public boolean isEmpty() {
+		return (rulesSize == 0) && (coordsSize == 0);
+	}
+
+	public boolean isPolygonal() {
+		return isPolygonal;
+	}
+
+	public boolean isRectangular() {
+        return (isPolygonal) && (rulesSize <= 5) && (coordsSize <= 8) &&
+               (coords[1] == coords[3]) && (coords[7] == coords[5]) &&
+               (coords[0] == coords[6]) && (coords[2] == coords[4]);
+    }
+
+	public boolean isSingular() {
+		return (moveToCount <= 1);
+	}
+
+	public void reset() {
+		coordsSize = 0;
+		rulesSize = 0;
+	}
+
+	public void transform(AffineTransform t) {
+		copy(new Area(t.createTransformedShape(this)), this);
+	}
+
+	public Area createTransformedArea(AffineTransform t) {
+		return new Area(t.createTransformedShape(this));
+	}
+
+	public Object clone() {
+		Area area = new Area();
+		copy(this, area);
+		return area;
+	}
+
+	public void add(Area area) {
+		if (isPolygonal() && area.isPolygonal()) {
+			addPolygon(area);
+		} else {
+			addCurvePolygon(area);
+		}
+	}
+	   
+	public void intersect(Area area) {
+		if (isPolygonal() && area.isPolygonal()) {
+			intersectPolygon(area);
+		} else {
+			intersectCurvePolygon(area);
+		}
+	}
+	
+	public void subtract(Area area) {
+		if (isPolygonal() && area.isPolygonal()) {
+			subtractPolygon(area);
+		} else {
+			subtractCurvePolygon(area);
+		}
+	}
+	
+ 	public void exclusiveOr(Area area) {
+		Area a = (Area) clone();
+		a.intersect(area);
+		add(area);
+		subtract(a);
+	}
+
+	private void addCurvePolygon(Area area) {
+		CurveCrossingHelper crossHelper = new CurveCrossingHelper(
+	            new double[][] { coords, area.coords },  
+		        new int[] { coordsSize, area.coordsSize }, 
+		        new int[][] { rules, area.rules },
+				new int[] { rulesSize, area.rulesSize }, 
+				new int[][] { offsets, area.offsets });
+		IntersectPoint[] intersectPoints = crossHelper.findCrossing();
+
+		if (intersectPoints.length == 0) {
+			if (area.contains(getBounds2D())) {
+				copy(area, this);
+			} else if (!contains(area.getBounds2D())) {
+				coords = adjustSize(coords, coordsSize + area.coordsSize);
+				System.arraycopy(area.coords, 0, coords, coordsSize,
+								 area.coordsSize);
+				coordsSize += area.coordsSize;
+				rules = adjustSize(rules, rulesSize + area.rulesSize);
+				System.arraycopy(area.rules, 0, rules, rulesSize, 
+								 area.rulesSize);
+				rulesSize += area.rulesSize;
+				offsets = adjustSize(offsets, rulesSize + area.rulesSize);
+				System.arraycopy(area.offsets, 0, offsets, rulesSize, 
+								 area.rulesSize);
+			}
+			
+			return;
+		}
+
+        double[] resultCoords = new double[coordsSize + area.coordsSize + 
+                                                       intersectPoints.length];
+        int[] resultRules = new int[rulesSize + area.rulesSize + 
+                                                       intersectPoints.length];
+        int[] resultOffsets = new int[rulesSize + area.rulesSize + 
+                                                       intersectPoints.length];
+        int resultCoordPos = 0;
+        int resultRulesPos = 0;
+        boolean isCurrentArea = true;
+
+        IntersectPoint point = intersectPoints[0];
+        resultRules[resultRulesPos] = PathIterator.SEG_MOVETO;
+        resultOffsets[resultRulesPos++] = resultCoordPos;
+        
+        do {
+        	resultCoords[resultCoordPos++] = point.getX();
+            resultCoords[resultCoordPos++] = point.getY();
+            int curIndex = point.getEndIndex(true);
+            
+            if (curIndex < 0) {
+            	isCurrentArea = !isCurrentArea;
+            } else if (area.containsExact(coords[2 * curIndex], 
+            		                      coords[2 * curIndex + 1]) > 0) { 
+            	isCurrentArea = false;
+            } else {
+            	isCurrentArea = true;
+            }
 
-        public void next() {
-            // nothing
-        }
+            IntersectPoint nextPoint = getNextIntersectPoint(intersectPoints, 
+                                                             point, 
+                                                             isCurrentArea);
+            double[] coords = (isCurrentArea) ? this.coords : area.coords;
+            int[] offsets = (isCurrentArea) ? this.offsets : area.offsets;
+            int[] rules = (isCurrentArea) ? this.rules : area.rules;
+            int offset = point.getRuleIndex(isCurrentArea);
+            boolean isCopyUntilZero = false;
+            
+            if ((point.getRuleIndex(isCurrentArea) > 
+                    nextPoint.getRuleIndex(isCurrentArea))) {
+            	int rulesSize = (isCurrentArea) ? this.rulesSize : 
+            		                              area.rulesSize;
+            	resultCoordPos = includeCoordsAndRules(offset + 1, rulesSize,
+            			                               rules, offsets, 
+            			                               resultRules, 
+            			                               resultOffsets, 
+            			                               resultCoords, coords, 
+            			                               resultRulesPos, 
+            			                               resultCoordPos,
+            			                               point, isCurrentArea, 
+            			                               false, 0);
+            	resultRulesPos += rulesSize - offset - 1; 
+            	offset = 1;
+            	isCopyUntilZero = true;
+            }
+            
+            int length = nextPoint.getRuleIndex(isCurrentArea) - offset + 1;
+            
+            if (isCopyUntilZero) {
+            	offset = 0;
+            }
+            
+           	resultCoordPos = includeCoordsAndRules(offset, length, rules, 
+           			                               offsets, resultRules, 
+           			                               resultOffsets, resultCoords,
+           			                               coords, resultRulesPos, 
+           			                               resultCoordPos, point, 
+           			                               isCurrentArea, true, 0);
+            resultRulesPos += length - offset; 
+            point = nextPoint;
+        } while (point != intersectPoints[0]);
+        
+        resultRules[resultRulesPos++] = PathIterator.SEG_CLOSE;
+        resultOffsets[resultRulesPos - 1] = resultCoordPos;
+		this.coords = resultCoords;
+		this.rules = resultRules;
+		this.offsets = resultOffsets;
+		this.coordsSize = resultCoordPos;
+		this.rulesSize = resultRulesPos;
+	}
+
+    private void addPolygon(Area area) {
+		CrossingHelper crossHelper = new CrossingHelper(new double[][] {coords,
+				                                        area.coords }, 
+				                                        new int[] {coordsSize, 
+				                                        area.coordsSize });
+		IntersectPoint[] intersectPoints = crossHelper.findCrossing();
+
+		if (intersectPoints.length == 0) {
+			if (area.contains(getBounds2D())) {
+				copy(area, this);
+			} else if (!contains(area.getBounds2D())) {
+				coords = adjustSize(coords, coordsSize + area.coordsSize);
+				System.arraycopy(area.coords, 0, coords, coordsSize,
+								 area.coordsSize);
+				coordsSize += area.coordsSize;
+				rules = adjustSize(rules, rulesSize + area.rulesSize);
+				System.arraycopy(area.rules, 0, rules, rulesSize, 
+								 area.rulesSize);
+				rulesSize += area.rulesSize;
+				offsets = adjustSize(offsets, rulesSize + area.rulesSize);
+				System.arraycopy(area.offsets, 0, offsets, rulesSize, 
+								 area.rulesSize);
+			}
+			return;
+		}
+
+        double[] resultCoords = new double[coordsSize + area.coordsSize + 
+                                                       intersectPoints.length];
+        int[] resultRules = new int[rulesSize + area.rulesSize + 
+                                                       intersectPoints.length];
+        int[] resultOffsets = new int[rulesSize + area.rulesSize + 
+                                                       intersectPoints.length];
+        int resultCoordPos = 0;
+        int resultRulesPos = 0;
+        boolean isCurrentArea = true;
+
+        IntersectPoint point = intersectPoints[0];
+        resultRules[resultRulesPos] = PathIterator.SEG_MOVETO;
+        resultOffsets[resultRulesPos++] = resultCoordPos;
+        
+        do {
+        	resultCoords[resultCoordPos++] = point.getX();
+            resultCoords[resultCoordPos++] = point.getY();
+            resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
+            resultOffsets[resultRulesPos++] = resultCoordPos - 2;
+            int curIndex = point.getEndIndex(true);
+            if (curIndex < 0) {
+            	isCurrentArea = !isCurrentArea;
+            } else if (area.containsExact(coords[2 * curIndex], 
+            		                      coords[2 * curIndex + 1]) > 0) { 
+            	isCurrentArea = false;
+            } else {
+            	isCurrentArea = true;
+            }
 
-        public int currentSegment(double[] coords) {
-            // awt.4B=Iterator out of bounds
-            throw new NoSuchElementException(Messages.getString("awt.4B")); //$NON-NLS-1$
-        }
+            IntersectPoint nextPoint = getNextIntersectPoint(intersectPoints, 
+            		                                         point, 
+            		                                         isCurrentArea);
+            double[] coords = (isCurrentArea) ? this.coords : area.coords;
+            int offset = 2 * point.getEndIndex(isCurrentArea);
+ 
+            if (nextPoint.getBegIndex(isCurrentArea) < 
+            		point.getEndIndex(isCurrentArea)) {
+                int coordSize = (isCurrentArea) ? this.coordsSize : 
+                	                              area.coordsSize;
+                int length = coordSize - offset;
+                System.arraycopy(coords, offset, 
+                		         resultCoords, resultCoordPos, length);
+                
+                for (int i = 0; i < length / 2; i++) {
+                	resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
+                	resultOffsets[resultRulesPos++] = resultCoordPos;
+                	resultCoordPos += 2;
+                }
+                
+                offset = 0;
+            }
+            
+            int length = 2 * nextPoint.getBegIndex(isCurrentArea) - offset + 2;
+            System.arraycopy(coords, offset, 
+            		         resultCoords, resultCoordPos, length);
+            
+            for (int i = 0; i < length / 2; i++) {
+            	resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
+            	resultOffsets[resultRulesPos++] = resultCoordPos;
+            	resultCoordPos += 2;
+            }
 
-        public int currentSegment(float[] coords) {
-            // awt.4B=Iterator out of bounds
-            throw new NoSuchElementException(Messages.getString("awt.4B")); //$NON-NLS-1$
+            point = nextPoint;
+        } while (point != intersectPoints[0]);
+        
+        resultRules[resultRulesPos - 1] = PathIterator.SEG_CLOSE;
+        resultOffsets[resultRulesPos - 1] = resultCoordPos;
+		coords = resultCoords;
+		rules = resultRules;
+		offsets = resultOffsets;
+		coordsSize = resultCoordPos;
+		rulesSize = resultRulesPos;
+	}
+    
+ 	private void intersectCurvePolygon(Area area) {
+		CurveCrossingHelper crossHelper = new CurveCrossingHelper(
+				new double[][] {coords, area.coords }, 
+				new int[] { coordsSize, area.coordsSize }, 
+				new int[][] { rules, area.rules },
+				new int[] { rulesSize, area.rulesSize }, 
+				new int[][] { offsets, area.offsets });
+		IntersectPoint[] intersectPoints = crossHelper.findCrossing();
+
+		if (intersectPoints.length == 0) {
+			if (contains(area.getBounds2D())) {
+				copy(area, this);
+			} else if (!area.contains(getBounds2D())) {
+				reset();
+			}
+			return;
+		}
+
+        double[] resultCoords = new double[coordsSize + area.coordsSize + 
+                                                       intersectPoints.length];
+        int[] resultRules = new int[rulesSize + area.rulesSize + 
+                                                       intersectPoints.length];
+        int[] resultOffsets = new int[rulesSize + area.rulesSize + 
+                                                       intersectPoints.length];
+        int resultCoordPos = 0;
+        int resultRulesPos = 0;
+        boolean isCurrentArea = true;
+
+        IntersectPoint point = intersectPoints[0];
+        IntersectPoint nextPoint = intersectPoints[0];
+        resultRules[resultRulesPos] = PathIterator.SEG_MOVETO;
+        resultOffsets[resultRulesPos++] = resultCoordPos;
+        
+        do {
+        	resultCoords[resultCoordPos++] = point.getX();
+            resultCoords[resultCoordPos++] = point.getY();
+ 
+            int curIndex = point.getEndIndex(true);
+            if ((curIndex < 0) || (area.containsExact(
+            		coords[2 * curIndex], coords[2 * curIndex + 1]) == 0)) {
+            	isCurrentArea = !isCurrentArea;
+            } else if (area.containsExact(coords[2 * curIndex], 
+            		                      coords[2 * curIndex + 1]) > 0) { 
+            	isCurrentArea = true;
+            } else {
+            	isCurrentArea = false;
+            }
+            
+            nextPoint = getNextIntersectPoint(intersectPoints, point, isCurrentArea);
+            double[] coords = (isCurrentArea) ? this.coords : area.coords;
+            int[] offsets = (isCurrentArea) ? this.offsets : area.offsets;
+            int[] rules = (isCurrentArea) ? this.rules : area.rules;
+            int offset = point.getRuleIndex(isCurrentArea);
+            boolean isCopyUntilZero = false;
+            
+            if (point.getRuleIndex(isCurrentArea) > 
+                    nextPoint.getRuleIndex(isCurrentArea)) {
+            	int rulesSize = (isCurrentArea) ? this.rulesSize : 
+            		                              area.rulesSize;
+            	resultCoordPos = includeCoordsAndRules(offset + 1, rulesSize, 
+            			                               rules, offsets, 
+            			                               resultRules, 
+            			                               resultOffsets, 
+            			                               resultCoords, coords, 
+            			                               resultRulesPos, 
+            			                               resultCoordPos, point, 
+            			                               isCurrentArea, false, 
+            			                               1);
+            	resultRulesPos += rulesSize - offset - 1; 
+            	offset = 1;
+            	isCopyUntilZero = true;
+            }
+            
+            int length = nextPoint.getRuleIndex(isCurrentArea) - offset + 1;
+            
+            if (isCopyUntilZero) {
+            	offset = 0;
+            	isCopyUntilZero = false;
+            }
+            if ((length == offset) && 
+            	(nextPoint.getRule(isCurrentArea) != PathIterator.SEG_LINETO) && 
+                (nextPoint.getRule(isCurrentArea) != PathIterator.SEG_CLOSE) &&
+            	(point.getRule(isCurrentArea) != PathIterator.SEG_LINETO) && 
+            	(point.getRule(isCurrentArea) != PathIterator.SEG_CLOSE)) {
+            	
+            	isCopyUntilZero = true;
+            	length++;
+            }
+            
+           	resultCoordPos = includeCoordsAndRules(offset, length, rules, 
+           			                               offsets, resultRules, 
+           			                               resultOffsets, resultCoords, 
+           			                               coords, resultRulesPos, 
+           			                               resultCoordPos, nextPoint, 
+           			                               isCurrentArea, true, 1);
+            resultRulesPos = ((length <= offset) || (isCopyUntilZero)) ? 
+            		resultRulesPos + 1 : resultRulesPos + length; 
+
+            point = nextPoint;
+        } while (point != intersectPoints[0]);
+        
+        if (resultRules[resultRulesPos - 1] == PathIterator.SEG_LINETO) {
+        	resultRules[resultRulesPos - 1] = PathIterator.SEG_CLOSE;
+        } else {
+        	resultCoords[resultCoordPos++] = nextPoint.getX();
+            resultCoords[resultCoordPos++] = nextPoint.getY();
+        	resultRules[resultRulesPos++] = PathIterator.SEG_CLOSE;
         }
+        
+        resultOffsets[resultRulesPos - 1] = resultCoordPos;
+		coords = resultCoords;
+		rules = resultRules;
+		offsets = resultOffsets;
+		coordsSize = resultCoordPos;
+		rulesSize = resultRulesPos;
+	}
+
+	private void intersectPolygon(Area area) {
+		CrossingHelper crossHelper = new CrossingHelper(new double[][] {coords, 
+				                                        area.coords }, 
+				                                        new int[] { coordsSize, 
+				                                        area.coordsSize });
+		IntersectPoint[] intersectPoints = crossHelper.findCrossing();
+
+		if (intersectPoints.length == 0) {
+			if (contains(area.getBounds2D())) {
+				copy(area, this);
+			} else if (!area.contains(getBounds2D())) {
+				reset();
+			}
+			return;
+		}
+
+        double[] resultCoords = new double[coordsSize + area.coordsSize + 
+                                                        intersectPoints.length];
+        int[] resultRules = new int[rulesSize + area.rulesSize + 
+                                                        intersectPoints.length];
+        int[] resultOffsets = new int[rulesSize + area.rulesSize + 
+                                                        intersectPoints.length];
+        int resultCoordPos = 0;
+        int resultRulesPos = 0;
+        boolean isCurrentArea = true;
+
+        IntersectPoint point = intersectPoints[0];
+        resultRules[resultRulesPos] = PathIterator.SEG_MOVETO;
+        resultOffsets[resultRulesPos++] = resultCoordPos; 
+        
+        do {
+        	resultCoords[resultCoordPos++] = point.getX();
+            resultCoords[resultCoordPos++] = point.getY();
+            resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
+            resultOffsets[resultRulesPos++] = resultCoordPos - 2;
+            int curIndex = point.getEndIndex(true);
+
+            if ((curIndex < 0) || 
+            	(area.containsExact(coords[2 * curIndex], 
+            		                coords[2 * curIndex + 1]) == 0)) {
+            	isCurrentArea = !isCurrentArea;
+            } else if (area.containsExact(coords[2 * curIndex], 
+            		                      coords[2 * curIndex + 1]) > 0) { 
+            	isCurrentArea = true;
+            } else {
+            	isCurrentArea = false;
+            }
 
-    }
-
-    public Area() {
-    }
+            IntersectPoint nextPoint = getNextIntersectPoint(intersectPoints, 
+            		                                         point, 
+            		                                         isCurrentArea);
+            double[] coords = (isCurrentArea) ? this.coords : area.coords;
+            int offset = 2 * point.getEndIndex(isCurrentArea);
+            if ((offset >= 0) && 
+            		(nextPoint.getBegIndex(isCurrentArea) < 
+            		    point.getEndIndex(isCurrentArea))) {
+                int coordSize = (isCurrentArea) ? this.coordsSize : 
+                	                              area.coordsSize;
+                int length = coordSize - offset;
+                System.arraycopy(coords, offset, 
+                		         resultCoords, resultCoordPos, length);
+                
+                for (int i = 0; i < length / 2; i++) {
+                	resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
+                	resultOffsets[resultRulesPos++] = resultCoordPos;
+                	resultCoordPos += 2;
+                }
+                
+                offset = 0;
+            }
+            
+            if (offset >= 0) {
+            	int length = 2 * nextPoint.getBegIndex(isCurrentArea) - 
+            	                 offset + 2;
+            	System.arraycopy(coords, offset, 
+            			         resultCoords, resultCoordPos, length);
+            	
+            	for (int i = 0; i < length / 2; i++) {
+            		resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
+            		resultOffsets[resultRulesPos++] = resultCoordPos;
+            		resultCoordPos += 2;
+            	}
+            }
 
-    public Area(Shape s) {
-        if (s == null) {
-            throw new NullPointerException();
-        }
-        this.s = s;
-    }
+            point = nextPoint;
+        } while (point != intersectPoints[0]);
+        
+        resultRules[resultRulesPos - 1] = PathIterator.SEG_CLOSE;
+        resultOffsets[resultRulesPos - 1] = resultCoordPos;
+		coords = resultCoords;
+		rules = resultRules;
+		offsets = resultOffsets;
+		coordsSize = resultCoordPos;
+		rulesSize = resultRulesPos;
+	}
+
+	private void subtractCurvePolygon(Area area) {
+		CurveCrossingHelper crossHelper = new CurveCrossingHelper(
+				new double[][] { coords, area.coords }, 
+				new int[] { coordsSize, area.coordsSize }, 
+				new int[][] { rules, area.rules },
+				new int[] { rulesSize, area.rulesSize }, 
+				new int[][] { offsets, area.offsets });
+		IntersectPoint[] intersectPoints = crossHelper.findCrossing();
+
+		if (intersectPoints.length == 0 && contains(area.getBounds2D())) {
+			copy(area, this);
+			return;
+		}
+
+        double[] resultCoords = new double[coordsSize + area.coordsSize + 
+                                                       intersectPoints.length];
+        int[] resultRules = new int[rulesSize + area.rulesSize + 
+                                                       intersectPoints.length];
+        int[] resultOffsets = new int[rulesSize + area.rulesSize + 
+                                                       intersectPoints.length];
+        int resultCoordPos = 0;
+        int resultRulesPos = 0;
+        boolean isCurrentArea = true;
+
+        IntersectPoint point = intersectPoints[0];
+        resultRules[resultRulesPos] = PathIterator.SEG_MOVETO;
+        resultOffsets[resultRulesPos++] = resultCoordPos;
+        
+        do {
+        	resultCoords[resultCoordPos++] = point.getX();
+            resultCoords[resultCoordPos++] = point.getY();
+            int curIndex = offsets[point.getRuleIndex(true)] % coordsSize;
+            
+            if (area.containsExact(coords[curIndex], 
+            		               coords[curIndex + 1]) == 0) {
+            	isCurrentArea = !isCurrentArea;
+            } else if (area.containsExact(coords[curIndex],
+            		                      coords[curIndex + 1]) > 0) { 
+            	isCurrentArea = false;
+            } else {
+            	isCurrentArea = true;
+            }
+  
+            IntersectPoint nextPoint = (isCurrentArea) ? 
+            		getNextIntersectPoint(intersectPoints, point, 
+            				              isCurrentArea):
+            		getPrevIntersectPoint(intersectPoints, point, 
+            				              isCurrentArea);	
+            double[] coords = (isCurrentArea) ? this.coords : area.coords;
+            int[] offsets = (isCurrentArea) ? this.offsets : area.offsets;
+            int[] rules = (isCurrentArea) ? this.rules : area.rules;
+            int offset = (isCurrentArea) ? point.getRuleIndex(isCurrentArea) :
+            	                         nextPoint.getRuleIndex(isCurrentArea);
+            boolean isCopyUntilZero = false;
+         
+            if (((isCurrentArea) && 
+            	 (point.getRuleIndex(isCurrentArea) > 
+            	  nextPoint.getRuleIndex(isCurrentArea))) ||
+            	((!isCurrentArea) && 
+            	 (nextPoint.getRuleIndex(isCurrentArea) > 
+            	  nextPoint.getRuleIndex(isCurrentArea)))) {
+            	
+            	int rulesSize = (isCurrentArea) ? this.rulesSize : 
+            		                              area.rulesSize;
+            	resultCoordPos = includeCoordsAndRules(offset + 1, rulesSize, 
+            			                               rules, offsets, 
+            			                               resultRules, 
+            			                               resultOffsets, 
+            			                               resultCoords, coords, 
+            			                               resultRulesPos, 
+            			                               resultCoordPos, point, 
+            			                               isCurrentArea, false, 
+            			                               2);
+            	resultRulesPos += rulesSize - offset - 1; 
+            	offset = 1;
+            	isCopyUntilZero = true;
+            }
+            
+            int length = nextPoint.getRuleIndex(isCurrentArea) - offset + 1;
+            
+            if (isCopyUntilZero) {
+            	offset = 0;
+            	isCopyUntilZero = false;
+            }
+            
+           	resultCoordPos = includeCoordsAndRules(offset, length, rules, 
+           			                               offsets, resultRules, 
+           			                               resultOffsets, resultCoords, 
+           			                               coords, resultRulesPos, 
+           			                               resultCoordPos, point, 
+           			                               isCurrentArea, true, 2);
+           	
+           	if ((length == offset) && 
+           		((rules[offset] == PathIterator.SEG_QUADTO) || 
+           		 (rules[offset] == PathIterator.SEG_CUBICTO))) {
+           		
+           		resultRulesPos++;
+    		} else {
+           	    resultRulesPos = (length < offset || isCopyUntilZero) ? 
+           	    		resultRulesPos + 1 : resultRulesPos + length - offset;
+    		}
+
+            point = nextPoint;
+        } while (point != intersectPoints[0]);
+        
+        resultRules[resultRulesPos++] = PathIterator.SEG_CLOSE;
+        resultOffsets[resultRulesPos - 1] = resultCoordPos;
+		coords = resultCoords;
+		rules = resultRules;
+		offsets = resultOffsets;
+		coordsSize = resultCoordPos;
+		rulesSize = resultRulesPos;
+	}
+
+	private void subtractPolygon(Area area) {
+		CrossingHelper crossHelper = new CrossingHelper(new double[][] {coords, 
+				                                        area.coords }, 
+				                                        new int[] { coordsSize, 
+				                                        area.coordsSize });
+		IntersectPoint[] intersectPoints = crossHelper.findCrossing();
+
+		if ((intersectPoints.length == 0) && (contains(area.getBounds2D()))) {
+			copy(area, this);
+			return;
+		} 
+
+        double[] resultCoords = new double[coordsSize + area.coordsSize + 
+                                                       intersectPoints.length];
+        int[] resultRules = new int[rulesSize + area.rulesSize + 
+                                                       intersectPoints.length];
+        int[] resultOffsets = new int[rulesSize + area.rulesSize + 
+                                                       intersectPoints.length];
+        int resultCoordPos = 0;
+        int resultRulesPos = 0;
+        boolean isCurrentArea = true;
+        int count = 0;
 
-    public boolean contains(double x, double y) {
-        return s == null ? false : s.contains(x, y);
-    }
+        IntersectPoint point = intersectPoints[0];
+        resultRules[resultRulesPos] = PathIterator.SEG_MOVETO;
+        resultOffsets[resultRulesPos++] = resultCoordPos;
+        
+        do {
+        	resultCoords[resultCoordPos++] = point.getX();
+            resultCoords[resultCoordPos++] = point.getY();
+            resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
+            resultOffsets[resultRulesPos++] = resultCoordPos - 2;
+            int curIndex = point.getEndIndex(true);
+            
+            if ((curIndex < 0) || 
+            	(area.containsExact(coords[2 * curIndex], 
+            			            coords[2 * curIndex + 1]) > 0)) {
+            	isCurrentArea = !isCurrentArea;
+            } else if (area.containsExact(coords[2 * curIndex], 
+            		                      coords[2 * curIndex + 1]) > 0) { 
+            	isCurrentArea = false;
+            } else {
+            	isCurrentArea = true;
+            }
 
-    public boolean contains(double x, double y, double width, double height) {
-        return s == null ? false : s.contains(x, y, width, height);
-    }
+            IntersectPoint nextPoint = (isCurrentArea) ? 
+            		getNextIntersectPoint(intersectPoints, point, isCurrentArea):
+            		getPrevIntersectPoint(intersectPoints, point, isCurrentArea);	
+            double[] coords = (isCurrentArea) ? this.coords : area.coords;
+            
+            int offset = (isCurrentArea) ? 2 * point.getEndIndex(isCurrentArea): 
+            							 2 * nextPoint.getEndIndex(isCurrentArea);
+            
+            if ((offset > 0) && 
+            	(((isCurrentArea) && 
+            	  (nextPoint.getBegIndex(isCurrentArea) < 
+            			  point.getEndIndex(isCurrentArea))) ||
+            	  ((!isCurrentArea) && 
+            	  (nextPoint.getEndIndex(isCurrentArea) < 
+            			  nextPoint.getBegIndex(isCurrentArea))))) {
+            	
+                int coordSize = (isCurrentArea) ? this.coordsSize : 
+                	                              area.coordsSize;
+                int length = coordSize - offset; 
+                
+                if (isCurrentArea) {
+                	System.arraycopy(coords, offset, 
+                			         resultCoords, resultCoordPos, length);
+                } else {
+                	double[] temp = new double[length];
+                	System.arraycopy(coords, offset, temp, 0, length);
+                	reverseCopy(temp);
+                	System.arraycopy(temp, 0, 
+                			         resultCoords, resultCoordPos, length);
+                }
+                
+                for (int i = 0; i < length / 2; i++) {
+                	resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
+                	resultOffsets[resultRulesPos++] = resultCoordPos;
+                	resultCoordPos += 2;
+                }
+                
+                offset = 0;
+            }
+            
+            if (offset >= 0) {
+            	int length = (isCurrentArea) ? 
+            			         2 * nextPoint.getBegIndex(isCurrentArea) - offset + 2:
+            	                 2 * point.getBegIndex(isCurrentArea) - offset + 2;
+            			         
+            	if (isCurrentArea) {
+            		System.arraycopy(coords, offset, 
+            				         resultCoords, resultCoordPos, length);
+            	} else {
+            		double[] temp = new double[length];
+            		System.arraycopy(coords, offset, temp, 0, length);
+            		reverseCopy(temp);
+            		System.arraycopy(temp, 0, 
+            				         resultCoords, resultCoordPos, length);
+            	}
+            	
+            	for (int i = 0; i < length / 2; i++) {
+            		resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
+            		resultOffsets[resultRulesPos++] = resultCoordPos;
+            		resultCoordPos += 2;
+            	}
+            }
 
-    public boolean contains(Point2D p) {
-        if (p == null) {
-            throw new NullPointerException();
+            point = nextPoint;
+            count++;
+        } while (point != intersectPoints[0] && count <= intersectPoints.length);
+        
+        if (count > intersectPoints.length) {
+        	reset();
+        } else {
+            resultRules[resultRulesPos - 1] = PathIterator.SEG_CLOSE;
+            resultOffsets[resultRulesPos - 1] = resultCoordPos;
+		    coords = resultCoords;
+		    rules = resultRules;
+		    offsets = resultOffsets;
+		    coordsSize = resultCoordPos;
+		    rulesSize = resultRulesPos;
         }
-        return s == null ? false : s.contains(p);
-    }
-
-    public boolean contains(Rectangle2D r) {
-        if (r == null) {
-            throw new NullPointerException();
+	}
+	
+	   private IntersectPoint getNextIntersectPoint(IntersectPoint[] iPoints,
+			                                        IntersectPoint isectPoint, 
+			                                        boolean isCurrentArea) {
+		   
+		int endIndex = isectPoint.getEndIndex(isCurrentArea);
+		if (endIndex < 0) {
+			return iPoints[Math.abs(endIndex) - 1];
+		}
+
+		IntersectPoint firstIsectPoint = null;
+		IntersectPoint nextIsectPoint = null;
+		for (IntersectPoint point : iPoints) {
+			int begIndex = point.getBegIndex(isCurrentArea);
+			
+			if (begIndex >= 0) {
+				if (firstIsectPoint == null) {
+					firstIsectPoint = point;
+				} else if (begIndex < firstIsectPoint
+						.getBegIndex(isCurrentArea)) {
+					firstIsectPoint = point;
+				}
+			}
+
+			if (endIndex <= begIndex) {
+				if (nextIsectPoint == null) {
+					nextIsectPoint = point;
+				} else if (begIndex < 
+						       nextIsectPoint.getBegIndex(isCurrentArea)) {
+					nextIsectPoint = point;
+				}
+			}
+		}
+
+		return (nextIsectPoint != null) ? nextIsectPoint : firstIsectPoint;
+	}
+
+	private IntersectPoint getPrevIntersectPoint(IntersectPoint[] iPoints,
+			                                     IntersectPoint isectPoint, 
+			                                     boolean isCurrentArea) {
+
+		int begIndex = isectPoint.getBegIndex(isCurrentArea);
+		
+		if (begIndex < 0) {
+			return iPoints[Math.abs(begIndex) - 1];
+		}
+
+		IntersectPoint firstIsectPoint = null;
+		IntersectPoint predIsectPoint = null;
+		for (IntersectPoint point : iPoints) {
+			int endIndex = point.getEndIndex(isCurrentArea);
+			
+			if (endIndex >= 0) {
+				if (firstIsectPoint == null) {
+					firstIsectPoint = point;
+				} else if (endIndex < firstIsectPoint
+						.getEndIndex(isCurrentArea)) {
+					firstIsectPoint = point;
+				}
+			}
+
+			if (endIndex <= begIndex) {
+				if (predIsectPoint == null) {
+					predIsectPoint = point;
+				} else if (endIndex > 
+				               predIsectPoint.getEndIndex(isCurrentArea)) {
+					predIsectPoint = point;
+				}
+			}
+		}
+
+		return (predIsectPoint != null) ? predIsectPoint : firstIsectPoint;
+	}
+
+	
+	private int includeCoordsAndRules(int offset, int length, int[] rules,
+			                          int[] offsets, int[] resultRules, 
+			                          int[] resultOffsets, double[] resultCoords, 
+			                          double[] coords, int resultRulesPos,
+			                          int resultCoordPos, IntersectPoint point, 
+			                          boolean isCurrentArea, boolean way, 
+			                          int operation) {
+
+		double[] temp = new double[8 * length];
+		int coordsCount = 0;
+		boolean isMoveIndex = true;
+		boolean isMoveLength = true;
+		boolean additional = false;
+
+		if (length <= offset) {
+			for (int i = resultRulesPos; i < resultRulesPos + 1; i++) {
+				resultRules[i] = PathIterator.SEG_LINETO;
+			}
+		} else {
+			int j = resultRulesPos;
+			for (int i = offset; i < length; i++) {
+				resultRules[j++] = PathIterator.SEG_LINETO;
+			}
+		}
+
+		if ((length == offset) &&
+			((rules[offset] == PathIterator.SEG_QUADTO) || 
+			 (rules[offset] == PathIterator.SEG_CUBICTO))) {
+			length++;
+			additional = true;
+		}
+		for (int i = offset; i < length; i++) {
+			int index = offsets[i];
+			
+			if (!isMoveIndex) {
+				index -= 2;
+			}
+			
+			if (!isMoveLength) {
+				length++;
+				isMoveLength = true;
+			}
+			
+			switch (rules[i]) {
+			    case PathIterator.SEG_MOVETO:
+			    	isMoveIndex = false;
+			    	isMoveLength = false;
+				    break;
+			    case PathIterator.SEG_LINETO:
+			    case PathIterator.SEG_CLOSE:
+				    resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
+				    resultOffsets[resultRulesPos++] = resultCoordPos + 2;
+				    boolean isLeft = CrossingHelper.compare(coords[index],
+						    coords[index + 1], point.getX(), point.getY()) > 0;
+						    
+				    if (way || !isLeft) {
+					    temp[coordsCount++] = coords[index];
+					    temp[coordsCount++] = coords[index + 1];
+				    }
+				    break;
+			    case PathIterator.SEG_QUADTO:
+				    resultRules[resultRulesPos] = PathIterator.SEG_QUADTO;
+				    resultOffsets[resultRulesPos++] = resultCoordPos + 4;
+				    double[] coefs = new double[] { coords[index - 2],
+						    coords[index - 1], coords[index], coords[index + 1],
+						    coords[index + 2], coords[index + 3] };
+				    isLeft = CrossingHelper.compare(coords[index - 2],
+						    coords[index - 1], point.getX(), point.getY()) > 0;
+						    
+				    if ((!additional) && (operation == 0 || operation == 2)) {
+					    isLeft = !isLeft;
+					    way = false;
+				    }
+				    GeometryUtil
+						.subQuad(coefs, point.getParam(isCurrentArea), isLeft);
+				    
+				    if (way || isLeft) {
+					    temp[coordsCount++] = coefs[2];
+					    temp[coordsCount++] = coefs[3];
+				    } else {
+					    System.arraycopy(coefs, 2, temp, coordsCount, 4);
+					    coordsCount += 4;
+				    }
+				    break;
+			    case PathIterator.SEG_CUBICTO:
+				    resultRules[resultRulesPos] = PathIterator.SEG_CUBICTO;
+				    resultOffsets[resultRulesPos++] = resultCoordPos + 6;
+				    coefs = new double[] {coords[index - 2], coords[index - 1],
+						                  coords[index], coords[index + 1], 
+						                  coords[index + 2], coords[index + 3], 
+						                  coords[index + 4], coords[index + 5] };
+				    isLeft = CrossingHelper.compare(coords[index - 2],
+						    coords[index - 1], point.getX(), point.getY()) > 0;
+				    GeometryUtil.subCubic(coefs, point.getParam(isCurrentArea),
+						                  !isLeft);
+				    
+				    if (isLeft) {
+					    System.arraycopy(coefs, 2, temp, coordsCount, 6);
+					    coordsCount += 6;
+				    } else {
+					    System.arraycopy(coefs, 2, temp, coordsCount, 4);
+					    coordsCount += 4;
+				    }
+				    break;
+		    }
+		}
+
+        if (operation == 2 && !isCurrentArea && coordsCount > 2) {
+			reverseCopy(temp);
+			System.arraycopy(temp, 0, resultCoords, resultCoordPos, coordsCount);
+		} else {
+			System.arraycopy(temp, 0, resultCoords, resultCoordPos, coordsCount);
+		}
+        
+		return (resultCoordPos + coordsCount);
+	}
+	
+	// the method check up the array size and necessarily increases it. 
+	private static double[] adjustSize(double[] array, int newSize) {
+		if (newSize <= array.length) {
+			return array;
+		}
+		double[] newArray = new double[2 * newSize];
+		System.arraycopy(array, 0, newArray, 0, array.length);
+		return newArray;
+	}
+
+	private static int[] adjustSize(int[] array, int newSize) {
+		if (newSize <= array.length) {
+			return array;
+		}
+		int[] newArray = new int[2 * newSize];
+		System.arraycopy(array, 0, newArray, 0, array.length);
+		return newArray;
+	}
+
+	private void copy(Area src, Area dst) {
+		dst.coordsSize = src.coordsSize;
+		dst.coords = src.coords.clone();
+		dst.rulesSize = src.rulesSize;
+		dst.rules = src.rules.clone();
+		dst.moveToCount = src.moveToCount;
+		dst.offsets = src.offsets.clone();
+	}
+
+    private int containsExact(double x, double y) {
+        PathIterator pi = getPathIterator(null);
+        int crossCount = Crossing.crossPath(pi, x, y);
+        
+        if (Crossing.isInsideEvenOdd(crossCount)) {
+            return 1;
         }
-        return s == null ? false : s.contains(r);
-    }
 
-    public boolean equals(Area obj) throws org.apache.harmony.luni.util.NotImplementedException {
-        throw new RuntimeException("Not implemented"); //$NON-NLS-1$
-    }
-
-    public boolean intersects(double x, double y, double width, double height) {
-        return s == null ? false : s.intersects(x, y, width, height);
-    }
-
-    public boolean intersects(Rectangle2D r) {
-        if (r == null) {
-            throw new NullPointerException();
+        double[] segmentCoords = new double[6];
+        double[] resultPoints = new double[6];
+        int rule;
+        double curX = -1;
+        double curY = -1;
+        double moveX = -1;
+        double moveY = -1;
+        
+        for (pi = getPathIterator(null); !pi.isDone(); pi.next()) {
+            rule = pi.currentSegment(segmentCoords);
+            switch (rule) {
+                case PathIterator.SEG_MOVETO:
+                    moveX = curX = segmentCoords[0];
+                    moveY = curY = segmentCoords[1];
+                    break;
+                case PathIterator.SEG_LINETO:
+                    if (GeometryUtil.intersectLines(curX, curY, 
+                    		segmentCoords[0], segmentCoords[1], x, y, x, y, 
+                    		resultPoints) != 0) {
+                        return 0;
+                    }
+                    curX = segmentCoords[0];
+                    curY = segmentCoords[1];
+                    break;
+                case PathIterator.SEG_QUADTO:
+                    if (GeometryUtil.intersectLineAndQuad(x, y, x, y, 
+                    		curX, curY, segmentCoords[0], segmentCoords[1], 
+                    		segmentCoords[2], segmentCoords[3], 
+                    		resultPoints) > 0) {
+                        return 0;
+                    }
+                    curX = segmentCoords[2];
+                    curY = segmentCoords[3];
+                    break;
+                case PathIterator.SEG_CUBICTO:
+                    if (GeometryUtil.intersectLineAndCubic(x, y, x, y, 
+                    		curX, curY, segmentCoords[0], segmentCoords[1], 
+                    		segmentCoords[2], segmentCoords[3], segmentCoords[4], 
+                    		segmentCoords[5], resultPoints) > 0) {
+                        return 0;
+                    }
+                    curX = segmentCoords[4];
+                    curY = segmentCoords[5];
+                    break;
+                case PathIterator.SEG_CLOSE:
+                    if (GeometryUtil.intersectLines(curX, curY, moveX, moveY,
+                    		x, y, x, y, resultPoints) != 0) {
+                        return 0;
+                    }
+                    curX = moveX;
+                    curY = moveY;
+                    break;
+            }
         }
-        return s == null ? false : s.intersects(r);
-    }
-
-    public Rectangle getBounds() {
-        return s == null ? new Rectangle() : s.getBounds();
+        return -1;
     }
 
-    public Rectangle2D getBounds2D() {
-        return s == null ? new Rectangle2D.Double(): s.getBounds2D();
-    }
-
-    public PathIterator getPathIterator(AffineTransform t) {
-        return s == null ? new NullIterator() : s.getPathIterator(t);
-    }
-
-    public PathIterator getPathIterator(AffineTransform t, double flatness) {
-        return s == null ? new NullIterator() : s.getPathIterator(t, flatness);
-    }
-
-    public void add(Area area) throws org.apache.harmony.luni.util.NotImplementedException {
-        throw new RuntimeException("Not implemented"); //$NON-NLS-1$
-    }
-
-    public void exclusiveOr(Area area) throws org.apache.harmony.luni.util.NotImplementedException {
-        throw new RuntimeException("Not implemented"); //$NON-NLS-1$
-    }
-
-    /**
-     * Extract Rectangle2D from the source shape
-     * @return a Rectangle2D object if the source shape is rectangle, or null if shape is empty or not rectangle. 
-     */
-    Rectangle2D extractRectangle() {
-        if (s == null) {
-            return null;
-        }
-        float[] points = new float[12];
-        int count = 0;
-        PathIterator p = s.getPathIterator(null);
-        float[] coords = new float[6];
-        while(!p.isDone()) {
-            int type = p.currentSegment(coords);
-            if (count > 12 || type == PathIterator.SEG_QUADTO || type == PathIterator.SEG_CUBICTO) {
-                return null;
-            }
-            points[count++] = coords[0];
-            points[count++] = coords[1];
-            p.next();
-        }
-        if (points[0] == points[6] && points[6] == points[8] && points[2] == points[4] &&
-            points[1] == points[3] && points[3] == points[9] && points[5] == points[7])
-        {
-            return new Rectangle2D.Float(points[0], points[1], points[2] - points[0], points[7] - points[1]);
-        }
-        return null;
+    private void reverseCopy(double[] coords) {
+    	double[] temp = new double[coords.length];
+    	System.arraycopy(coords, 0, temp, 0, coords.length);
+    	
+    	for (int i = 0; i < coords.length;) {
+    		coords[i] = temp[coords.length - i - 2];
+    		coords[i + 1] = temp[coords.length - i - 1]; 
+    		i = i + 2;
+    	}
     }
     
-    public void intersect(Area area) {
-        Rectangle2D src1 = extractRectangle();
-        Rectangle2D src2 = area.extractRectangle();
-        if (src1 != null && src2 != null) {
-            Rectangle2D.intersect(src1, src2, (Rectangle2D)s);
-        }
-    }
-
-    public void subtract(Area area) throws org.apache.harmony.luni.util.NotImplementedException {
-        throw new RuntimeException("Not implemented"); //$NON-NLS-1$
-    }
-
-    public boolean isEmpty() throws org.apache.harmony.luni.util.NotImplementedException {
-        throw new RuntimeException("Not implemented"); //$NON-NLS-1$
-    }
-
-    public boolean isPolygonal() throws org.apache.harmony.luni.util.NotImplementedException {
-        throw new RuntimeException("Not implemented"); //$NON-NLS-1$
-    }
-
-    public boolean isRectangular() throws org.apache.harmony.luni.util.NotImplementedException {
-        throw new RuntimeException("Not implemented"); //$NON-NLS-1$
-    }
-
-    public boolean isSingular() throws org.apache.harmony.luni.util.NotImplementedException {
-        throw new RuntimeException("Not implemented"); //$NON-NLS-1$
-    }
-
-    public void reset() throws org.apache.harmony.luni.util.NotImplementedException {
-        throw new RuntimeException("Not implemented"); //$NON-NLS-1$
-    }
-
-    public void transform(AffineTransform t) {
-        s = t.createTransformedShape(s);
-    }
-
-    public Area createTransformedArea(AffineTransform t) {
-        return s == null ? new Area() : new Area(t.createTransformedShape(s));
-    }
-
-    @Override
-    public Object clone() {
-        return new Area(this);
-    }
+    // the internal class implements PathIterator
+	private class AreaPathIterator implements PathIterator {
 
-}
+		AffineTransform t;
+		Area area;
+		int curRuleIndex = 0;
+		int curCoordIndex = 0;
+
+		AreaPathIterator(Area area) {
+			this(area, null);
+		}
+
+		AreaPathIterator(Area area, AffineTransform t) {
+			this.area = area;
+			this.t = t;
+		}
+
+		public int getWindingRule() {
+			return WIND_EVEN_ODD;
+		}
+
+		public boolean isDone() {
+			return curRuleIndex >= rulesSize;
+		}
+
+		public void next() {
+			switch (rules[curRuleIndex]) {
+			case PathIterator.SEG_MOVETO:
+			case PathIterator.SEG_LINETO:
+				curCoordIndex += 2;
+				break;
+			case PathIterator.SEG_QUADTO:
+				curCoordIndex += 4;
+				break;
+			case PathIterator.SEG_CUBICTO:
+				curCoordIndex += 6;
+				break;
+			}
+			curRuleIndex++;
+		}
+
+		public int currentSegment(double[] c) {
+			if (isDone()) {
+				throw new NoSuchElementException(Messages.getString("awt.4B")); //$NON-NLS-1$
+			}
+			switch (rules[curRuleIndex]) {
+				case PathIterator.SEG_CUBICTO:
+					c[4] = coords[curCoordIndex + 4];
+					c[5] = coords[curCoordIndex + 5];
+				case PathIterator.SEG_QUADTO:
+					c[2] = coords[curCoordIndex + 2];
+					c[3] = coords[curCoordIndex + 3];
+				case PathIterator.SEG_MOVETO:
+				case PathIterator.SEG_LINETO:
+					c[0] = coords[curCoordIndex];
+					c[1] = coords[curCoordIndex + 1];
+			}
+			return rules[curRuleIndex];
+		}
+
+		public int currentSegment(float[] c) {
+			double[] doubleCoords = new double[6];
+			int rule = currentSegment(doubleCoords);
+			
+			for (int i = 0; i < 6; i++) {
+				c[i] = (float) doubleCoords[i];
+			}
+			return rule;
+		}
+	}
+}
\ No newline at end of file

Propchange: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jun 18 00:36:49 2007
@@ -0,0 +1,3 @@
+*.dll
+*.map
+*.pdb

Propchange: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/shared/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jun 18 00:36:49 2007
@@ -0,0 +1 @@
+*.obj

Propchange: harmony/enhanced/classlib/branches/java6/modules/awt/src/main/native/fontlib/windows/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jun 18 00:36:49 2007
@@ -0,0 +1,2 @@
+*.RES
+*.pdb

Modified: harmony/enhanced/classlib/branches/java6/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java?view=diff&rev=548243&r1=548242&r2=548243
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java Mon Jun 18 00:36:49 2007
@@ -45,54 +45,126 @@
     }
     
     public void testContainsPoint() {
-        // Regression test HARMONY-1404
         try {
-            Area a = new Area();
-            a.contains((Point2D)null);
-            fail("Expected NPE");
-        } catch (NullPointerException e) {
-            // expected
-        }
-    }
+             Area area = new Area(new Ellipse2D.Double(200, 300, 400, 200));
+             assertTrue(area.contains(250, 350));
+             assertFalse(area.contains(200, 300));
+             assertFalse(area.contains(50, 50));
+             
+             assertTrue(area.contains(new Point2D.Double(500, 400)));
+             assertFalse(area.contains(new Point2D.Double(700, 400)));
+             
+             // Regression test HARMONY-1404
+             Area emptyArea = new Area();
+             emptyArea.contains((Point2D)null);
+             fail("Expected NPE");
+         } catch (NullPointerException e) {
+             // expected
+         }
+     }
 
-    public void testContainsRect() {
-        // Regression test HARMONY-1404
-        try {
-            Area a = new Area();
-            a.contains((Rectangle2D)null);
-            fail("Expected NPE");
-        } catch (NullPointerException e) {
-            // expected
-        }
-    }
+     public void testContainsRect() {
+         // Regression test HARMONY-1476
+         GeneralPath path = new GeneralPath();
+         path.moveTo(100, 500);
+         path.lineTo(400, 100);
+         path.lineTo(700, 500);
+         path.closePath();
+         
+         Area area = new Area(path);
+         assertTrue(area.contains(new Rectangle2D.Double(300, 400, 100, 50)));
+         assertFalse(area.contains(new Rectangle2D.Double(50, 400, 700, 50)));
+         
+         GeneralPath path1 = new GeneralPath();
+         path1.moveTo(400, 500);
+         path1.quadTo(200, 200, 400, 100);
+         path1.quadTo(600, 200, 400, 500);
+         path1.closePath();
+         
+         Area area1 = new Area(path1);
+         assertTrue(area1.contains(350, 200, 50, 50));
+         assertFalse(area1.contains(100, 50, 600, 500));
+         
+     	// Regression test HARMONY-1404
+         try {
+             Area emptyArea = new Area();
+             emptyArea.contains((Rectangle2D)null);
+             fail("Expected NPE");
+         } catch (NullPointerException e) {
+             // expected
+         }
+     }
 
-    public void testIntersectsRect() {
-        // Regression test HARMONY-1404
-        try {
-            Area a = new Area();
-            a.intersects((Rectangle2D)null);
-            fail("Expected NPE");
-        } 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);
-    }
-    
-    public void testCreateTransformedArea() {
-        // Regression test HARMONY-1880
-        AffineTransform t = AffineTransform.getScaleInstance(2, 3);
-        Area a1 = new Area();        
-        Area a2 = a1.createTransformedArea(t);
-        PathIterator path = a2.getPathIterator(null);
-        checkPathRule(path, PathIterator.WIND_NON_ZERO);
-        checkPathDone(path, true);
-    }
+     public void testIntersectsRect() {
+         // Regression test HARMONY-1476
+         GeneralPath path = new GeneralPath();
+         path.moveTo(100, 500);
+         path.lineTo(400, 100);
+         path.lineTo(700, 500);
+         path.closePath();
+         
+         Area area = new Area(path);
+         assertTrue(area.intersects(new Rectangle2D.Double(300, 400, 100, 50)));
+         assertFalse(area.intersects(new Rectangle2D.Double(50, 50, 50, 50)));
+         
+         GeneralPath path1 = new GeneralPath();
+         path1.moveTo(400, 500);
+         path1.quadTo(200, 200, 400, 100);
+         path1.quadTo(600, 200, 400, 500);
+         path1.closePath();
+         
+         Area area1 = new Area(path1);
+         assertTrue(area1.intersects(350, 200, 50, 50));
+         assertFalse(area1.intersects(500, 50, 100, 50));
+         
+         // Regression test HARMONY-1404
+         try {
+             Area emptyArea = new Area();
+             emptyArea.intersects((Rectangle2D)null);
+             fail("Expected NPE");
+         } catch (NullPointerException e) {
+             // expected
+         }
+     }
+     
+     public void testIsRectangle() {
+     	 // Regression test HARMONY-1476
+     	Area area = new Area(new Rectangle2D.Double(200, 300, 400, 150));
+     	assertTrue(area.isRectangular());
+         
+     	GeneralPath path = new GeneralPath();
+         path.moveTo(200, 300);
+         path.lineTo(600, 300);
+         path.lineTo(600, 450);
+         path.lineTo(200, 450);
+         path.closePath();
+         
+         Area area1 = new Area(path);
+         assertTrue(area1.isRectangular());
+         
+         Area area2 = new Area(new Ellipse2D.Double(200, 300, 400, 150));
+         assertFalse(area2.isRectangular());     
+     }
+     
+     public void testGetPathIterator() {
+         // Regression test HARMONY-1860
+         Area a = new Area();
+         PathIterator path = a.getPathIterator(null);
+         checkPathRule(path, PathIterator.WIND_EVEN_ODD);
+         checkPathDone(path, true);
+     }
+     
+     public void testCreateTransformedArea() {
+         // Regression test HARMONY-1880
+         AffineTransform t = AffineTransform.getScaleInstance(2, 3);
+         Area a1 = new Area();        
+         Area a2 = a1.createTransformedArea(t);
+         PathIterator path = a2.getPathIterator(null);
+         checkPathRule(path, PathIterator.WIND_EVEN_ODD);
+         checkPathDone(path, true);
+     }
 
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(AreaTest.class);
+    }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/InputStreamReader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/InputStreamReader.java?view=diff&rev=548243&r1=548242&r2=548243
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/InputStreamReader.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/InputStreamReader.java Mon Jun 18 00:36:49 2007
@@ -70,6 +70,7 @@
         decoder = Charset.forName(encoding).newDecoder().onMalformedInput(
                 CodingErrorAction.REPLACE).onUnmappableCharacter(
                 CodingErrorAction.REPLACE);
+        bytes.limit(0);
     }
 
     /**
@@ -101,6 +102,7 @@
         } catch (IllegalArgumentException e) {
             throw new UnsupportedEncodingException();
         }
+        bytes.limit(0);
     }
 
     /**
@@ -118,6 +120,7 @@
         dec.averageCharsPerByte();
         this.in = in;
         decoder = dec;
+        bytes.limit(0);
     }
 
     /**
@@ -136,6 +139,7 @@
         decoder = charset.newDecoder().onMalformedInput(
                 CodingErrorAction.REPLACE).onUnmappableCharacter(
                 CodingErrorAction.REPLACE);
+        bytes.limit(0);
     }
 
     /**
@@ -385,67 +389,47 @@
             if (length == 0) {
                 return 0;
             }
-            
-            // allocate enough space for bytes if the default length is
-            // inadequate
-            int availableLen = in.available();     
-            if (Math.min(availableLen, length) > bytes.capacity()) {
-                bytes = ByteBuffer.allocate(availableLen);
-            }
-            
+
             CharBuffer out = CharBuffer.wrap(buf, offset, length);
             CoderResult result = CoderResult.UNDERFLOW;
-            byte[] a = bytes.array();
-            boolean has_been_read = false;
 
-            if (!bytes.hasRemaining() || bytes.limit() == bytes.capacity()) {
-                // Nothing is available in the buffer...
-                if (!bytes.hasRemaining()) {
-                    bytes.clear();
-                }
-                int readed = in.read(a, bytes.arrayOffset(), bytes.remaining());
-                if (readed == -1) {
-                    endOfInput = true;
-                    return -1;
-                }
-                bytes.limit(readed);
-                has_been_read = true;
-            }
+            // bytes.remaining() indicates number of bytes in buffer
+            // when 1-st time entered, it'll be equal to zero
+            boolean needInput = !bytes.hasRemaining();
 
             while (out.hasRemaining()) {
-                if (bytes.hasRemaining()) {
-                    result = decoder.decode(bytes, out, false);
-                    if (!bytes.hasRemaining() && endOfInput) {
-                        decoder.decode(bytes, out, true);
-                        decoder.flush(out);
-                        decoder.reset();
+                // fill the buffer if needed
+                if (needInput) {
+                    if ((in.available() == 0) && (out.position() > offset)) {
+                        // we could return the result without blocking read
                         break;
                     }
-                    if (!out.hasRemaining()
-                            || bytes.position() == bytes.limit()) {
-                        bytes.compact();
-                    }
-                }
-                if (in.available() > 0
-                        && (!has_been_read && out.hasRemaining())
-                        || out.position() == 0) {
-                    bytes.compact();
-                    int to_read = bytes.remaining();
-                    int off = bytes.arrayOffset() + bytes.position();
-
-                    to_read = in.read(a, off, to_read);
-                    if (to_read == -1) {
-                        if (bytes.hasRemaining()) {
-                            bytes.flip();
-                        }
+
+                    int to_read = bytes.capacity() - bytes.limit();
+                    int off = bytes.arrayOffset() + bytes.limit();
+                    int was_red = in.read(bytes.array(), off, to_read);
+
+                    if (was_red == -1) {
                         endOfInput = true;
                         break;
+                    } else if (was_red == 0) {
+                        break;
                     }
-                    has_been_read = true;
-                    if (to_read > 0) {
-                        bytes.limit(bytes.position() + to_read);
+                    bytes.limit(bytes.limit() + was_red);
+                    needInput = false;
+                }
+
+                // decode bytes
+                result = decoder.decode(bytes, out, false);
+
+                if (result.isUnderflow()) {
+                    // compact the buffer if no space left
+                    if (bytes.limit() == bytes.capacity()) {
+                        bytes.compact();
+                        bytes.limit(bytes.position());
                         bytes.position(0);
                     }
+                    needInput = true;
                 } else {
                     break;
                 }
@@ -453,10 +437,7 @@
 
             if (result == CoderResult.UNDERFLOW && endOfInput) {
                 result = decoder.decode(bytes, out, true);
-                // FIXME: should flush at first, but seems ICU has a bug that it
-                // will throw IAE if some malform/unmappable bytes found during
-                // decoding
-                // result = decoder.flush(chars);
+                decoder.flush(out);
                 decoder.reset();
             }
             if (result.isMalformed()) {
@@ -464,9 +445,6 @@
             } else if (result.isUnmappable()) {
                 throw new UnmappableCharacterException(result.length());
             }
-            if (result == CoderResult.OVERFLOW && bytes.position() != 0) {
-                bytes.flip();
-            }
 
             return out.position() - offset == 0 ? -1 : out.position() - offset;
         }
@@ -505,7 +483,7 @@
                 throw new IOException(Msg.getString("K0070")); //$NON-NLS-1$
             }
             try {
-                return bytes.limit() != bytes.capacity() || in.available() > 0;
+                return bytes.hasRemaining() || in.available() > 0;
             } catch (IOException e) {
                 return false;
             }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/InetAddress.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/InetAddress.java?view=diff&rev=548243&r1=548242&r2=548243
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/InetAddress.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/net/InetAddress.java Mon Jun 18 00:36:49 2007
@@ -844,12 +844,12 @@
                     boolean threadReached = false;
                     // if isICMP, tries ICMP ping, else TCP echo
                     if (isICMP) {
-                        threadReached = NETIMPL.isReachableByICMP(
-                                InetAddress.this, addr, ttl, timeout);
+                        threadReached = NETIMPL.isReachableByICMP(addr,
+                                InetAddress.this, ttl, timeout);
                     } else {
                         try {
-                            threadReached = isReachableByTCP(InetAddress.this,
-                                    addr, timeout);
+                            threadReached = isReachableByTCP(addr,
+                                    InetAddress.this, timeout);
                         } catch (IOException e) {
                             // do nothing
                         }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/BitSet.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/BitSet.java?view=diff&rev=548243&r1=548242&r2=548243
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/BitSet.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/BitSet.java Mon Jun 18 00:36:49 2007
@@ -100,7 +100,7 @@
         if (nbits < 0) {
             throw new NegativeArraySizeException();
         }
-        bits = new long[(nbits + ELM_SIZE - 1) >> OFFSET];
+        bits = new long[(nbits >> OFFSET) + ((nbits & RIGHT_BITS) > 0 ? 1 : 0)];
         actualArrayLength = 0;
         isLengthActual = true;
     }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Currency.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Currency.java?view=diff&rev=548243&r1=548242&r2=548243
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Currency.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Currency.java Mon Jun 18 00:36:49 2007
@@ -45,7 +45,7 @@
     }
 
     /**
-     * Answers the currency instance for this currency code.
+     * Returns the Currency instance for this currency code.
      * <p>
      * 
      * @param currencyCode
@@ -81,7 +81,7 @@
     }
 
     /***************************************************************************
-     * Answers the currency instance for this locale.
+     * Returns the Currency instance for the given locale.
      * 
      * @param locale
      *            java.util.Locale
@@ -115,28 +115,27 @@
     }
 
     /**
-     * Answers this currency's ISO 4217 currency code.
+     * Returns this currency's ISO 4217 currency code.
      * 
      * @return this currency's ISO 4217 currency code
      */
     public String getCurrencyCode() {
         return currencyCode;
     }
-
+    
     /**
-     * Answers the symbol for this currency in the default locale. For instance,
-     * if the default locale is the US, the symbol of the US dollar is "$". For
-     * other locales it may be "US$". If no symbol can be determined, the ISO
-     * 4217 currency code of the US dollar is returned.
+     * Returns the currency symbol for the default locale.
+     * 
+     * Equivalent to <code>getSymbol(Locale.getDefault())</code>
      * 
-     * @return the symbol for this currency in the default locale
+     * @return the currency symbol for the default locale.
      */
     public String getSymbol() {
         return getSymbol(Locale.getDefault());
     }
 
     /**
-     * Return the symbol for this currency in the given locale.
+     * Returns the currency symbol for the given locale.
      * <p>
      * 
      * If the locale doesn't have any countries (e.g.
@@ -154,9 +153,9 @@
      * <p>
      * 
      * @param locale
-     *            java.lang.String locale
-     * @return symbol java.lang.String the representation of this Currency's
-     *         symbol in this locale
+     *            the locale
+     * @return symbol the representation of this Currency's symbol in this
+     *         locale
      */
     public String getSymbol(Locale locale) {
         if (locale.getCountry().equals("")) { //$NON-NLS-1$
@@ -194,10 +193,9 @@
     }
 
     /**
-     * Answers the default number of fraction digits for this currency. For
-     * instance, the default number of fraction digits for the US dollar is 2.
-     * For the Japanese Yen the number is 0. In the case of pseudo-currencies,
-     * such as IMF Special Drawing Rights, -1 is returned.
+     * Returns the default number of fraction digits for this currency (i.e. the
+     * number of digits after the decimal point). For pseudo currencies this
+     * method returns -1.
      * 
      * @return the default number of fraction digits for this currency
      */
@@ -206,7 +204,7 @@
     }
 
     /**
-     * Answers this currency's ISO 4217 currency code.
+     * Returns this currency's ISO 4217 currency code.
      * 
      * @return this currency's ISO 4217 currency code
      */

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Random.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Random.java?view=diff&rev=548243&r1=548242&r2=548243
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Random.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/Random.java Mon Jun 18 00:36:49 2007
@@ -77,12 +77,14 @@
     }
 
     /**
-     * Answers a pseudo-random uniformly distributed <code>int</code> value of
-     * the number of bits specified by the argument <code>bits</code> as
-     * described by Donald E. Knuth in <i>The Art of Computer Programming,
-     * Volume 2: Seminumerical Algorithms</i>, section 3.2.1.
+     * Returns a pseudo-random uniformly distributed <code>int</code> value of
+     * the number of bits specified by the argument <code>bits</code>.
      * 
-     * @return int a pseudo-random generated int number
+     * Implements D. H. Lehmer's random number algorithm found in <i>The Art of
+     * Computer Programming, Volume 2: Seminumerical Algorithms</i>, by Donald
+     * E. Knuth (section 3.2.1).
+     * 
+     * @return a pseudo-randomly generated int
      * @param bits
      *            number of bits of the returned value
      * 
@@ -136,7 +138,7 @@
      * Generates a normally distributed random double number between 0.0
      * inclusively and 1.0 exclusively.
      * 
-     * @return double
+     * @return a random double between 0.0 and 1.0
      * 
      * @see #nextFloat
      */
@@ -148,7 +150,7 @@
      * Generates a normally distributed random float number between 0.0
      * inclusively and 1.0 exclusively.
      * 
-     * @return float a random float number between 0.0 and 1.0
+     * @return a random float between 0.0 and 1.0
      * 
      * @see #nextDouble
      */
@@ -157,14 +159,15 @@
     }
 
     /**
-     * pseudo-randomly generates (approximately) a normally distributed
+     * Returns a pseudo-randomly generated, normally distributed
      * <code>double</code> value with mean 0.0 and a standard deviation value
-     * of <code>1.0</code> using the <i>polar method<i> of G. E. P. Box, M.
-     * E. Muller, and G. Marsaglia, as described by Donald E. Knuth in <i>The
-     * Art of Computer Programming, Volume 2: Seminumerical Algorithms</i>,
-     * section 3.4.1, subsection C, algorithm P
+     * of <code>1.0</code>.
+     * 
+     * Implements G. E. P. Box, M. E. Muller, and G. Marsaglia's polar method
+     * found in <i>The Art of Computer Programming, Volume 2: Seminumerical
+     * Algorithms</i>, by Donald E. Knuth (section 3.4.1).
      * 
-     * @return double
+     * @return a pseudo-randomly generated double
      * 
      * @see #nextDouble
      */
@@ -194,7 +197,7 @@
      * Generates a uniformly distributed 32-bit <code>int</code> value from
      * the this random number sequence.
      * 
-     * @return int uniformly distributed <code>int</code> value
+     * @return a randomly generated <code>int</code>
      * 
      * @see java.lang.Integer#MAX_VALUE
      * @see java.lang.Integer#MIN_VALUE
@@ -206,13 +209,12 @@
     }
 
     /**
-     * Returns to the caller a new pseudo-random integer value which is uniformly
-     * distributed between 0 (inclusively) and the value of <code>n</code>
-     * (exclusively).
+     * Returns a new pseudo-random integer value which is uniformly distributed
+     * between 0 (inclusively) and <code>n</code> (exclusively).
      * 
-     * @return int
+     * @return a randomly generated <code>int</code> between 0 and n
      * @param n
-     *            int
+     *            the upper limit of the values that can be returned
      */
     public int nextInt(int n) {
         if (n > 0) {
@@ -246,8 +248,9 @@
     }
 
     /**
-     * Modifies the seed using linear congruential formula presented in <i>The
-     * Art of Computer Programming, Volume 2</i>, Section 3.2.1.
+     * Modifies the seed using a linear congruential formula, as found in <i>The
+     * Art of Computer Programming, Volume 2</i>, by Donald E. Knuth (section
+     * 3.2.1).
      * 
      * @param seed
      *            the seed that alters the state of the random number generator