[Patch][gui] FYI: More geom bugfixes
Michael Koch
konqueror@gmx.de
Wed Nov 17 07:51:00 GMT 2004
Hi list,
I just merged the attached patch from GNU classpath. It fixes 11 mauve
fails.
Michael
2004-11-17 Sven de Marothy <sven@physto.se>
* java/awt/geom/Arc2D.java
(setAngleStart): Corrected (wrong sign on atan2 y parameter).
(setAngles): Likewise.
(containsAngle): Return false on zero extent, don't include
final angle.
(contains): Treat OPEN-type arcs like CHORD ones, not as PIE
ones.
-------------- next part --------------
Index: java/awt/geom/Arc2D.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/geom/Arc2D.java,v
retrieving revision 1.3.14.4
diff -u -r1.3.14.4 Arc2D.java
--- java/awt/geom/Arc2D.java 16 Nov 2004 09:55:40 -0000 1.3.14.4
+++ java/awt/geom/Arc2D.java 17 Nov 2004 07:22:57 -0000
@@ -327,7 +327,7 @@
// Normalize.
double x = p.getX() - (getX() + getWidth() / 2);
double y = p.getY() - (getY() + getHeight() / 2);
- setAngleStart(Math.toDegrees(Math.atan2(y, x)));
+ setAngleStart(Math.toDegrees(Math.atan2(-y, x)));
}
/**
@@ -352,8 +352,8 @@
y1 = y1 - (my + mh / 2);
x2 = x2 - (mx + mw / 2);
y2 = y2 - (my + mh / 2);
- double start = Math.toDegrees(Math.atan2(y1, x1));
- double extent = Math.toDegrees(Math.atan2(y2, x2)) - start;
+ double start = Math.toDegrees(Math.atan2(-y1, x1));
+ double extent = Math.toDegrees(Math.atan2(-y2, x2)) - start;
if (extent < 0)
extent += 360;
setAngleStart(start);
@@ -469,6 +469,9 @@
double extent = getAngleExtent();
double end = start + extent;
+ if (extent == 0)
+ return false;
+
if (extent >= 360 || extent <= -360)
return true;
@@ -490,7 +493,7 @@
while (a < start)
a += 360;
- return a >= start && a <= end;
+ return a >= start && a < end; // starting angle included, ending angle not
}
/**
@@ -498,7 +501,7 @@
* is empty, then this will return false.
*
* The area considered 'inside' an arc of type OPEN is the same as the
- * area inside an equivalent filled PIE-type arc. The area considered
+ * area inside an equivalent filled CHORD-type arc. The area considered
* 'inside' a CHORD-type arc is the same as the filled area.
*
* @param x the x coordinate to test
@@ -521,7 +524,7 @@
return false;
double angle = Math.toDegrees(Math.atan2(-dy, dx));
- if (getArcType() != CHORD)
+ if (getArcType() == PIE)
return containsAngle(angle);
double a1 = Math.toRadians(getAngleStart());
More information about the Java-patches
mailing list