aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/graph/math/plane
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-05-06 14:50:56 +0200
committerSven Gothel <[email protected]>2011-05-06 14:50:56 +0200
commit2570c1bee6dd8b33ac2e92b533e32b69b02a2cfc (patch)
tree2c8773508e01a628e3f9da121e78d45d8636705c /src/jogl/classes/jogamp/graph/math/plane
parentd75835796900cac602f7e5789601ffba0a27efe2 (diff)
GlyphShape: Use switch block for PathIterator - adding default (exception)
Implements more of John Pritchard <[email protected]> proposal https://github.com/syntelos/jogl/commit/05a7ec92d30e1e688b1eb7cc317cad83a0e8fd60
Diffstat (limited to 'src/jogl/classes/jogamp/graph/math/plane')
-rw-r--r--src/jogl/classes/jogamp/graph/math/plane/Crossing.java102
1 files changed, 54 insertions, 48 deletions
diff --git a/src/jogl/classes/jogamp/graph/math/plane/Crossing.java b/src/jogl/classes/jogamp/graph/math/plane/Crossing.java
index 2138b217d..9be5978cc 100644
--- a/src/jogl/classes/jogamp/graph/math/plane/Crossing.java
+++ b/src/jogl/classes/jogamp/graph/math/plane/Crossing.java
@@ -467,31 +467,34 @@ public class Crossing {
int cross = 0;
float mx, my, cx, cy;
mx = my = cx = cy = 0.0f;
- float coords[] = new float[6];
+ final float coords[] = new float[6];
while (!p.isDone()) {
- switch (p.currentSegment(coords)) {
- case PathIterator.SEG_MOVETO:
- if (cx != mx || cy != my) {
- cross += crossLine(cx, cy, mx, my, x, y);
- }
- mx = cx = coords[0];
- my = cy = coords[1];
- break;
- case PathIterator.SEG_LINETO:
- cross += crossLine(cx, cy, cx = coords[0], cy = coords[1], x, y);
- break;
- case PathIterator.SEG_QUADTO:
- cross += crossQuad(cx, cy, coords[0], coords[1], cx = coords[2], cy = coords[3], x, y);
- break;
- case PathIterator.SEG_CUBICTO:
- cross += crossCubic(cx, cy, coords[0], coords[1], coords[2], coords[3], cx = coords[4], cy = coords[5], x, y);
- break;
- case PathIterator.SEG_CLOSE:
- if (cy != my || cx != mx) {
- cross += crossLine(cx, cy, cx = mx, cy = my, x, y);
- }
- break;
+ final int segmentType = p.currentSegment(coords);
+ switch (segmentType) {
+ case PathIterator.SEG_MOVETO:
+ if (cx != mx || cy != my) {
+ cross += crossLine(cx, cy, mx, my, x, y);
+ }
+ mx = cx = coords[0];
+ my = cy = coords[1];
+ break;
+ case PathIterator.SEG_LINETO:
+ cross += crossLine(cx, cy, cx = coords[0], cy = coords[1], x, y);
+ break;
+ case PathIterator.SEG_QUADTO:
+ cross += crossQuad(cx, cy, coords[0], coords[1], cx = coords[2], cy = coords[3], x, y);
+ break;
+ case PathIterator.SEG_CUBICTO:
+ cross += crossCubic(cx, cy, coords[0], coords[1], coords[2], coords[3], cx = coords[4], cy = coords[5], x, y);
+ break;
+ case PathIterator.SEG_CLOSE:
+ if (cy != my || cx != mx) {
+ cross += crossLine(cx, cy, cx = mx, cy = my, x, y);
+ }
+ break;
+ default:
+ throw new IllegalArgumentException("Unhandled Segment Type: "+segmentType);
}
// checks if the point (x,y) is the vertex of shape with PathIterator p
@@ -821,7 +824,7 @@ public class Crossing {
int count;
float mx, my, cx, cy;
mx = my = cx = cy = 0.0f;
- float coords[] = new float[6];
+ final float coords[] = new float[6];
float rx1 = x;
float ry1 = y;
@@ -830,30 +833,33 @@ public class Crossing {
while (!p.isDone()) {
count = 0;
- switch (p.currentSegment(coords)) {
- case PathIterator.SEG_MOVETO:
- if (cx != mx || cy != my) {
- count = intersectLine(cx, cy, mx, my, rx1, ry1, rx2, ry2);
- }
- mx = cx = coords[0];
- my = cy = coords[1];
- break;
- case PathIterator.SEG_LINETO:
- count = intersectLine(cx, cy, cx = coords[0], cy = coords[1], rx1, ry1, rx2, ry2);
- break;
- case PathIterator.SEG_QUADTO:
- count = intersectQuad(cx, cy, coords[0], coords[1], cx = coords[2], cy = coords[3], rx1, ry1, rx2, ry2);
- break;
- case PathIterator.SEG_CUBICTO:
- count = intersectCubic(cx, cy, coords[0], coords[1], coords[2], coords[3], cx = coords[4], cy = coords[5], rx1, ry1, rx2, ry2);
- break;
- case PathIterator.SEG_CLOSE:
- if (cy != my || cx != mx) {
- count = intersectLine(cx, cy, mx, my, rx1, ry1, rx2, ry2);
- }
- cx = mx;
- cy = my;
- break;
+ final int segmentType = p.currentSegment(coords);
+ switch (segmentType) {
+ case PathIterator.SEG_MOVETO:
+ if (cx != mx || cy != my) {
+ count = intersectLine(cx, cy, mx, my, rx1, ry1, rx2, ry2);
+ }
+ mx = cx = coords[0];
+ my = cy = coords[1];
+ break;
+ case PathIterator.SEG_LINETO:
+ count = intersectLine(cx, cy, cx = coords[0], cy = coords[1], rx1, ry1, rx2, ry2);
+ break;
+ case PathIterator.SEG_QUADTO:
+ count = intersectQuad(cx, cy, coords[0], coords[1], cx = coords[2], cy = coords[3], rx1, ry1, rx2, ry2);
+ break;
+ case PathIterator.SEG_CUBICTO:
+ count = intersectCubic(cx, cy, coords[0], coords[1], coords[2], coords[3], cx = coords[4], cy = coords[5], rx1, ry1, rx2, ry2);
+ break;
+ case PathIterator.SEG_CLOSE:
+ if (cy != my || cx != mx) {
+ count = intersectLine(cx, cy, mx, my, rx1, ry1, rx2, ry2);
+ }
+ cx = mx;
+ cy = my;
+ break;
+ default:
+ throw new IllegalArgumentException("Unhandled Segment Type: "+segmentType);
}
if (count == CROSSING) {
return CROSSING;