From 2570c1bee6dd8b33ac2e92b533e32b69b02a2cfc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 6 May 2011 14:50:56 +0200 Subject: GlyphShape: Use switch block for PathIterator - adding default (exception) Implements more of John Pritchard proposal https://github.com/syntelos/jogl/commit/05a7ec92d30e1e688b1eb7cc317cad83a0e8fd60 --- .../jogamp/graph/curve/text/GlyphShape.java | 52 ++++++++++++---------- 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'src/jogl/classes/jogamp/graph/curve') 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); } } -- cgit v1.2.3