This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[PATCH] more geometry fixes
- From: graydon hoare <graydon at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: 18 Jul 2003 11:25:16 -0400
- Subject: [PATCH] more geometry fixes
hi,
these just correct more mis-calculations in some of the
java.awt.geom.* classes, and rework the path iterator loops to a
consistent shared style.
ok to commit?
-graydon
Index: java/awt/geom/CubicCurve2D.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/geom/CubicCurve2D.java,v
retrieving revision 1.1
diff -u -r1.1 CubicCurve2D.java
--- java/awt/geom/CubicCurve2D.java 9 Aug 2002 04:26:15 -0000 1.1
+++ java/awt/geom/CubicCurve2D.java 18 Jul 2003 15:16:31 -0000
@@ -204,7 +204,7 @@
return new PathIterator()
{
/** Current coordinate. */
- private int current;
+ private int current = 0;
public int getWindingRule()
{
@@ -213,7 +213,7 @@
public boolean isDone()
{
- return current < 2;
+ return current >= 2;
}
public void next()
@@ -223,52 +223,56 @@
public int currentSegment(float[] coords)
{
- if (current == 0)
+ int result;
+ switch (current)
{
+ case 0:
coords[0] = (float) getX1();
coords[1] = (float) getY1();
- if (at != null)
- at.transform(coords, 0, coords, 0, 1);
- return SEG_MOVETO;
- }
- if (current == 1)
- {
+ result = SEG_MOVETO;
+ break;
+ case 1:
coords[0] = (float) getCtrlX1();
coords[1] = (float) getCtrlY1();
coords[2] = (float) getCtrlX2();
coords[3] = (float) getCtrlY2();
coords[4] = (float) getX2();
coords[5] = (float) getY2();
- if (at != null)
- at.transform(coords, 0, coords, 0, 3);
- return SEG_CUBICTO;
+ result = SEG_CUBICTO;
+ break;
+ default:
+ throw new NoSuchElementException("cubic iterator out of bounds");
}
- throw new NoSuchElementException("cubic iterator out of bounds");
+ if (at != null)
+ at.transform(coords, 0, coords, 0, 3);
+ return result;
}
public int currentSegment(double[] coords)
{
- if (current == 0)
+ int result;
+ switch (current)
{
+ case 0:
coords[0] = getX1();
coords[1] = getY1();
- if (at != null)
- at.transform(coords, 0, coords, 0, 1);
- return SEG_MOVETO;
- }
- if (current == 1)
- {
+ result = SEG_MOVETO;
+ break;
+ case 1:
coords[0] = getCtrlX1();
coords[1] = getCtrlY1();
coords[2] = getCtrlX2();
coords[3] = getCtrlY2();
coords[4] = getX2();
coords[5] = getY2();
- if (at != null)
- at.transform(coords, 0, coords, 0, 3);
- return SEG_CUBICTO;
- }
- throw new NoSuchElementException("cubic iterator out of bounds");
+ result = SEG_CUBICTO;
+ break;
+ default:
+ throw new NoSuchElementException("cubic iterator out of bounds");
+ }
+ if (at != null)
+ at.transform(coords, 0, coords, 0, 3);
+ return result;
}
};
}
Index: java/awt/geom/Line2D.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/geom/Line2D.java,v
retrieving revision 1.5
diff -u -r1.5 Line2D.java
--- java/awt/geom/Line2D.java 14 Jan 2003 21:21:34 -0000 1.5
+++ java/awt/geom/Line2D.java 18 Jul 2003 15:16:31 -0000
@@ -668,7 +668,7 @@
return new PathIterator()
{
/** Current coordinate. */
- private int current;
+ private int current = 0;
public int getWindingRule()
{
@@ -677,7 +677,7 @@
public boolean isDone()
{
- return current < 2;
+ return current >= 2;
}
public void next()
Index: java/awt/geom/QuadCurve2D.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/geom/QuadCurve2D.java,v
retrieving revision 1.2
diff -u -r1.2 QuadCurve2D.java
--- java/awt/geom/QuadCurve2D.java 14 Jan 2003 21:21:34 -0000 1.2
+++ java/awt/geom/QuadCurve2D.java 18 Jul 2003 15:16:31 -0000
@@ -215,7 +215,7 @@
return new PathIterator()
{
/** Current coordinate. */
- private int current;
+ private int current = 0;
public int getWindingRule()
{
@@ -224,7 +224,7 @@
public boolean isDone()
{
- return current < 2;
+ return current >= 2;
}
public void next()
@@ -234,48 +234,52 @@
public int currentSegment(float[] coords)
{
- if (current == 0)
+ int result;
+ switch (current)
{
+ case 0:
coords[0] = (float) getX1();
coords[1] = (float) getY1();
- if (at != null)
- at.transform(coords, 0, coords, 0, 1);
- return SEG_MOVETO;
- }
- if (current == 1)
- {
+ result = SEG_MOVETO;
+ break;
+ case 1:
coords[0] = (float) getCtrlX();
coords[1] = (float) getCtrlY();
coords[2] = (float) getX2();
coords[3] = (float) getY2();
- if (at != null)
- at.transform(coords, 0, coords, 0, 2);
- return SEG_QUADTO;
+ result = SEG_QUADTO;
+ break;
+ default:
+ throw new NoSuchElementException("quad iterator out of bounds");
}
- throw new NoSuchElementException("quad iterator out of bounds");
+ if (at != null)
+ at.transform(coords, 0, coords, 0, 2);
+ return result;
}
public int currentSegment(double[] coords)
{
- if (current == 0)
+ int result;
+ switch (current)
{
+ case 0:
coords[0] = getX1();
coords[1] = getY1();
- if (at != null)
- at.transform(coords, 0, coords, 0, 1);
- return SEG_MOVETO;
- }
- if (current == 1)
- {
+ result = SEG_MOVETO;
+ break;
+ case 1:
coords[0] = getCtrlX();
coords[1] = getCtrlY();
coords[2] = getX2();
coords[3] = getY2();
- if (at != null)
- at.transform(coords, 0, coords, 0, 2);
- return SEG_QUADTO;
+ result = SEG_QUADTO;
+ break;
+ default:
+ throw new NoSuchElementException("quad iterator out of bounds");
}
- throw new NoSuchElementException("quad iterator out of bounds");
+ if (at != null)
+ at.transform(coords, 0, coords, 0, 2);
+ return result;
}
};
}