public class DefaultWritablePolygon2D extends AbstractRealInterval implements WritablePolygon2D
DefaultWritablePolygon2D
defined by the given vertices. The resulting
polygon may contain some edge points, all edge points, or no edge points
depending on the specified shape.
If consistent edge point inclusion/exclusion is needed see
OpenWritablePolygon2D
or ClosedWritablePolygon2D
. These implementations will
be less efficient but have consistent edge behavior.
Modifier and Type | Class and Description |
---|---|
protected class |
DefaultWritablePolygon2D.VertexList |
Modifier and Type | Field and Description |
---|---|
protected DefaultWritablePolygon2D.VertexList |
x |
protected DefaultWritablePolygon2D.VertexList |
y |
max, min
n
Constructor and Description |
---|
DefaultWritablePolygon2D(double[] x,
double[] y)
Creates a 2D polygon with vertices at the provided x, y coordinates.
|
DefaultWritablePolygon2D(List<? extends RealLocalizable> vertices)
Creates a 2D polygon with the provided vertices.
|
Modifier and Type | Method and Description |
---|---|
void |
addVertex(int index,
RealLocalizable vertex)
If the given vertex has more than 2 dimensions, the higher dimensions
will be ignored.
|
void |
addVertices(int index,
Collection<RealLocalizable> vertices)
Adds vertices starting at the given index.
|
boolean |
equals(Object obj)
Determines whether this polygon describes the same region as another one.
|
int |
hashCode() |
int |
numVertices()
Returns the number of vertices in the shape.
|
void |
removeVertex(int index)
Removes the vertex at the given index.
|
boolean |
test(RealLocalizable localizable)
Return true if the given point is contained inside the boundary.
|
RealLocalizableRealPositionable |
vertex(int pos)
Return a copy of the vertex
|
realMax, realMax, realMax, realMin, realMin, realMin, toString
numDimensions
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addVertex
hashCode, maskType, numDimensions
and, isEmpty, minus, or, realMax, realMax, realMin, realMin, transform, xor
boundaryType, isAll, knownConstant
maxAsDoubleArray, maxAsRealPoint, minAsDoubleArray, minAsRealPoint, realMax, realMin
protected final DefaultWritablePolygon2D.VertexList x
protected final DefaultWritablePolygon2D.VertexList y
public DefaultWritablePolygon2D(List<? extends RealLocalizable> vertices)
vertices
- List of vertices which will be copied. Each vertex should have
a position in 2D space, positions beyond 2D will be ignored.public DefaultWritablePolygon2D(double[] x, double[] y)
x
- X coordinates of the vertices which will be copiedy
- Y coordinates of the vertices which will be copiedpublic boolean test(RealLocalizable localizable)
test
in interface Predicate<RealLocalizable>
public RealLocalizableRealPositionable vertex(int pos)
vertex
in interface Polyshape
vertex
in interface WritablePolyshape
public int numVertices()
Polyshape
numVertices
in interface Polyshape
public void addVertex(int index, RealLocalizable vertex)
addVertex
in interface WritablePolyshape
public void removeVertex(int index)
WritablePolyshape
removeVertex
in interface WritablePolyshape
public void addVertices(int index, Collection<RealLocalizable> vertices)
WritablePolyshape
addVertices
in interface WritablePolyshape
public boolean equals(Object obj)
Polygon2D
equals
in interface Polygon2D
equals
in interface MaskPredicate<RealLocalizable>
equals
in class Object
obj
- The polygon to compare with this one.MaskPredicate.equals(Object)
,
Polyshape.equals(Polyshape, Polyshape)
Copyright © 2015–2022 ImgLib2. All rights reserved.