public class OutlineShape extends Object implements Comparable<OutlineShape>
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.
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:
Modifier and Type | Class and Description |
---|---|
static class |
OutlineShape.VerticesState
Outline's vertices have undefined state until transformed.
|
Modifier and Type | Field and Description |
---|---|
static float |
DEFAULT_SHARPNESS
Initial
getSharpness() value, which can be modified via setSharpness(float) . |
static int |
DIRTY_BOUNDS |
static int |
DIRTY_TRIANGLES
Modified shape, requires to update the vertices and triangles, here: triangulation.
|
static int |
DIRTY_VERTICES
Modified shape, requires to update the vertices and triangles, here: vertices.
|
Constructor and Description |
---|
OutlineShape(Vertex.Factory<? extends Vertex> factory)
Create a new Outline based Shape
|
Modifier and Type | Method and Description |
---|---|
void |
addEmptyOutline()
Add a new empty
Outline
to the end of this shape's outline list. |
void |
addOutline(int position,
Outline outline)
Insert the
Outline element at the given position . |
void |
addOutline(Outline outline)
Appends the
Outline element to the end,
ensuring a clean tail. |
void |
addOutlineShape(OutlineShape outlineShape)
Insert the
OutlineShape elements of type Outline , .. |
void |
addVertex(float[] coordsBuffer,
int offset,
int length,
boolean onCurve)
Add a vertex to the last outline by passing a float array and specifying the
offset and length in which.
|
void |
addVertex(float x,
float y,
boolean onCurve)
Add a 2D
Vertex to the last outline by defining the coordinate attribute
of the vertex. |
void |
addVertex(float x,
float y,
float z,
boolean onCurve)
Add a 3D
Vertex to the last outline by defining the coordniate attribute
of the vertex. |
void |
addVertex(int position,
Vertex v)
Adds a vertex to the last open outline to the shape at
position |
void |
addVertex(Vertex v)
Adds a vertex to the last open outline to the shape's tail.
|
void |
clear()
Clears all data and reset all states as if this instance was newly created
|
void |
clearCache()
Clears cached triangulated data, i.e.
|
void |
closeLastOutline(boolean closeTail)
Closes the last outline in the shape.
|
int |
compareTo(OutlineShape other)
Compare two outline shape's Bounding Box size.
|
boolean |
equals(Object obj) |
int |
getAddedVerticeCount()
Return the number of newly added vertices during
getTriangles(VerticesState)
while transforming the outlines to OutlineShape.VerticesState.QUADRATIC_NURBS and triangulation. |
AABBox |
getBounds() |
Outline |
getLastOutline()
Get the last added outline to the list
of outlines that define the shape
|
Outline |
getOutline(int position)
Returns the
Outline at position |
int |
getOutlineNumber() |
OutlineShape.VerticesState |
getOutlineState()
Return the outline's vertices state,
OutlineShape.VerticesState |
float |
getSharpness()
Sharpness value, defaults to
DEFAULT_SHARPNESS . |
ArrayList<Triangle> |
getTriangles(OutlineShape.VerticesState destinationType)
Triangulate the
OutlineShape generating a list of triangles,
while #transformOutlines(VerticesState) beforehand. |
ArrayList<Vertex> |
getVertices()
Return list of concatenated vertices associated with all
Outline s of this object. |
int |
hashCode() |
Outline |
removeOutline(int position)
Removes the
Outline element at the given position . |
void |
setIsQuadraticNurbs()
Claim this outline's vertices are all
OutlineShape.VerticesState.QUADRATIC_NURBS ,
hence no cubic transformations will be performed. |
void |
setOutline(int position,
Outline outline)
Replaces the
Outline element at the given position . |
void |
setSharpness(float s)
Sets sharpness, defaults to
DEFAULT_SHARPNESS . |
String |
toString() |
OutlineShape |
transform(jogamp.graph.geom.plane.AffineTransform t)
Return a transformed instance with all
Outline s are copied and transformed. |
Vertex.Factory<? extends Vertex> |
vertexFactory()
Returns the associated vertex factory of this outline shape
|
public static final float DEFAULT_SHARPNESS
getSharpness()
value, which can be modified via setSharpness(float)
.public static final int DIRTY_BOUNDS
public static final int DIRTY_VERTICES
public static final int DIRTY_TRIANGLES
public OutlineShape(Vertex.Factory<? extends Vertex> factory)
public int getAddedVerticeCount()
getTriangles(VerticesState)
while transforming the outlines to OutlineShape.VerticesState.QUADRATIC_NURBS
and triangulation.setIsQuadraticNurbs()
public float getSharpness()
DEFAULT_SHARPNESS
.public void setSharpness(float s)
DEFAULT_SHARPNESS
.public void clear()
public void clearCache()
getTriangles(VerticesState)
and getVertices()
.public final Vertex.Factory<? extends Vertex> vertexFactory()
public final int getOutlineNumber()
public final void addEmptyOutline()
Outline
to the end of this shape's outline list.
If the getLastOutline()
is empty already, no new one will be added.
public final void addOutline(Outline outline) throws NullPointerException
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.
outline
- Outline object to be addedNullPointerException
- if the Outline
element is nullpublic final void addOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException
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.
position
- of the added Outlineoutline
- Outline object to be addedNullPointerException
- if the Outline
element is nullIndexOutOfBoundsException
- if position is out of range (position < 0 || position > getOutlineNumber())public final void addOutlineShape(OutlineShape outlineShape) throws NullPointerException
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.
outlineShape
- OutlineShape elements to be added.NullPointerException
- if the OutlineShape
is nullIndexOutOfBoundsException
- if position is out of range (position < 0 || position > getOutlineNumber())public final void setOutline(int position, Outline outline) throws NullPointerException, IndexOutOfBoundsException
Outline
element at the given position
.
Sets the bounding box dirty, hence a next call to getBounds()
will validate it.
position
- of the replaced Outlineoutline
- replacement Outline objectNullPointerException
- if the Outline
element is nullIndexOutOfBoundsException
- if position is out of range (position < 0 || position >= getOutlineNumber())public final Outline removeOutline(int position) throws IndexOutOfBoundsException
Outline
element at the given position
.
Sets the bounding box dirty, hence a next call to getBounds()
will validate it.
position
- of the to be removed OutlineIndexOutOfBoundsException
- if position is out of range (position < 0 || position >= getOutlineNumber())public final Outline getLastOutline()
public final Outline getOutline(int position) throws IndexOutOfBoundsException
Outline
at position
IndexOutOfBoundsException
- if position is out of range (position < 0 || position >= getOutlineNumber())public final void addVertex(Vertex v)
v
- the vertex to be added to the OutlineShapepublic final void addVertex(int position, Vertex v)
position
position
- indx at which the vertex will be addedv
- the vertex to be added to the OutlineShapepublic final void addVertex(float x, float y, boolean onCurve)
Vertex
to the last outline by defining the coordinate attribute
of the vertex. The 2D vertex will be represented as Z=0.x
- the x coordinatey
- the y coordniateonCurve
- flag if this vertex is on the final curve or defines a curved region
of the shape around this vertex.public final void addVertex(float x, float y, float z, boolean onCurve)
Vertex
to the last outline by defining the coordniate attribute
of the vertex.x
- the x coordinatey
- the y coordinatez
- the z coordinateonCurve
- flag if this vertex is on the final curve or defines a curved region
of the shape around this vertex.public final void addVertex(float[] coordsBuffer, int offset, int length, boolean onCurve)
coordsBuffer
- the coordinate array where the vertex attributes are to be picked fromoffset
- the offset in the buffer to the x coordinatelength
- the number of attributes to pick from the buffer (maximum 3)onCurve
- flag if this vertex is on the final curve or defines a curved region
of the shape around this vertex.public final void closeLastOutline(boolean closeTail)
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
.
closeTail
- if true, a clone of the first vertex will be appended,
otherwise a clone of the last vertex will be prepended.public final OutlineShape.VerticesState getOutlineState()
OutlineShape.VerticesState
public final void setIsQuadraticNurbs()
OutlineShape.VerticesState.QUADRATIC_NURBS
,
hence no cubic transformations will be performed.public final ArrayList<Vertex> getVertices()
Outline
s 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!
public ArrayList<Triangle> getTriangles(OutlineShape.VerticesState destinationType)
OutlineShape
generating a list of triangles,
while #transformOutlines(VerticesState)
beforehand.
Triangles are cached until marked dirty.
public final OutlineShape transform(jogamp.graph.geom.plane.AffineTransform t)
Outline
s are copied and transformed.
Note: Triangulated data is lost in returned instance!
public final int compareTo(OutlineShape other)
compareTo
in interface Comparable<OutlineShape>
AABBox.getSize()
,
Comparable.compareTo(java.lang.Object)
public final AABBox getBounds()
public boolean equals(Object obj)
Copyright 2010 JogAmp Community.