public class Contour extends Object
The complete() method should always be called when a contour is fully populated (e.g. it is complete). The complete call trims the internal buffers and performs any sanity checking required for contour management.
A closed-loop contour is expected to always include a "closure point" so that the first point in the contour matches the last. This approach is taken to simplify internal logic in the contour building routines. The complete() method ensures that a closure point is added to closed-loop contours if none is provided by the application.
Modifier and Type | Class and Description |
---|---|
static class |
Contour.ContourType
An enumeration that indicates the type of a contour
|
Constructor and Description |
---|
Contour(int leftIndex,
int rightIndex,
double z,
boolean closedLoop)
Constructs an instance of a contour
|
Modifier and Type | Method and Description |
---|---|
void |
add(double x,
double y)
Add an coordinate point to the contour.
|
void |
complete()
Called when the construction of a contour is complete to trim the memory
for the internal point collection.
|
int |
getContourId()
Gets the serialized identification code for the contour.
|
Contour.ContourType |
getContourType()
Indicates whether the contour is an interior or perimeter contour.
|
double[] |
getCoordinates()
Gets a safe copy of the coordinates for the contour.
|
int |
getLeftIndex()
Get the index for the region lying to the left of the contour.
|
Path2D |
getPath2D(AffineTransform transform)
Gets a Path2D suitable for rendering purposes.
|
int |
getRightIndex()
Get the index for the region lying to the right of the contour.
|
double[] |
getXY()
Gets a safe copy of the coordinates for the contour.
|
double |
getZ()
Gets the z value associated with the contour
|
boolean |
isBoundary()
Indicates whether the contour is a boundary contour.
|
boolean |
isClosed()
Indicates that the contour forms a closed loop
|
boolean |
isEmpty()
Indicates whether the contour is empty.
|
int |
size()
Indicates the number of points stored in the contour
|
String |
toString() |
public Contour(int leftIndex, int rightIndex, double z, boolean closedLoop)
leftIndex
- the contour-interval index of the area to the left of the
contour.rightIndex
- the contour-interval index of the area to the right of
the contour.z
- the vertical coordinate for the contourclosedLoop
- indicates if the contour is to be treated as a closed
loop.public void add(double x, double y)
x
- the Cartesian x-coordinate for the pointy
- the Cartesian y-coordinate for the pointpublic double[] getCoordinates()
public double[] getXY()
{ (x0,y0), (x1,y1), (x2,y2), etc. }.
public double getZ()
public boolean isEmpty()
public int size()
public void complete()
References to edges and contour-building elements are not affected by this call.
public int getContourId()
public Path2D getPath2D(AffineTransform transform)
transform
- a valid AffineTransform, typically specified to map the
Cartesian coordinates of the contour to pixel coordinate.public Contour.ContourType getContourType()
public boolean isBoundary()
public boolean isClosed()
public int getLeftIndex()
public int getRightIndex()
Copyright © 2021. All rights reserved.