Top Description Inners Fields Constructors Methods
com.jogamp.graph.curve

public Class OutlineShape

extends Object
implements Comparable<OutlineShape>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable
Imports
java.util.ArrayList, .Collections, .Comparator, jogamp.graph.geom.plane.AffineTransform, com.jogamp.graph.curve.tess.Triangulation, .Triangulator, com.jogamp.graph.geom.Outline, .Triangle, .Vertex, com.jogamp.opengl.math.FloatUtil, .VectorUtil, com.jogamp.opengl.math.geom.AABBox

A Generic shape objects which is defined by a list of Outlines. This Shape can be transformed to triangulations. The list of triangles generated are render-able by a Region object. The triangulation produced by this Shape will define the closed region defined by the outlines. One or more OutlineShape Object can be associated to a region this is left as a high-level representation of the Objects. For optimizations, flexibility requirements for future features.

Example to creating an Outline Shape:
     addVertex(...)
     addVertex(...)
     addVertex(...)
     addEmptyOutline()
     addVertex(...)
     addVertex(...)
     addVertex(...)
The above will create two outlines each with three vertices. By adding these two outlines to the OutlineShape, we are stating that the combination of the two outlines represent the shape.
To specify that the shape is curved at a region, the on-curve flag should be set to false for the vertex that is in the middle of the curved region (if the curved region is defined by 3 vertices (quadratic curve).
In case the curved region is defined by 4 or more vertices the middle vertices should both have the on-curve flag set to false.
Example:
     addVertex(0,0, true);
     addVertex(0,1, false);
     addVertex(1,1, false);
     addVertex(1,0, true);
The above snippet defines a cubic nurbs curve where (0,1 and 1,1) do not belong to the final rendered shape. Implementation Notes:
See Also
Outline, Region

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
OutlineShape.VerticesState

Outline's vertices have undefined state until transformed.

Field Summary

Modifier and TypeField and Description
private int
private final AABBox
public static final float
DEFAULT_SHARPNESS

Initial getSharpness() value, which can be modified via setSharpness(float).

public static final int
public static final int
DIRTY_TRIANGLES

Modified shape, requires to update the vertices and triangles, here: triangulation.

public static final int
DIRTY_VERTICES

Modified shape, requires to update the vertices and triangles, here: vertices.

private int
dirtyBits

dirty bits DIRTY_BOUNDS

pack-priv final ArrayList<Outline>
outlines

The list of Outlines that are part of this outline shape.

private OutlineShape.VerticesState
private static Comparator<Outline>
private float
private final float[]
private final float[]
private final float[]
private final ArrayList<Triangle>
private final Vertex.Factory<? extends Vertex>
private final ArrayList<Vertex>

Constructor Summary

AccessConstructor and Description
public
OutlineShape(final Vertex.Factory<? extends Vertex> factory)

Create a new Outline based Shape

Method Summary

Modifier and TypeMethod and Description
public final void
addEmptyOutline()

Add a new empty Outline to the end of this shape's outline list.

public final void
addOutline(final Outline
Outline object to be added
outline
)

Appends the Outline element to the end, ensuring a clean tail.

public final void
addOutline(final int
of the added Outline
position
,
final Outline
Outline object to be added
outline
)

Insert the Outline element at the given position.

public final void
addOutlineShape(final OutlineShape
OutlineShape elements to be added.
outlineShape
)

Insert the OutlineShape elements of type Outline, ..

public final void
addVertex(final Vertex
the vertex to be added to the OutlineShape
v
)

Adds a vertex to the last open outline to the shape's tail.

public final void
addVertex(final int
indx at which the vertex will be added
position
,
final Vertex
the vertex to be added to the OutlineShape
v
)

Adds a vertex to the last open outline to the shape at position

public final void
addVertex(final float
the x coordinate
x
,
final float
the y coordniate
y
,
final boolean
flag if this vertex is on the final curve or defines a curved region of the shape around this vertex.
onCurve
)

Add a 2D Vertex to the last outline by defining the coordinate attribute of the vertex.

public final void
addVertex(final float
the x coordinate
x
,
final float
the y coordinate
y
,
final float
the z coordinate
z
,
final boolean
flag if this vertex is on the final curve or defines a curved region of the shape around this vertex.
onCurve
)

Add a 3D Vertex to the last outline by defining the coordniate attribute of the vertex.

public final void
addVertex(final float[]
the coordinate array where the vertex attributes are to be picked from
coordsBuffer
,
final int
the offset in the buffer to the x coordinate
offset
,
final int
the number of attributes to pick from the buffer (maximum 3)
length
,
final boolean
flag if this vertex is on the final curve or defines a curved region of the shape around this vertex.
onCurve
)

Add a vertex to the last outline by passing a float array and specifying the offset and length in which.

private void
checkOverlaps()

Check overlaps between curved triangles first check if any vertex in triangle a is in triangle b second check if edges of triangle a intersect segments of triangle b if any of the two tests is true we divide current triangle and add the other to the list of overlaps Loop until overlap array is empty.

private Vertex
checkTriOverlaps0(final Vertex a, final Vertex b, final Vertex c)

private Vertex
checkTriOverlaps1(final Vertex a, final Vertex b, final Vertex c)

private void
public void
clear()

Clears all data and reset all states as if this instance was newly created

public void
clearCache()

Clears cached triangulated data, i.e. getTriangles(VerticesState) and getVertices().

public final void
closeLastOutline(final boolean
if true, a clone of the first vertex will be appended, otherwise a clone of the last vertex will be prepended.
closeTail
)

Closes the last outline in the shape.

public final int
compareTo(final OutlineShape
the object to be compared.
other
)

Implements java.lang.Comparable.compareTo.

Compare two outline shape's Bounding Box size.
public boolean

Returns:

true if obj is an OutlineShape, not null, same outlineState, equal bounds and equal outlines in the same order
equals
(final Object
the Object to compare this OutlineShape with
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
private int
public int
getAddedVerticeCount()

Return the number of newly added vertices during getTriangles(VerticesState) while transforming the outlines to VerticesState#QUADRATIC_NURBS and triangulation.

public final AABBox
public final Outline

Returns:

the last outline
getLastOutline
()

Get the last added outline to the list of outlines that define the shape

public final Outline
getOutline(final int position)

Returns the Outline at position

public final int
public final OutlineShape.VerticesState
getOutlineState()

Return the outline's vertices state, OutlineShape.VerticesState

public float
getSharpness()

Sharpness value, defaults to DEFAULT_SHARPNESS.

public ArrayList<Triangle>

Returns:

an arraylist of triangles representing the filled region which is produced by the combination of the outlines
getTriangles
(final OutlineShape.VerticesState destinationType)

Triangulate the OutlineShape generating a list of triangles, while transformOutlines(VerticesState) beforehand.

public final ArrayList<Vertex>
getVertices()

Return list of concatenated vertices associated with all Outlines of this object.

public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public final Outline
removeOutline(final int
of the to be removed Outline
position
)

Removes the Outline element at the given position.

public final void
setIsQuadraticNurbs()

Claim this outline's vertices are all OutlineShape.VerticesState#QUADRATIC_NURBS, hence no cubic transformations will be performed.

public final void
setOutline(final int
of the replaced Outline
position
,
final Outline
replacement Outline object
outline
)

Replaces the Outline element at the given position.

public void
setSharpness(final float s)

Sets sharpness, defaults to DEFAULT_SHARPNESS.

private void
sortOutlines()

Sort the outlines from large to small depending on the AABox

private void
subdivideTriangle(final Outline outline, final Vertex a, final Vertex b, final Vertex c, final int index)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public final OutlineShape
transform(final AffineTransform t)

Return a transformed instance with all Outlines are copied and transformed.

private void
private void
public final Vertex.Factory<? extends Vertex>

Returns:

Vertex.Factory object
vertexFactory
()

Returns the associated vertex factory of this outline shape

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

addedVerticeCountback to summary
private int addedVerticeCount
bboxback to summary
private final AABBox bbox
DEFAULT_SHARPNESSback to summary
public static final float DEFAULT_SHARPNESS

Initial getSharpness() value, which can be modified via setSharpness(float).

DIRTY_BOUNDSback to summary
public static final int DIRTY_BOUNDS
DIRTY_TRIANGLESback to summary
public static final int DIRTY_TRIANGLES

Modified shape, requires to update the vertices and triangles, here: triangulation.

DIRTY_VERTICESback to summary
public static final int DIRTY_VERTICES

Modified shape, requires to update the vertices and triangles, here: vertices.

dirtyBitsback to summary
private int dirtyBits

dirty bits DIRTY_BOUNDS

outlinesback to summary
pack-priv final ArrayList<Outline> outlines

The list of Outlines that are part of this outline shape.

outlineStateback to summary
private OutlineShape.VerticesState outlineState
reversSizeComparatorback to summary
private static Comparator<Outline> reversSizeComparator
sharpnessback to summary
private float sharpness
tmpV1back to summary
private final float[] tmpV1
tmpV2back to summary
private final float[] tmpV2
tmpV3back to summary
private final float[] tmpV3
trianglesback to summary
private final ArrayList<Triangle> triangles
vertexFactoryback to summary
private final Vertex.Factory<? extends Vertex> vertexFactory
verticesback to summary
private final ArrayList<Vertex> vertices

Constructor Detail

OutlineShapeback to summary
public OutlineShape(final Vertex.Factory<? extends Vertex> factory)

Create a new Outline based Shape

Method Detail

addEmptyOutlineback to summary
public final void addEmptyOutline()

Add a new empty Outline to the end of this shape's outline list.

If the getLastOutline() is empty already, no new one will be added.

After a call to this function all new vertices added will belong to the new outline
addOutlineback to summary
public final void addOutline(final Outline outline) throws NullPointerException

Appends the Outline element to the end, ensuring a clean tail.

A clean tail is ensured, no double empty Outlines are produced and a pre-existing empty outline will be replaced with the given one.

Parameters
outline:Outline

Outline object to be added

Exceptions
NullPointerException:
if the Outline element is null
addOutlineback to summary
public final void addOutline(final int position, final Outline outline) throws NullPointerException, IndexOutOfBoundsException

Insert the Outline element at the given position.

If the position indicates the end of this list, a clean tail is ensured, no double empty Outlines are produced and a pre-existing empty outline will be replaced with the given one.

Parameters
position:int

of the added Outline

outline:Outline

Outline object to be added

Exceptions
NullPointerException:
if the Outline element is null
IndexOutOfBoundsException:
if position is out of range (position < 0 || position > getOutlineNumber())
addOutlineShapeback to summary
public final void addOutlineShape(final OutlineShape outlineShape) throws NullPointerException

Insert the OutlineShape elements of type Outline, .. at the end of this shape, using addOutline(Outline) for each element.

Closes the current last outline via closeLastOutline(boolean) before adding the new ones.

Parameters
outlineShape:OutlineShape

OutlineShape elements to be added.

Exceptions
NullPointerException:
if the OutlineShape is null
IndexOutOfBoundsException:
if position is out of range (position < 0 || position > getOutlineNumber())
addVertexback to summary
public final void addVertex(final Vertex v)

Adds a vertex to the last open outline to the shape's tail.

Parameters
v:Vertex

the vertex to be added to the OutlineShape

addVertexback to summary
public final void addVertex(final int position, final Vertex v)

Adds a vertex to the last open outline to the shape at position

Parameters
position:int

indx at which the vertex will be added

v:Vertex

the vertex to be added to the OutlineShape

addVertexback to summary
public final void addVertex(final float x, final float y, final boolean onCurve)

Add a 2D Vertex to the last outline by defining the coordinate attribute of the vertex. The 2D vertex will be represented as Z=0.

Parameters
x:float

the x coordinate

y:float

the y coordniate

onCurve:boolean

flag if this vertex is on the final curve or defines a curved region of the shape around this vertex.

addVertexback to summary
public final void addVertex(final float x, final float y, final float z, final boolean onCurve)

Add a 3D Vertex to the last outline by defining the coordniate attribute of the vertex.

Parameters
x:float

the x coordinate

y:float

the y coordinate

z:float

the z coordinate

onCurve:boolean

flag if this vertex is on the final curve or defines a curved region of the shape around this vertex.

addVertexback to summary
public final void addVertex(final float[] coordsBuffer, final int offset, final int length, final boolean onCurve)

Add a vertex to the last outline by passing a float array and specifying the offset and length in which. The attributes of the vertex are located. The attributes should be continuous (stride = 0). Attributes which value are not set (when length less than 3) are set implicitly to zero.

Parameters
coordsBuffer:float[]

the coordinate array where the vertex attributes are to be picked from

offset:int

the offset in the buffer to the x coordinate

length:int

the number of attributes to pick from the buffer (maximum 3)

onCurve:boolean

flag if this vertex is on the final curve or defines a curved region of the shape around this vertex.

checkOverlapsback to summary
private void checkOverlaps()

Check overlaps between curved triangles first check if any vertex in triangle a is in triangle b second check if edges of triangle a intersect segments of triangle b if any of the two tests is true we divide current triangle and add the other to the list of overlaps Loop until overlap array is empty. (check only in first pass)

checkTriOverlaps0back to summary
private Vertex checkTriOverlaps0(final Vertex a, final Vertex b, final Vertex c)
checkTriOverlaps1back to summary
private Vertex checkTriOverlaps1(final Vertex a, final Vertex b, final Vertex c)
Annotations
@SuppressWarnings:unused
cleanupOutlinesback to summary
private void cleanupOutlines()
clearback to summary
public void clear()

Clears all data and reset all states as if this instance was newly created

clearCacheback to summary
public void clearCache()

Clears cached triangulated data, i.e. getTriangles(VerticesState) and getVertices().

closeLastOutlineback to summary
public final void closeLastOutline(final boolean closeTail)

Closes the last outline in the shape.

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 closeTail.

Parameters
closeTail:boolean

if true, a clone of the first vertex will be appended, otherwise a clone of the last vertex will be prepended.

compareToback to summary
public final int compareTo(final OutlineShape other)

Implements java.lang.Comparable.compareTo.

Compare two outline shape's Bounding Box size.

Parameters
other:OutlineShape

Doc from java.lang.Comparable.compareTo.

the object to be compared.

Returns:int

Doc from java.lang.Comparable.compareTo.

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
See Also
AABBox#getSize(), java.lang.Comparable#compareTo(java.lang.Object)
equalsback to summary
public boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the Object to compare this OutlineShape with

Returns:boolean

true if obj is an OutlineShape, not null, same outlineState, equal bounds and equal outlines in the same order

Annotations
@Override
generateVertexIdsback to summary
private int generateVertexIds()
getAddedVerticeCountback to summary
public int getAddedVerticeCount()

Return the number of newly added vertices during getTriangles(VerticesState) while transforming the outlines to VerticesState#QUADRATIC_NURBS and triangulation.

See Also
setIsQuadraticNurbs()
getBoundsback to summary
public final AABBox getBounds()
getLastOutlineback to summary
public final Outline getLastOutline()

Get the last added outline to the list of outlines that define the shape

Returns:Outline

the last outline

getOutlineback to summary
public final Outline getOutline(final int position) throws IndexOutOfBoundsException

Returns the Outline at position

Exceptions
IndexOutOfBoundsException:
if position is out of range (position < 0 || position >= getOutlineNumber())
getOutlineNumberback to summary
public final int getOutlineNumber()
getOutlineStateback to summary
public final OutlineShape.VerticesState getOutlineState()

Return the outline's vertices state, OutlineShape.VerticesState

getSharpnessback to summary
public float getSharpness()

Sharpness value, defaults to DEFAULT_SHARPNESS.

getTrianglesback to summary
public ArrayList<Triangle> getTriangles(final OutlineShape.VerticesState destinationType)

Triangulate the OutlineShape generating a list of triangles, while transformOutlines(VerticesState) beforehand.

Triangles are cached until marked dirty.

Returns:ArrayList<Triangle>

an arraylist of triangles representing the filled region which is produced by the combination of the outlines

getVerticesback to summary
public final ArrayList<Vertex> getVertices()

Return list of concatenated vertices associated with all Outlines of this object.

Vertices are cached until marked dirty.

Should always be called after getTriangles(VerticesState), since the latter will mark all cached vertices dirty!

hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
removeOutlineback to summary
public final Outline removeOutline(final int position) throws IndexOutOfBoundsException

Removes the Outline element at the given position.

Sets the bounding box dirty, hence a next call to getBounds() will validate it.

Parameters
position:int

of the to be removed Outline

Exceptions
IndexOutOfBoundsException:
if position is out of range (position < 0 || position >= getOutlineNumber())
setIsQuadraticNurbsback to summary
public final void setIsQuadraticNurbs()

Claim this outline's vertices are all OutlineShape.VerticesState#QUADRATIC_NURBS, hence no cubic transformations will be performed.

setOutlineback to summary
public final void setOutline(final int position, final Outline outline) throws NullPointerException, IndexOutOfBoundsException

Replaces the Outline element at the given position.

Sets the bounding box dirty, hence a next call to getBounds() will validate it.

Parameters
position:int

of the replaced Outline

outline:Outline

replacement Outline object

Exceptions
NullPointerException:
if the Outline element is null
IndexOutOfBoundsException:
if position is out of range (position < 0 || position >= getOutlineNumber())
setSharpnessback to summary
public void setSharpness(final float s)

Sets sharpness, defaults to DEFAULT_SHARPNESS.

sortOutlinesback to summary
private void sortOutlines()

Sort the outlines from large to small depending on the AABox

subdivideTriangleback to summary
private void subdivideTriangle(final Outline outline, final Vertex a, final Vertex b, final Vertex c, final int index)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
transformback to summary
public final OutlineShape transform(final AffineTransform t)

Return a transformed instance with all Outlines are copied and transformed.

Note

Triangulated data is lost in returned instance!

triangulateImplback to summary
private void triangulateImpl()
validateBoundingBoxback to summary
private void validateBoundingBox()
vertexFactoryback to summary
public final Vertex.Factory<? extends Vertex> vertexFactory()

Returns the associated vertex factory of this outline shape

Returns:Vertex.Factory<? extends Vertex>

Vertex.Factory object

com.jogamp.graph.curve back to summary

public final Enum OutlineShape.VerticesState

extends Enum<OutlineShape.VerticesState>
Class Inheritance

Outline's vertices have undefined state until transformed.

Field Summary

Modifier and TypeField and Description
public static final OutlineShape.VerticesState
public final int
public static final OutlineShape.VerticesState

Constructor Summary

AccessConstructor and Description
private
VerticesState(final int state)

Method Summary

Modifier and TypeMethod and Description
public static OutlineShape.VerticesState
public static OutlineShape.VerticesState[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

QUADRATIC_NURBSback to summary
public static final OutlineShape.VerticesState QUADRATIC_NURBS
stateback to summary
public final int state
UNDEFINEDback to summary
public static final OutlineShape.VerticesState UNDEFINED

Constructor Detail

VerticesStateback to summary
private VerticesState(final int state)

Method Detail

valueOfback to summary
public static OutlineShape.VerticesState valueOf(String name)
valuesback to summary
public static OutlineShape.VerticesState[] values()