Class Polygon

  • All Implemented Interfaces:
    JsonSerializable

    public final class Polygon
    extends Multipart
    Represents an areal shape defined by a collection of parts, and a SpatialReference. Each Part defines an area bounded by a collection of Segments. If there is more than one part, each part may lie inside or be disjoint from other parts. Point-based helper methods allow the polygon to be treated as a series of connected Points.

    Polygon is immutable. Instead of changing the properties of an existing Polygon, create new Polygon instances, or use PolygonBuilder.

    A Polygon can be used as the geometry of a Feature or Graphic.

    Since:
    100.0.0
    See Also:
    PolygonBuilder
    • Constructor Detail

      • Polygon

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

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

        This overload can be used to create a new Polygon 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 Polygon
        spatialReference - the SpatialReference of the new Polygon
        Throws:
        ArcGISRuntimeException - if the SpatialReference of points does not match the spatialReference
        Since:
        100.0.0
      • Polygon

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

        public Polygon​(Part part,
                       SpatialReference spatialReference)
        Creates a new Polygon containing a copy of the given Part, and with the given SpatialReference.
        Parameters:
        part - the Part to copy to the new Polygon
        spatialReference - the SpatialReference of the new Polygon
        Throws:
        ArcGISRuntimeException - if the SpatialReference of part does not match the spatialReference
        Since:
        100.0.0
      • Polygon

        public Polygon​(PartCollection parts)
        Creates a new immutable Polygon containing a copy of the given PartCollection. The SpatialReference of the new Polygon will match that of the given PartCollection.
        Parameters:
        parts - the PartCollection used to initialize the new Polygon
        Since:
        100.0.0
      • Polygon

        public Polygon​(PartCollection parts,
                       SpatialReference spatialReference)
        Creates a new Polygon containing a copy of the given PartCollection, and with the given SpatialReference.
        Parameters:
        parts - the PartCollection to be copied to the new Polygon
        spatialReference - the SpatialReference of the new Polygon
        Throws:
        ArcGISRuntimeException - if the SpatialReference of part does not match spatialReference
        Since:
        100.0.0
    • Method Detail

      • toPolyline

        public Polyline toPolyline()
        Returns a new Polyline representing the boundary of this Polygon.
        Returns:
        a new Polyline
        Since:
        100.0.0