Class Outline

  • All Implemented Interfaces:

    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
    • 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,
                       Winding enforce)
        Copy ctor w/ enforced Winding

        If the enforced Winding doesn't match the source Outline, the vertices reversed copied into this new instance.

        src - the source Outline
        enforce - Winding to be enforced on this copy
    • Method Detail

      • setWinding

        public final void setWinding​(Winding enforce)
        Sets Winding to this outline

        If the enforced Winding doesn't match this Outline, the vertices are reversed.

        enforce - to be enforced Winding
      • getWinding

        public final Winding getWinding()
        Compute the winding of the #getLastOutline() using the #area(ArrayList) function over all of its vertices.
        Winding.CCW or Winding.CW
      • getVertexCount

        public final int getVertexCount()
      • getVertex

        public final Vertex getVertex​(int index)
      • getVertexIndex

        public int getVertexIndex​(Vertex vertex)
      • removeVertex

        public final Vertex removeVertex​(int position)
                                  throws IndexOutOfBoundsException
        Removes the Vertex 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 Vertex
        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.

        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 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.
        true if closing performed, otherwise false for NOP
      • transform

        public final Outline transform​(AffineTransform t)
        Return a transformed instance with all vertices are copied and transformed.
      • getBounds

        public final AABBox getBounds()
      • equals

        public boolean equals​(Object obj)
        equals in class Object
        obj - the Object to compare this Outline with
        true if obj is an Outline, not null, equals bounds and equal vertices in the same order
      • hashCode

        public final int hashCode()
        hashCode in class Object