Package org.tinfour.common
Class LinearConstraint
- java.lang.Object
-
- org.tinfour.common.PolyLineConstraintAdapter
-
- org.tinfour.common.LinearConstraint
-
- All Implemented Interfaces:
Iterable<Vertex>,IConstraint,IPolyline
public class LinearConstraint extends PolyLineConstraintAdapter implements IConstraint
An implementation of the IConstraint interface intended to store constraints comprised of a chain of connected line segments. Constraint chains must be non-self-intersecting (except at segment endpoints). The chain must never "fold back" on itself. All segments in the chain must be non-zero-length.Do not use this class for closed polygons.
-
-
Field Summary
-
Fields inherited from class org.tinfour.common.PolyLineConstraintAdapter
applicationData, constraintIndex, constraintLinkingEdge, isComplete, length, list, maintainingTin
-
-
Constructor Summary
Constructors Constructor Description LinearConstraint()The standard constructorLinearConstraint(List<Vertex> vList)Constructs a constraint with the specified vertices.LinearConstraint(Vertex v0, Vertex v1)A convience constructor intended for the frequently occurring case in which an application wishes to define a constraint as a single line segment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomplete()Called to indicate that the feature is complete and that no further vertices will be added to it.booleandefinesConstrainedRegion()Indicates whether the constraint defines a data area.LinearConstraintgetConstraintWithNewGeometry(List<Vertex> geometry)Gets a new constraint that has the attributes of this constraint and the specified geometry.doublegetNominalPointSpacing()Get the average distance between points for the feature.Path2DgetPath2D(AffineTransform transform)Gets a Java Path2D based on the geometry of the constraint mapped through an optional affine transform.booleanisPolygon()Indicates whether the instance represents a polygon.booleanisValid()Indicates that sufficient information has been stored in the polyline to establish a valid geometry.LinearConstraintrefactor(Iterable<Vertex> geometry)Creates a new polyline feature with the specified geometry and transfers any data elements defined by the implementing class from the current object to the newly created one.-
Methods inherited from class org.tinfour.common.PolyLineConstraintAdapter
add, densify, getApplicationData, getBounds, getConstraintIndex, getConstraintLinkingEdge, getLength, getManagingTin, getVertices, isPointInsideConstraint, iterator, setApplicationData, setConstraintIndex, setConstraintLinkingEdge
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.tinfour.common.IConstraint
densify, getApplicationData, getConstraintIndex, getConstraintLinkingEdge, getManagingTin, isPointInsideConstraint, setApplicationData, setConstraintIndex, setConstraintLinkingEdge
-
Methods inherited from interface org.tinfour.common.IPolyline
add, getBounds, getLength, getVertices
-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
-
-
-
Constructor Detail
-
LinearConstraint
public LinearConstraint()
The standard constructor
-
LinearConstraint
public LinearConstraint(Vertex v0, Vertex v1)
A convience constructor intended for the frequently occurring case in which an application wishes to define a constraint as a single line segment.- Parameters:
v0- the initial vertex of the edgev1- the final vertex of the edge
-
-
Method Detail
-
complete
public final void complete()
Description copied from interface:IPolylineCalled to indicate that the feature is complete and that no further vertices will be added to it. Some implementing classes may perform lightweight sanity checking on the feature instance.Multiple calls to complete are benign and will be ignored. If vertices are added after complete is called, the behavior is undefined.
-
isPolygon
public boolean isPolygon()
Description copied from interface:IPolylineIndicates whether the instance represents a polygon. Some implementations may define a constant value for this method, others may determine it dynamically.
-
definesConstrainedRegion
public boolean definesConstrainedRegion()
Indicates whether the constraint defines a data area. Because linear constraints cannot define an area, this method always returns false.- Specified by:
definesConstrainedRegionin interfaceIConstraint- Returns:
- always false for linear constraints.
-
getNominalPointSpacing
public double getNominalPointSpacing()
Description copied from interface:IPolylineGet the average distance between points for the feature.- Specified by:
getNominalPointSpacingin interfaceIPolyline- Returns:
- if the feature contains more than one point, a floating point value greater than zero; otherwise a NaN.
-
getConstraintWithNewGeometry
public LinearConstraint getConstraintWithNewGeometry(List<Vertex> geometry)
Description copied from interface:IConstraintGets a new constraint that has the attributes of this constraint and the specified geometry. This method is primarily used in cases where a geometry is very similar (or identical) to the input but either simplified or with replacement vertices.- Specified by:
getConstraintWithNewGeometryin interfaceIConstraint- Parameters:
geometry- a valid set of vertices.- Returns:
- a new constraint.
-
refactor
public LinearConstraint refactor(Iterable<Vertex> geometry)
Description copied from interface:IPolylineCreates a new polyline feature with the specified geometry and transfers any data elements defined by the implementing class from the current object to the newly created one.This method is intended to be used in cases where application code performs some kind of transformation on the geometry of the existing object and produces a new object. In doing so, the application code treats the existing object on a read-only basis, but is free to transfer any implementation-specific data from the old object to the new. Examples of possible transformations include an implementation of a point-reduction technique such as Visvalingam's algorithm or point-addition techniques such as curve smoothing.
-
isValid
public boolean isValid()
Description copied from interface:IPolylineIndicates that sufficient information has been stored in the polyline to establish a valid geometry.
-
getPath2D
public Path2D getPath2D(AffineTransform transform)
Gets a Java Path2D based on the geometry of the constraint mapped through an optional affine transform.- Specified by:
getPath2Din interfaceIConstraint- Parameters:
transform- a valid transform, or the null to use the identity transform.- Returns:
- a valid instance of a Java Path2D
-
-