You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ap...@apache.org on 2007/09/03 18:30:07 UTC
svn commit: r572382 - in /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: apetrenko
Date: Mon Sep 3 09:30:03 2007
New Revision: 572382
URL: http://svn.apache.org/viewvc?rev=572382&view=rev
Log:
Patch for HARMONY-4680 "[classlib][awt] No correct result of java.awt.Graphics2D.scale() method use when the drawing figure is java.awt.geom.Area object"
Modified:
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/Area.java
harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java
Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/Area.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/Area.java?rev=572382&r1=572381&r2=572382&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/Area.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/geom/Area.java Mon Sep 3 09:30:03 2007
@@ -1290,7 +1290,7 @@
// the internal class implements PathIterator
private class AreaPathIterator implements PathIterator {
- AffineTransform t;
+ AffineTransform transform;
Area area;
int curRuleIndex = 0;
int curCoordIndex = 0;
@@ -1301,7 +1301,7 @@
AreaPathIterator(Area area, AffineTransform t) {
this.area = area;
- this.t = t;
+ this.transform = t;
}
public int getWindingRule() {
@@ -1332,18 +1332,29 @@
if (isDone()) {
throw new NoSuchElementException(Messages.getString("awt.4B")); //$NON-NLS-1$
}
+
+ int count = 0;
+
switch (rules[curRuleIndex]) {
case PathIterator.SEG_CUBICTO:
c[4] = coords[curCoordIndex + 4];
c[5] = coords[curCoordIndex + 5];
+ count = 1;
case PathIterator.SEG_QUADTO:
c[2] = coords[curCoordIndex + 2];
c[3] = coords[curCoordIndex + 3];
+ count += 1;
case PathIterator.SEG_MOVETO:
case PathIterator.SEG_LINETO:
c[0] = coords[curCoordIndex];
c[1] = coords[curCoordIndex + 1];
+ count += 1;
}
+
+ if(transform != null) {
+ transform.transform(c, 0, c, 0, count);
+ }
+
return rules[curRuleIndex];
}
Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java?rev=572382&r1=572381&r2=572382&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/geom/AreaTest.java Mon Sep 3 09:30:03 2007
@@ -191,7 +191,42 @@
assertFalse(area1.contains(375, 325));
assertTrue(area1.contains(600, 300));
assertTrue(area1.contains(325, 325));
- }
+ }
+
+ public void testTransformPathIterator() {
+ // Regression test HARMONY-4680
+ AffineTransform transform = new AffineTransform(2.0, 0.0, 0.0, 200.0 / 140.0, 0.0, 0.0);
+ Area ar = new Area(new Rectangle2D.Double(100, 100, 50.0, 100.0));
+
+ PathIterator path = ar.getPathIterator(null);
+ PathIterator transformedPath = ar.getPathIterator(transform);
+ double[] coords = new double[6];
+ double[] transformedCoords = new double[6];
+
+ while (!path.isDone() && !transformedPath.isDone()) {
+ int rule1 = path.currentSegment(coords);
+ int rule2 = transformedPath.currentSegment(transformedCoords);
+ assertTrue(rule1 == rule2);
+ switch (rule1) {
+ case PathIterator.SEG_MOVETO: {
+ transform.transform(coords, 0, coords, 0, 1);
+ assertTrue(coords[0] == transformedCoords[0] && coords[1] == transformedCoords[1]);
+ break;
+ }
+ case PathIterator.SEG_LINETO: {
+ transform.transform(coords, 0, coords, 0, 1);
+ assertTrue(coords[0] == transformedCoords[0] && coords[1] == transformedCoords[1]);
+ break;
+ }
+ case PathIterator.SEG_CLOSE: {
+ break;
+ }
+ }
+ path.next();
+ transformedPath.next();
+ }
+ assertTrue(path.isDone() && transformedPath.isDone());
+ }
public static void main(String[] args) {
junit.textui.TestRunner.run(AreaTest.class);