Class PolylineBuffer
java.lang.Object
org.apache.sis.internal.processing.isoline.PolylineBuffer
Coordinates of a polyline under construction. Coordinates can be appended in only one direction.
If the polyline may growth on both directions (which happens if the polyline crosses the bottom
side and the right side of a cell), then the two directions are handled by two distinct instances
connected by their
opposite field.
When a polyline has been completed, its content is copied to Tracer.Level.path
and the PolylineBuffer object is recycled for a new polyline.
- Since:
- 1.1
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) double[]Coordinates as (x,y) tuples.(package private) static final intNumber of coordinates in a tuple.(package private) PolylineBufferIf the polyline has points added to its two extremities, the other extremity.(package private) intNumber of valid elements in thecoordinatesarray. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an initially empty polyline.PolylineBuffer(double[] data) Creates a new polyline wrapping the given coordinates. -
Method Summary
Modifier and TypeMethodDescription(package private) final voidappend(double x, double y) Appends given coordinates to this polyline.(package private) final PolylineBufferattach(PolylineBuffer other) Declares that the specified polyline will add points in the direction opposite to this polyline.(package private) final voidclear()Discards all coordinates in this polyline.(package private) final booleanisEmpty()Returns whether this polyline is empty.(package private) final voidtoRawPath(Map<PolylineStage, Path2D> appendTo) Appends the pixel coordinates of this polyline to the given path, for debugging purposes only.toString()Returns a string representation of thisPolylinefor debugging purposes.(package private) final PolylineBuffertransferFrom(PolylineBuffer source) Transfers all coordinates from given polylines to this polylines, in same order.(package private) final booleanTransfers all coordinates from this polyline to the polyline going in opposite direction.
-
Field Details
-
DIMENSION
static final int DIMENSIONNumber of coordinates in a tuple.- See Also:
-
coordinates
double[] coordinatesCoordinates as (x,y) tuples. This array is expanded as needed. -
size
int sizeNumber of valid elements in thecoordinatesarray. This is twice the number of points. -
opposite
PolylineBuffer oppositeIf the polyline has points added to its two extremities, the other extremity. Otherwisenull. The first point ofoppositepolyline is connected to the first point of this polyline. Consequently, when those two polylines are joined in a single polyline, the coordinates of eitherthisoroppositemust be iterated in reverse order.
-
-
Constructor Details
-
PolylineBuffer
PolylineBuffer()Creates an initially empty polyline. -
PolylineBuffer
PolylineBuffer(double[] data) Creates a new polyline wrapping the given coordinates. Used for wrappingFragmentsinstances in objects expected byTracer.writeTo(Joiner, Polyline[], boolean). ThosePolylineinstances are temporary.
-
-
Method Details
-
clear
final void clear()Discards all coordinates in this polyline. This method does not clear theoppositepolyline; it is caller's responsibility to do so. -
isEmpty
final boolean isEmpty()Returns whether this polyline is empty. This method is used only forassert isEmpty()statement because of the check foropposite == null: an empty polyline should not have a non-nulloppositevalue. -
attach
Declares that the specified polyline will add points in the direction opposite to this polyline. This happens when the polyline crosses the bottom side and the right side of a cell (assuming an iteration from left to right and top to bottom).This method is typically invoked in the following pattern (but this is not mandatory). An important aspect is that
thisandothershould be on perpendicular axes:- Returns:
thisfor method calls chaining.
-
transferFrom
Transfers all coordinates from given polylines to this polylines, in same order. This is used when polyline on the left side continues on bottom side, or conversely when polyline on the top side continues on right side. This polyline shall be empty before this method is invoked. The given source will become empty after this method returned.- Parameters:
source- the source from which to take data.- Returns:
thisfor method calls chaining.
-
transferToOpposite
final boolean transferToOpposite()Transfers all coordinates from this polyline to the polyline going in opposite direction. This is used when this polyline reached the right image border, in which case its data will be lost if we do not copy them somewhere.- Returns:
trueif coordinates have been transferred, orfalseif there is no opposite direction.
-
append
final void append(double x, double y) Appends given coordinates to this polyline.- Parameters:
x- first coordinate of the (x,y) tuple to add.y- second coordinate of the (x,y) tuple to add.
-
toString
Returns a string representation of thisPolylinefor debugging purposes. -
toRawPath
Appends the pixel coordinates of this polyline to the given path, for debugging purposes only. The#gridToCRStransform is not applied by this method. For avoiding confusing behavior, that transform should be null.- Parameters:
appendTo- where to append the coordinates.- See Also:
-