diff options
Diffstat (limited to 'src/jogl/classes/jogamp')
8 files changed, 128 insertions, 136 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java index 91a7e4246..749292297 100644 --- a/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java +++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java @@ -67,7 +67,7 @@ public class GlyphShape { pathIterator.next(); } } - shape.transformOutlines(OutlineShape.QUADRATIC_NURBS); + shape.transformOutlines(OutlineShape.VerticesState.QUADRATIC_NURBS); } public final Vertex.Factory<? extends Vertex> vertexFactory() { return shape.vertexFactory(); } @@ -77,51 +77,34 @@ public class GlyphShape { } private void addOutlineVerticesFromGlyphVector(float[] coords, int segmentType){ - if(segmentType == PathIterator.SEG_MOVETO){ - if(!shape.getLastOutline().isEmpty()){ - shape.addEmptyOutline(); - } - Vertex vert = vertexFactory().create(coords[0],coords[1]); - vert.setOnCurve(true); - addVertexToLastOutline(vert); - - numVertices++; - } - else if(segmentType == PathIterator.SEG_LINETO){ - Vertex vert1 = vertexFactory().create(coords[0],coords[1]); - vert1.setOnCurve(true); - addVertexToLastOutline(vert1); - - numVertices++; - } - else if(segmentType == PathIterator.SEG_QUADTO){ - Vertex vert1 = vertexFactory().create(coords[0],coords[1]); - vert1.setOnCurve(false); - addVertexToLastOutline(vert1); - - Vertex vert2 = vertexFactory().create(coords[2],coords[3]); - vert2.setOnCurve(true); - addVertexToLastOutline(vert2); - - numVertices+=2; - } - else if(segmentType == PathIterator.SEG_CUBICTO){ - Vertex vert1 = vertexFactory().create(coords[0],coords[1]); - vert1.setOnCurve(false); - addVertexToLastOutline(vert1); - - Vertex vert2 = vertexFactory().create(coords[2],coords[3]); - vert2.setOnCurve(false); - addVertexToLastOutline(vert2); - - Vertex vert3 = vertexFactory().create(coords[4],coords[5]); - vert3.setOnCurve(true); - addVertexToLastOutline(vert3); - - 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); } } diff --git a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java index a904c2b48..852d84f5a 100644 --- a/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java +++ b/src/jogl/classes/jogamp/graph/curve/text/GlyphString.java @@ -45,12 +45,11 @@ import jogamp.graph.geom.plane.PathIterator; import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.RegionFactory; import com.jogamp.graph.curve.opengl.RenderState; -import com.jogamp.opengl.util.glsl.ShaderState; public class GlyphString { private ArrayList<GlyphShape> glyphs = new ArrayList<GlyphShape>(); - private String str = ""; - private String fontname = ""; + private CharSequence str; + private String fontname; private Region region; private SVertex origin = new SVertex(); @@ -60,7 +59,7 @@ public class GlyphString { * associated with * @param str the string object */ - public GlyphString(String fontname, String str){ + public GlyphString(String fontname, CharSequence str){ this.fontname = fontname; this.str = str; } @@ -68,7 +67,8 @@ public class GlyphString { public void addGlyphShape(GlyphShape glyph){ glyphs.add(glyph); } - public String getString(){ + + public CharSequence getString(){ return str; } diff --git a/src/jogl/classes/jogamp/graph/font/FontInt.java b/src/jogl/classes/jogamp/graph/font/FontInt.java index f915d57f0..6c25f9a80 100644 --- a/src/jogl/classes/jogamp/graph/font/FontInt.java +++ b/src/jogl/classes/jogamp/graph/font/FontInt.java @@ -46,7 +46,7 @@ public interface FontInt extends Font { public Path2D getPath(float pixelSize); } - public void getPaths(String string, float pixelSize, + public void getPaths(CharSequence string, float pixelSize, AffineTransform transform, Path2D[] result); //TODO: Rami - ADD getOutlines without path2D } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java index dae5b3333..2e5774622 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java @@ -199,11 +199,11 @@ class TypecastFont implements FontInt { return result; } - public void getPaths(String string, float pixelSize, AffineTransform transform, Path2D[] result) { + public void getPaths(CharSequence string, float pixelSize, AffineTransform transform, Path2D[] result) { TypecastRenderer.getPaths(this, string, pixelSize, transform, result); } - public float getStringWidth(String string, float pixelSize) { + public float getStringWidth(CharSequence string, float pixelSize) { float width = 0; final int len = string.length(); for (int i=0; i< len; i++) @@ -220,7 +220,7 @@ class TypecastFont implements FontInt { return (int)(width + 0.5f); } - public float getStringHeight(String string, float pixelSize) { + public float getStringHeight(CharSequence string, float pixelSize) { int height = 0; for (int i=0; i<string.length(); i++) @@ -274,4 +274,4 @@ class TypecastFont implements FontInt { return FontFactory.isPrintableChar(c); } -}
\ No newline at end of file +} diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java index c8861d744..f3029b1e4 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java @@ -41,7 +41,7 @@ import com.jogamp.graph.font.Font; public class TypecastRenderer { public static void getPaths(TypecastFont font, - String string, float pixelSize, AffineTransform transform, Path2D[] p) + CharSequence string, float pixelSize, AffineTransform transform, Path2D[] p) { if (string == null) { return; diff --git a/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java b/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java index 79e842887..fc086ebe4 100644 --- a/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java +++ b/src/jogl/classes/jogamp/graph/geom/plane/AffineTransform.java @@ -409,7 +409,7 @@ public class AffineTransform implements Cloneable, Serializable { float x = src.getX(); float y = src.getY(); - dst.setCoord(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12); + dst.setCoord(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12, 0f); return dst; } @@ -422,7 +422,7 @@ public class AffineTransform implements Cloneable, Serializable { if (dstPoint == null) { throw new IllegalArgumentException("dst["+dstOff+"] is null"); } - dstPoint.setCoord(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12); + dstPoint.setCoord(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12, 0f); dst[dstOff++] = dstPoint; } } @@ -452,7 +452,7 @@ public class AffineTransform implements Cloneable, Serializable { float x = src.getX(); float y = src.getY(); - dst.setCoord(x * m00 + y * m01, x * m10 + y * m11); + dst.setCoord(x * m00 + y * m01, x * m10 + y * m11, 0f); return dst; } @@ -477,7 +477,7 @@ public class AffineTransform implements Cloneable, Serializable { float x = src.getX() - m02; float y = src.getY() - m12; - dst.setCoord((x * m11 - y * m01) / det, (y * m00 - x * m10) / det); + dst.setCoord((x * m11 - y * m01) / det, (y * m00 - x * m10) / det, 0f); return dst; } @@ -519,9 +519,9 @@ public class AffineTransform implements Cloneable, Serializable { } @Override - public Object clone() { + public AffineTransform clone() { try { - return super.clone(); + return (AffineTransform) super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(); } diff --git a/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java b/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java index edeabaa40..8082fe4e1 100644 --- a/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java +++ b/src/jogl/classes/jogamp/graph/geom/plane/Path2D.java @@ -268,32 +268,35 @@ public final class Path2D implements Cloneable { public void append(PathIterator path, boolean connect) { while (!path.isDone()) { - float coords[] = new float[6]; - switch (path.currentSegment(coords)) { - case PathIterator.SEG_MOVETO: - if (!connect || typeSize == 0) { - moveTo(coords[0], coords[1]); + final float coords[] = new float[6]; + final int segmentType = path.currentSegment(coords); + switch (segmentType) { + case PathIterator.SEG_MOVETO: + if (!connect || typeSize == 0) { + moveTo(coords[0], coords[1]); + break; + } + if (types[typeSize - 1] != PathIterator.SEG_CLOSE && + points[pointSize - 2] == coords[0] && + points[pointSize - 1] == coords[1]) + { + break; + } + // NO BREAK; + case PathIterator.SEG_LINETO: + lineTo(coords[0], coords[1]); break; - } - if (types[typeSize - 1] != PathIterator.SEG_CLOSE && - points[pointSize - 2] == coords[0] && - points[pointSize - 1] == coords[1]) - { + case PathIterator.SEG_QUADTO: + quadTo(coords[0], coords[1], coords[2], coords[3]); break; - } - // NO BREAK; - case PathIterator.SEG_LINETO: - lineTo(coords[0], coords[1]); - break; - case PathIterator.SEG_QUADTO: - quadTo(coords[0], coords[1], coords[2], coords[3]); - break; - case PathIterator.SEG_CUBICTO: - curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]); - break; - case PathIterator.SEG_CLOSE: - closePath(); - break; + case PathIterator.SEG_CUBICTO: + curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]); + break; + case PathIterator.SEG_CLOSE: + closePath(); + break; + default: + throw new IllegalArgumentException("Unhandled Segment Type: "+segmentType); } path.next(); connect = false; @@ -315,7 +318,7 @@ public final class Path2D implements Cloneable { j -= pointShift[type]; } } - return new SVertex(points[j], points[j + 1]); + return new SVertex(points[j], points[j + 1], 0f, true); } public void reset() { 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; |