diff options
author | Sven Gothel <[email protected]> | 2011-05-06 14:50:56 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-05-06 14:50:56 +0200 |
commit | 2570c1bee6dd8b33ac2e92b533e32b69b02a2cfc (patch) | |
tree | 2c8773508e01a628e3f9da121e78d45d8636705c /src/jogl/classes/jogamp/graph/curve | |
parent | d75835796900cac602f7e5789601ffba0a27efe2 (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/curve')
-rw-r--r-- | src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java index 46d7fa947..749292297 100644 --- a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java +++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java @@ -77,30 +77,34 @@ public class GlyphShape { } private void addOutlineVerticesFromGlyphVector(float[] coords, int segmentType){ - if(segmentType == PathIterator.SEG_MOVETO){ - if(!shape.getLastOutline().isEmpty()){ - shape.addEmptyOutline(); - } - addVertexToLastOutline(vertexFactory().create(coords, 0, 2, true)); - numVertices++; - } - else if(segmentType == PathIterator.SEG_LINETO){ - addVertexToLastOutline(vertexFactory().create(coords, 0, 2, true)); - numVertices++; - } - else if(segmentType == PathIterator.SEG_QUADTO){ - addVertexToLastOutline(vertexFactory().create(coords, 0, 2, false)); - addVertexToLastOutline(vertexFactory().create(coords, 2, 2, true)); - numVertices+=2; - } - else if(segmentType == PathIterator.SEG_CUBICTO){ - addVertexToLastOutline(vertexFactory().create(coords, 0, 2, false)); - addVertexToLastOutline(vertexFactory().create(coords, 2, 2, false)); - addVertexToLastOutline(vertexFactory().create(coords, 4, 2, true)); - numVertices+=3; - } - else if(segmentType == PathIterator.SEG_CLOSE){ - shape.closeLastOutline(); + switch(segmentType) { + case PathIterator.SEG_MOVETO: + if(!shape.getLastOutline().isEmpty()){ + shape.addEmptyOutline(); + } + addVertexToLastOutline(vertexFactory().create(coords, 0, 2, true)); + numVertices++; + break; + case PathIterator.SEG_LINETO: + addVertexToLastOutline(vertexFactory().create(coords, 0, 2, true)); + numVertices++; + break; + case PathIterator.SEG_QUADTO: + addVertexToLastOutline(vertexFactory().create(coords, 0, 2, false)); + addVertexToLastOutline(vertexFactory().create(coords, 2, 2, true)); + numVertices+=2; + break; + case PathIterator.SEG_CUBICTO: + addVertexToLastOutline(vertexFactory().create(coords, 0, 2, false)); + addVertexToLastOutline(vertexFactory().create(coords, 2, 2, false)); + addVertexToLastOutline(vertexFactory().create(coords, 4, 2, true)); + numVertices+=3; + break; + case PathIterator.SEG_CLOSE: + shape.closeLastOutline(); + break; + default: + throw new IllegalArgumentException("Unhandled Segment Type: "+segmentType); } } |