Class PolylineBuilder


public final class PolylineBuilder extends MultipartBuilder
Helper class for building immutable Polyline geometries.

Use the constructors to initialize the builder with a SpatialReference-once set, the SpatialReference cannot be changed. The initial shape stored in the builder can also be initialized in the constructors, by passing in existing geometries or collections. Change the contents of the shape by using the mutable PartCollection accessible from MultipartBuilder.getParts(). Call the toGeometry() method to create a new immutable Polyline from the current state of this builder.

  • Constructor Details

    • PolylineBuilder

      public PolylineBuilder(SpatialReference spatialReference)
      Creates a new empty PolylineBuilder with the given SpatialReference. SpatialReference cannot be changed after instantiation.
      Parameters:
      spatialReference - the SpatialReference of the new builder. May be null.
      Since:
      100.0.0
    • PolylineBuilder

      public PolylineBuilder(Polyline polyline)
      Creates a new Polyline by copying the parts from the given Polyline. The SpatialReference of the new builder will match that of the given Polyline. Use this constructor in workflows that create a modified version of an existing geometry, for example feature or graphic editing workflows.

      Prior to v100.12, only polygons without curves could be used; passing in a polygon where Geometry.hasCurves() is true would throw an exception.

      From v100.12, polygons with curves are supported.

      Parameters:
      polyline - the Polyline used to initialize this builder
      Since:
      100.0.0
      See Also:
    • PolylineBuilder

      public PolylineBuilder(PointCollection points)
      Creates a new PolylineBuilder containing a copy of the Points in the given PointCollection. The SpatialReference of the new builder will match that of the given PointCollection.
      Parameters:
      points - the PointCollection used to initialize the new builder
      Since:
      100.0.0
    • PolylineBuilder

      public PolylineBuilder(PointCollection points, SpatialReference spatialReference)
      Creates a new PolylineBuilder containing a copy of the Points in the given PointCollection, and with the given SpatialReference.

      This overload can be used to initialize a PolylineBuilder with a specific SpatialReference from an existing PointCollection that has a null SpatialReference (the points are assigned the given SpatialReference-they are not projected).

      Parameters:
      points - the PointCollection containing points copied to the new builder
      spatialReference - the SpatialReference of the new builder
      Throws:
      ArcGISRuntimeException - if the SpatialReference of points does not match the spatialReference argument.
      Since:
      100.0.0
    • PolylineBuilder

      public PolylineBuilder(Part part)
      Creates a new PolylineBuilder containing the given Part. The SpatialReference of the new builder will match that of the given Part.
      Parameters:
      part - the Part used to initialize the new builder
      Since:
      100.0.0
    • PolylineBuilder

      public PolylineBuilder(Part part, SpatialReference spatialReference)
      Creates a new PolylineBuilder containing the given Part, and with the given SpatialReference.
      Parameters:
      part - the Part to add to the new builder
      spatialReference - the SpatialReference of the new builder
      Since:
      100.0.0
    • PolylineBuilder

      public PolylineBuilder(PartCollection parts)
      Creates a new PolylineBuilder containing the Parts in the given PartCollection. The SpatialReference of the new builder will match that of the given PartCollection.
      Parameters:
      parts - the PartCollection containing Parts to add to the new builder
      Since:
      100.0.0
    • PolylineBuilder

      public PolylineBuilder(PartCollection parts, SpatialReference spatialReference)
      Creates a new PolylineBuilder containing the Parts in the given PartCollection, and with the given SpatialReference.
      Parameters:
      parts - the PartCollection containing Parts to add to the new builder
      spatialReference - the SpatialReference of the new builder
  • Method Details

    • toGeometry

      public Polyline toGeometry()
      Returns a new Polyline based on the current state of this builder. This method can be called as many times as required for any specific instance; it does not affect the state of the builder, and returns a new Polyline each time.

      Any gaps between the Segments in each part of the returned Polyline will be filled by new connecting LineSegments.

      Specified by:
      toGeometry in class GeometryBuilder
      Returns:
      a new Polyline based on the current state of this builder
      Since:
      100.0.0