Package com.jogamp.graph.geom
Class Outline
- java.lang.Object
-
- com.jogamp.graph.geom.Outline
-
- All Implemented Interfaces:
Comparable<Outline>
public class Outline extends Object implements Comparable<Outline>
Define a single continuous stroke by control vertices. The vertices define the shape of the region defined by this outline. The Outline can contain a list of off-curve and on-curve vertices which define curved regions. Note: An outline should be closed to be rendered as a region.- See Also:
OutlineShape
,Region
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addVertex(int position, Vertex vertex)
Insert theVertex
element at the givenposition
to the outline loop/strip.void
addVertex(Vertex vertex)
Appends a vertex to the outline loop/strip.int
compareTo(Outline other)
Compare two outline's Bounding Box size.boolean
equals(Object obj)
com.jogamp.math.geom.AABBox
getBounds()
Vertex
getLastVertex()
Vertex
getVertex(int index)
int
getVertexCount()
int
getVertexIndex(Vertex vertex)
ArrayList<Vertex>
getVertices()
com.jogamp.math.geom.plane.Winding
getWinding()
int
hashCode()
boolean
isClosed()
boolean
isComplex()
Returns cached or computed result if whether thisOutline
spolyline
is a complex shape.boolean
isEmpty()
void
print(PrintStream out)
Vertex
removeVertex(int position)
Removes theVertex
element at the givenposition
.boolean
setClosed(boolean closeTail)
Ensure this outline is closed.void
setVertex(int position, Vertex vertex)
Replaces theVertex
element at the givenposition
.void
setVertices(ArrayList<Vertex> vertices)
Use the given outline loop/strip.void
setWinding(com.jogamp.math.geom.plane.Winding enforce)
SetsWinding
to this outlineString
toString()
Outline
transform(com.jogamp.math.geom.plane.AffineTransform t)
Return a transformed instance with all vertices are copied and transformed.
-
-
-
Constructor Detail
-
Outline
public Outline()
Create an outline defined by control vertices. An outline can contain off Curve vertices which define curved regions in the outline.
-
Outline
public Outline(Outline src)
Copy ctor
-
Outline
public Outline(Outline src, com.jogamp.math.geom.plane.Winding enforce)
Copy ctor w/ enforced WindingIf the enforced
Winding
doesn't match the source Outline, the vertices reversed copied into this new instance.- Parameters:
src
- the source Outlineenforce
-Winding
to be enforced on this copy
-
-
Method Detail
-
setWinding
public final void setWinding(com.jogamp.math.geom.plane.Winding enforce)
SetsWinding
to this outlineIf the enforced
Winding
doesn't match this Outline, the vertices are reversed.- Parameters:
enforce
- to be enforcedWinding
-
getWinding
public final com.jogamp.math.geom.plane.Winding getWinding()
Returns the cached or computed winding of thisOutline
spolyline
usingVectorUtil#area(ArrayList)
.The result is cached.
- Returns:
Winding.CCW
orWinding.CW
-
isComplex
public boolean isComplex()
Returns cached or computed result if whether thisOutline
spolyline
is a complex shape.A polyline with less than 3 elements is marked a simple shape for simplicity.
The result is cached.
-
getVertexCount
public final int getVertexCount()
-
addVertex
public final void addVertex(Vertex vertex) throws NullPointerException
Appends a vertex to the outline loop/strip.- Parameters:
vertex
- Vertex to be added- Throws:
NullPointerException
- if theVertex
element is null
-
addVertex
public final void addVertex(int position, Vertex vertex) throws NullPointerException, IndexOutOfBoundsException
Insert theVertex
element at the givenposition
to the outline loop/strip.- Parameters:
position
- of the added Vertexvertex
- Vertex object to be added- Throws:
NullPointerException
- if theVertex
element is nullIndexOutOfBoundsException
- if position is out of range (position < 0 || position > getVertexNumber())
-
setVertex
public final void setVertex(int position, Vertex vertex) throws NullPointerException, IndexOutOfBoundsException
Replaces theVertex
element at the givenposition
.Sets the bounding box dirty, hence a next call to
getBounds()
will validate it.- Parameters:
position
- of the replaced Vertexvertex
- replacement Vertex object- Throws:
NullPointerException
- if theOutline
element is nullIndexOutOfBoundsException
- if position is out of range (position < 0 || position >= getVertexNumber())
-
getVertex
public final Vertex getVertex(int index)
-
getVertexIndex
public int getVertexIndex(Vertex vertex)
-
removeVertex
public final Vertex removeVertex(int position) throws IndexOutOfBoundsException
Removes theVertex
element at the givenposition
.Sets the bounding box dirty, hence a next call to
getBounds()
will validate it.- Parameters:
position
- of the to be removed Vertex- Throws:
IndexOutOfBoundsException
- if position is out of range (position < 0 || position >= getVertexNumber())
-
isEmpty
public final boolean isEmpty()
-
getLastVertex
public final Vertex getLastVertex()
-
setVertices
public final void setVertices(ArrayList<Vertex> vertices)
Use the given outline loop/strip.Validates the bounding box.
- Parameters:
vertices
- the new outline loop/strip
-
isClosed
public final boolean isClosed()
-
setClosed
public final boolean setClosed(boolean closeTail)
Ensure this outline is closed.Checks whether the last vertex equals to the first. If not equal, it either appends a copy of the first vertex or prepends a copy of the last vertex, depending on
closeTail
.- Parameters:
closeTail
- if true, a copy of the first vertex will be appended, otherwise a copy of the last vertex will be prepended.- Returns:
- true if closing performed, otherwise false for NOP
-
transform
public final Outline transform(com.jogamp.math.geom.plane.AffineTransform t)
Return a transformed instance with all vertices are copied and transformed.
-
getBounds
public final com.jogamp.math.geom.AABBox getBounds()
-
compareTo
public final int compareTo(Outline other)
Compare two outline's Bounding Box size.- Specified by:
compareTo
in interfaceComparable<Outline>
- See Also:
AABBox.getSize()
,Comparable.compareTo(java.lang.Object)
-
equals
public boolean equals(Object obj)
-
print
public void print(PrintStream out)
-
-