Class PolygonBuilder
- java.lang.Object
-
- com.esri.arcgisruntime.geometry.GeometryBuilder
-
- com.esri.arcgisruntime.geometry.MultipartBuilder
-
- com.esri.arcgisruntime.geometry.PolygonBuilder
-
public final class PolygonBuilder extends MultipartBuilder
Helper class for building immutablePolygon
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 fromMultipartBuilder.getParts()
. Call thetoGeometry()
method to create a new immutable Polygon from the current state of this builder.
-
-
Constructor Summary
Constructors Constructor Description PolygonBuilder(Part part)
Creates a new PolygonBuilder containing the given Part.PolygonBuilder(PartCollection parts)
Creates a new PolygonBuilder containing the Parts in the given PartCollection.PolygonBuilder(PartCollection parts, SpatialReference spatialReference)
Creates a new PolygonBuilder containing the Parts in the given PartCollection, and with the given SpatialReference.PolygonBuilder(Part part, SpatialReference spatialReference)
Creates a new PolygonBuilder containing the given Part, and with the given SpatialReference.PolygonBuilder(PointCollection points)
Creates a new PolygonBuilder containing a copy of the Points in the given PointCollection.PolygonBuilder(PointCollection points, SpatialReference spatialReference)
Creates a new PolygonBuilder containing a copy of the Points in the given PointCollection, and with the given SpatialReference.PolygonBuilder(Polygon polygon)
Creates a new PolygonBuilder by copying the parts from the given Polygon.PolygonBuilder(SpatialReference spatialReference)
Creates a new empty PolygonBuilder with the given SpatialReference.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Polygon
toGeometry()
Returns a new Polygon based on the current state of this builder.Polyline
toPolyline()
Creates a polyline with the values in this builder.-
Methods inherited from class com.esri.arcgisruntime.geometry.MultipartBuilder
addPart, addPart, addPart, addParts, addPoint, addPoint, addPoint, addPoints, addPointsToPart, addPointToPart, getParts, replaceGeometry
-
Methods inherited from class com.esri.arcgisruntime.geometry.GeometryBuilder
create, create, getBuilderType, getExtent, getSpatialReference, hasCurves, hasM, hasZ, isEmpty, isSketchValid
-
-
-
-
Constructor Detail
-
PolygonBuilder
public PolygonBuilder(SpatialReference spatialReference)
Creates a new empty PolygonBuilder 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
-
PolygonBuilder
public PolygonBuilder(Polygon polygon)
Creates a new PolygonBuilder by copying the parts from the given Polygon. The SpatialReference of the new builder will match that of the given Polygon. 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:
polygon
- the Polygon used to initialize the new builder- Since:
- 100.0.0
- See Also:
GeometryBuilder.hasCurves()
-
PolygonBuilder
public PolygonBuilder(PointCollection points)
Creates a new PolygonBuilder 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 initialise the new builder- Since:
- 100.0.0
-
PolygonBuilder
public PolygonBuilder(PointCollection points, SpatialReference spatialReference)
Creates a new PolygonBuilder containing a copy of the Points in the given PointCollection, and with the given SpatialReference.This overload can be used to initialize a PolygonBuilder 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 builderspatialReference
- the SpatialReference of the new builder- Throws:
ArcGISRuntimeException
- if the SpatialReference ofpoints
does not match the match thespatialReference
argument.- Since:
- 100.0.0
-
PolygonBuilder
public PolygonBuilder(Part part)
Creates a new PolygonBuilder containing the given Part. The SpatialReference of the new builder will match that of the given Part.- Parameters:
part
- the Part used to initialise the new builder- Since:
- 100.0.0
-
PolygonBuilder
public PolygonBuilder(Part part, SpatialReference spatialReference)
Creates a new PolygonBuilder containing the given Part, and with the given SpatialReference.- Parameters:
part
- the Part to add to the new builderspatialReference
- the SpatialReference of the new builder- Since:
- 100.0.0
-
PolygonBuilder
public PolygonBuilder(PartCollection parts)
Creates a new PolygonBuilder 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
-
PolygonBuilder
public PolygonBuilder(PartCollection parts, SpatialReference spatialReference)
Creates a new PolygonBuilder containing the Parts in the given PartCollection, and with the given SpatialReference.- Parameters:
parts
- the PartCollection containing Parts to add to the new builderspatialReference
- the SpatialReference of the new builder- Since:
- 100.0.0
-
-
Method Detail
-
toGeometry
public Polygon toGeometry()
Returns a new Polygon 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 Polygon each time.Any gaps between the Segments in each part of the returned Polygon will be filled by new connecting LineSegments.
- Specified by:
toGeometry
in classGeometryBuilder
- Returns:
- a new Polygon based on the current state of this builder
- Since:
- 100.0.0
-
toPolyline
public Polyline toPolyline()
Creates a polyline with the values in this builder.- Returns:
- a polyline with the values in this builder
- Since:
- 100.1.0
-
-