Class 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.

    • 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 edge
        v1 - the final vertex of the edge
      • LinearConstraint

        public LinearConstraint​(List<Vertex> vList)
        Constructs a constraint with the specified vertices. This approach is generally faster than adding the vertices one at a time.
        Parameters:
        vList - a valid list containing at least 2 distinct points.
    • Method Detail

      • complete

        public final void complete()
        Description copied from interface: IPolyline
        Called 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.

        Specified by:
        complete in interface IPolyline
      • isPolygon

        public boolean isPolygon()
        Description copied from interface: IPolyline
        Indicates whether the instance represents a polygon. Some implementations may define a constant value for this method, others may determine it dynamically.
        Specified by:
        isPolygon in interface IPolyline
        Returns:
        true if the instance is a polygon; otherwise, false.
      • 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:
        definesConstrainedRegion in interface IConstraint
        Returns:
        always false for linear constraints.
      • getNominalPointSpacing

        public double getNominalPointSpacing()
        Description copied from interface: IPolyline
        Get the average distance between points for the feature.
        Specified by:
        getNominalPointSpacing in interface IPolyline
        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: IConstraint
        Gets 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:
        getConstraintWithNewGeometry in interface IConstraint
        Parameters:
        geometry - a valid set of vertices.
        Returns:
        a new constraint.
      • refactor

        public LinearConstraint refactor​(Iterable<Vertex> geometry)
        Description copied from interface: IPolyline
        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.

        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.

        Specified by:
        refactor in interface IPolyline
        Parameters:
        geometry - a list or other iterable instance that can be used as a source of vertices.
        Returns:
        if successful, a new instance of the implementing class.
      • isValid

        public boolean isValid()
        Description copied from interface: IPolyline
        Indicates that sufficient information has been stored in the polyline to establish a valid geometry.
        Specified by:
        isValid in interface IPolyline
        Returns:
        true if the polyline has a valid geometry; otherwise, false.
      • 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:
        getPath2D in interface IConstraint
        Parameters:
        transform - a valid transform, or the null to use the identity transform.
        Returns:
        a valid instance of a Java Path2D