diff options
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/geom/Outline.java')
-rw-r--r-- | src/jogl/classes/com/jogamp/graph/geom/Outline.java | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/geom/Outline.java b/src/jogl/classes/com/jogamp/graph/geom/Outline.java index 2d9d74966..b299524c0 100644 --- a/src/jogl/classes/com/jogamp/graph/geom/Outline.java +++ b/src/jogl/classes/com/jogamp/graph/geom/Outline.java @@ -29,7 +29,10 @@ package com.jogamp.graph.geom; import java.util.ArrayList; +import jogamp.graph.geom.plane.AffineTransform; + import com.jogamp.graph.geom.Vertex; +import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.math.VectorUtil; import com.jogamp.opengl.math.geom.AABBox; @@ -181,21 +184,18 @@ public class Outline implements Cloneable, Comparable<Outline> { return false; } - /** Compare two outlines with Bounding Box area - * as criteria. - * @see java.lang.Comparable#compareTo(java.lang.Object) + /** + * Return a transformed instance with all vertices are copied and transformed. */ - @Override - public final int compareTo(Outline outline) { - float size = getBounds().getSize(); - float newSize = outline.getBounds().getSize(); - if(size < newSize){ - return -1; - } - else if(size > newSize){ - return 1; + public final Outline transform(AffineTransform t) { + final Outline newOutline = new Outline(); + final int vsize = vertices.size(); + for(int i=0; i<vsize; i++) { + final Vertex v = vertices.get(i); + newOutline.addVertex(t.transform(v, null)); } - return 0; + newOutline.closed = this.closed; + return newOutline; } private final void validateBoundingBox() { @@ -214,6 +214,24 @@ public class Outline implements Cloneable, Comparable<Outline> { } /** + * Compare two outline's Bounding Box size. + * @see AABBox#getSize() + * @see java.lang.Comparable#compareTo(java.lang.Object) + */ + @Override + public final int compareTo(final Outline other) { + final float thisSize = getBounds().getSize(); + final float otherSize = other.getBounds().getSize(); + if( FloatUtil.equals(thisSize, otherSize, FloatUtil.EPSILON) ) { + return 0; + } else if(thisSize < otherSize){ + return -1; + } else { + return 1; + } + } + + /** * @param obj the Object to compare this Outline with * @return true if {@code obj} is an Outline, not null, equals bounds and equal vertices in the same order */ |