diff options
author | Sven Göthel <[email protected]> | 2024-02-02 10:24:51 +0100 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-02-02 10:24:51 +0100 |
commit | aa39750aa27fc4c65f34fbd599186b30e5005f59 (patch) | |
tree | 3dc4050e2ed216514f432d05efeb9b34a8e89b3c | |
parent | 1639bf159810895eb24791c8128a7b2c02d15a56 (diff) |
Remove Clonable and clone() in favor of explicit determined copy() and copy-ctor in com.jogamp.graph.* and com.jogamp.math.*
8 files changed, 36 insertions, 71 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java index 2da0f6850..cda46d8f6 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java +++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java @@ -502,11 +502,11 @@ public final class OutlineShape implements Comparable<OutlineShape> { * Closes the last outline in the shape. * <p> * Checks whether the last vertex equals to the first of the last outline. - * If not equal, it either appends a clone of the first vertex - * or prepends a clone of the last vertex, depending on <code>closeTail</code>. + * If not equal, it either appends a copy of the first vertex + * or prepends a copy of the last vertex, depending on <code>closeTail</code>. * </p> - * @param closeTail if true, a clone of the first vertex will be appended, - * otherwise a clone of the last vertex will be prepended. + * @param closeTail if true, a copy of the first vertex will be appended, + * otherwise a copy of the last vertex will be prepended. */ public final void closeLastOutline(final boolean closeTail) { if( getLastOutline().setClosed( closeTail ) ) { diff --git a/src/jogl/classes/com/jogamp/graph/geom/Outline.java b/src/jogl/classes/com/jogamp/graph/geom/Outline.java index 272f92f37..b593c20be 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Outline.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Outline.java @@ -80,7 +80,7 @@ public class Outline implements Comparable<Outline> { winding = src.getWinding(); dirtyWinding = false; for(int i=0; i<count; i++) { - vertices.add( src.vertices.get(i).clone() ); + vertices.add( src.vertices.get(i).copy() ); } closed = src.closed; bbox = new AABBox(src.bbox); @@ -103,12 +103,12 @@ public class Outline implements Comparable<Outline> { dirtyWinding = false; if( enforce != had_winding ) { for(int i=count-1; i>=0; --i) { - vertices.add( src.vertices.get(i).clone() ); + vertices.add( src.vertices.get(i).copy() ); } winding = enforce; } else { for(int i=0; i<count; ++i) { - vertices.add( src.vertices.get(i).clone() ); + vertices.add( src.vertices.get(i).copy() ); } } closed = src.closed; @@ -256,11 +256,11 @@ public class Outline implements Comparable<Outline> { * Ensure this outline is closed. * <p> * Checks whether the last vertex equals to the first. - * If not equal, it either appends a clone of the first vertex - * or prepends a clone of the last vertex, depending on <code>closeTail</code>. + * If not equal, it either appends a copy of the first vertex + * or prepends a copy of the last vertex, depending on <code>closeTail</code>. * </p> - * @param closeTail if true, a clone of the first vertex will be appended, - * otherwise a clone of the last vertex will be prepended. + * @param closeTail if true, a copy of the first vertex will be appended, + * otherwise a copy of the last vertex will be prepended. * @return true if closing performed, otherwise false for NOP */ public final boolean setClosed(final boolean closeTail) { @@ -270,9 +270,9 @@ public class Outline implements Comparable<Outline> { final Vertex last = getLastVertex(); if( !first.getCoord().isEqual( last.getCoord() ) ) { if( closeTail ) { - vertices.add(first.clone()); + vertices.add(first.copy()); } else { - vertices.add(0, last.clone()); + vertices.add(0, last.copy()); } return true; } diff --git a/src/jogl/classes/com/jogamp/graph/geom/Triangle.java b/src/jogl/classes/com/jogamp/graph/geom/Triangle.java index e26d2aaf1..032213387 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Triangle.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Triangle.java @@ -46,9 +46,9 @@ public class Triangle { public Triangle(final Triangle src) { id = src.id; - vertices[0] = src.vertices[0].clone(); - vertices[1] = src.vertices[1].clone(); - vertices[2] = src.vertices[2].clone(); + vertices[0] = src.vertices[0].copy(); + vertices[1] = src.vertices[1].copy(); + vertices[2] = src.vertices[2].copy(); System.arraycopy(src.boundaryEdges, 0, boundaryEdges, 0, 3); boundaryVertices = new boolean[3]; System.arraycopy(src.boundaryVertices, 0, boundaryVertices, 0, 3); @@ -62,7 +62,7 @@ public class Triangle { } /** - * Returns a transformed a clone of this instance using the given AffineTransform. + * Returns a transformed copy of this instance using the given AffineTransform. */ public Triangle transform(final AffineTransform t) { final Triangle tri = new Triangle(id, boundaryEdges, boundaryVertices); diff --git a/src/jogl/classes/com/jogamp/graph/geom/Vertex.java b/src/jogl/classes/com/jogamp/graph/geom/Vertex.java index 8744474d9..67d468ab6 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Vertex.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Vertex.java @@ -34,7 +34,7 @@ import com.jogamp.math.Vert3fImmutable; /** * A Vertex exposing Vec3f vertex- and texture-coordinates. */ -public final class Vertex implements Vert3fImmutable, Cloneable { +public final class Vertex implements Vert3fImmutable { private int id; private boolean onCurve; private final Vec3f coord = new Vec3f(); @@ -44,6 +44,7 @@ public final class Vertex implements Vert3fImmutable, Cloneable { this.id = Integer.MAX_VALUE; } + /** Copy ctor */ public Vertex(final Vertex src) { this.id = Integer.MAX_VALUE; coord.set(src.getCoord()); @@ -195,11 +196,10 @@ public final class Vertex implements Vert3fImmutable, Cloneable { } /** - * @return deep clone of this Vertex elements + * @return deep copy of this Vertex element via {@link Vertex#Vertex(Vertex)} */ - @Override - public Vertex clone(){ - return new Vertex(this); // OK to not call super.clone(), using own copy-ctor + public Vertex copy(){ + return new Vertex(this); } @Override diff --git a/src/jogl/classes/com/jogamp/math/geom/plane/AffineTransform.java b/src/jogl/classes/com/jogamp/math/geom/plane/AffineTransform.java index 05d7e201e..f0ae250b4 100644 --- a/src/jogl/classes/com/jogamp/math/geom/plane/AffineTransform.java +++ b/src/jogl/classes/com/jogamp/math/geom/plane/AffineTransform.java @@ -28,7 +28,7 @@ import com.jogamp.math.Vec2f; import com.jogamp.math.Vec3f; import com.jogamp.math.geom.AABBox; -public class AffineTransform implements Cloneable { +public class AffineTransform { static final String determinantIsZero = "Determinant is zero"; @@ -560,20 +560,6 @@ public class AffineTransform implements Cloneable { } } - public final Path2F createTransformedShape(final Path2F src) { - if (src == null) { - return null; - } - return src.createTransformedShape(this); - /** - * If !(src instanceof Path2D): (but here it always is) - final PathIterator path = src.iterator(this); - final Path2D dst = new Path2D(path.getWindingRule()); - dst.append(path, false); - return dst; - */ - } - @Override public final String toString() { return @@ -582,15 +568,6 @@ public class AffineTransform implements Cloneable { + m10 + ", " + m11 + ", " + m12 + "]]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } - @Override - public final AffineTransform clone() { - try { - return (AffineTransform) super.clone(); - } catch (final CloneNotSupportedException e) { - throw new InternalError(); - } - } - /** @Override public int hashCode() { HashCode hash = new HashCode(); diff --git a/src/jogl/classes/com/jogamp/math/geom/plane/Path2F.java b/src/jogl/classes/com/jogamp/math/geom/plane/Path2F.java index 9e0dda286..6c3e76ad8 100644 --- a/src/jogl/classes/com/jogamp/math/geom/plane/Path2F.java +++ b/src/jogl/classes/com/jogamp/math/geom/plane/Path2F.java @@ -28,7 +28,7 @@ import com.jogamp.math.geom.AABBox; /** * Path2F represents and provides construction method for a 2D shape using float[2] points. */ -public final class Path2F implements Cloneable { +public final class Path2F { static final String invalidWindingRuleValue = "Invalid winding rule value"; static final String iteratorOutOfBounds = "Iterator out of bounds"; @@ -507,7 +507,7 @@ public final class Path2F implements Cloneable { } public Path2F createTransformedShape(final AffineTransform t) { - final Path2F p = (Path2F)clone(); + final Path2F p = new Path2F(this); if (t != null) { p.transform(t); } @@ -587,17 +587,5 @@ public final class Path2F implements Cloneable { /* public Path2F.Iterator getPathIterator(AffineTransform t, float flatness) { return new FlatteningPathIterator(getPathIterator(t), flatness); } */ - - @Override - public Object clone() { - try { - final Path2F p = (Path2F) super.clone(); - p.m_types = m_types.clone(); - p.m_points = m_points.clone(); - return p; - } catch (final CloneNotSupportedException e) { - throw new InternalError(); - } - } } diff --git a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java index b7fee25e5..fe1aad169 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2D.java @@ -204,9 +204,9 @@ public class CDTriangulator2D implements Triangulator { final GraphVertex gv2 = outVertices.get((i+1)%size); // +1 if( !gv1.getPoint().isOnCurve() ) { - final Vertex v0 = gv0.getPoint().clone(); - final Vertex v2 = gv2.getPoint().clone(); - final Vertex v1 = gv1.getPoint().clone(); + final Vertex v0 = gv0.getPoint().copy(); + final Vertex v2 = gv2.getPoint().copy(); + final Vertex v1 = gv1.getPoint().copy(); addedVerticeCount += 3; final boolean[] boundaryVertices = { true, true, true }; diff --git a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java index 32f526f3b..5429192cd 100644 --- a/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java +++ b/src/jogl/classes/jogamp/graph/curve/tess/CDTriangulator2DExpAddOn.java @@ -95,17 +95,17 @@ public class CDTriangulator2DExpAddOn { } } else { if( v0IsLS ) { - final Vertex v = v0.clone(); + final Vertex v = v0.copy(); v.setTexCoord(0f, 0f, texZTag); triVs[0] = v; } if( v1IsLS ) { - final Vertex v = v1.clone(); + final Vertex v = v1.copy(); v.setTexCoord(0f, 0f, texZTag); triVs[1] = v; } if( v2IsLS ) { - final Vertex v = v2.clone(); + final Vertex v = v2.copy(); v.setTexCoord(0f, 0f, texZTag); triVs[2] = v; } @@ -252,16 +252,16 @@ public class CDTriangulator2DExpAddOn { vOA = verts1[otherIdxA]; vOB = verts2[otherIdxB]; } else { - // Fetch and clone, write-back to triangles - vC0A = verts1[commonIdxA[0]].clone(); + // Fetch and copy, write-back to triangles + vC0A = verts1[commonIdxA[0]].copy(); verts1[commonIdxA[0]] = vC0A; verts2[commonIdxB[0]] = vC0A; - vC1A = verts1[commonIdxA[1]].clone(); + vC1A = verts1[commonIdxA[1]].copy(); verts1[commonIdxA[1]] = vC1A; verts2[commonIdxB[1]] = vC1A; - vOA = verts1[otherIdxA].clone(); + vOA = verts1[otherIdxA].copy(); verts1[otherIdxA] = vOA; - vOB = verts2[otherIdxB].clone(); + vOB = verts2[otherIdxB].copy(); verts2[otherIdxB] = vOB; } |