Class ImmutablePart

  • All Implemented Interfaces:
    java.lang.Iterable<Segment>, java.util.Collection<Segment>, java.util.List<Segment>

    public final class ImmutablePart
    extends java.util.AbstractList<Segment>
    Represents an immutable collection of Segments that define the shape of a part of an immutable Multipart geometry - Polygon or Polyline. Point-based helper methods also allow working with the part as a series of Points.

    Use Multipart.getParts() to return an ImmutablePartCollection, which can then be used to iterate through the Segments and Points in each ImmutablePart. Use java.util.AbstractList.iterator() or getPoints() to return an iterator, or use get(int) or getPoint(int) to access each specific Segment or Point.

    Because geometries themselves are immutable, the collections they are composed of are also immutable. For geometry editing or creation workflows, a mutable Part is used instead. Part has constructors that take an ImmutablePart (among other options), allowing the creation of new geometry parts from existing parts.

    For more information about using geometries, see the 'Fundamentals' > 'Geometries' topic in the Guide.

    Prior to v100.12, the only supported segment type was LineSegment. If the underlying geometry contained curve segments (Geometry.hasCurves() is true), then the curve information was lost when iterating through the segments in that part.

    From v100.12, curve segments may be returned from get(int). A part may contain a mix of linear and curve segments.

    Since:
    100.0.0
    See Also:
    Polyline, Polygon, Multipart.getParts(), Part
    • Field Summary

      • Fields inherited from class java.util.AbstractList

        modCount
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(java.lang.Object o)  
      Segment get​(int index)
      Gets the Segment at the given index position in this ImmutablePart.
      Point getEndPoint()
      Gets a Point representing the end of the last Segment of the ImmutablePart.
      int getEndPointIndexFromSegmentIndex​(int segmentIndex)
      Gets the index of the end point of a segment.
      Point getPoint​(int index)
      Gets the Point at the given index in the ImmutablePart.
      int getPointCount()
      Returns the number of Points in the ImmutablePart, representing the number of vertices in the shape.
      java.lang.Iterable<Point> getPoints()
      Gets an iterator of Points representing the ends of the Segments in this ImmutablePart (the vertices in the shape).
      int getSegmentIndexFromEndPointIndex​(int endPointIndex)
      Gets the index of the segment that has a given end point.
      int getSegmentIndexFromStartPointIndex​(int startPointIndex)
      Gets the index of the segment that has a given start point.
      SpatialReference getSpatialReference()
      Gets the SpatialReference of the geometries in this ImmutablePart.
      Point getStartPoint()
      Gets a Point representing the start of the first Segment of the ImmutablePart.
      int getStartPointIndexFromSegmentIndex​(int segmentIndex)
      Gets the index of the start point of a segment.
      boolean hasCurves()
      Indicates if this ImmutablePart contains Segments that represent true curves.
      int indexOf​(java.lang.Object o)  
      boolean isEmpty()  
      int size()
      Returns the number of Segments in this ImmutablePart.
      • Methods inherited from class java.util.AbstractList

        add, add, addAll, clear, equals, hashCode, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
      • Methods inherited from class java.util.AbstractCollection

        addAll, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        addAll, containsAll, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
    • Method Detail

      • getSpatialReference

        public SpatialReference getSpatialReference()
        Gets the SpatialReference of the geometries in this ImmutablePart. The SpatialReference defines how coordinates correspond to locations in the real world. May be null.
        Returns:
        the SpatialReference of the geometries in this ImmutablePart
        Since:
        100.0.0
      • get

        public Segment get​(int index)
        Gets the Segment at the given index position in this ImmutablePart.

        To work with the Part as a series of Points, use getPoint(int) and getPointCount() instead.

        Specified by:
        get in interface java.util.List<Segment>
        Specified by:
        get in class java.util.AbstractList<Segment>
        Parameters:
        index - the index of the Segment to return
        Returns:
        the Segment at the given index
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= size()
        Since:
        100.0.0
      • indexOf

        public int indexOf​(java.lang.Object o)
        Specified by:
        indexOf in interface java.util.List<Segment>
        Overrides:
        indexOf in class java.util.AbstractList<Segment>
      • size

        public int size()
        Returns the number of Segments in this ImmutablePart. Use this to find the maximum index for calling get(int).

        An ImmutablePart can also be represented by a set of Points representing each vertex; the getPointCount method returns the number of Points in the ImmutablePart. See getPointCount() for an explanation of how the two relate.

        Specified by:
        size in interface java.util.Collection<Segment>
        Specified by:
        size in interface java.util.List<Segment>
        Specified by:
        size in class java.util.AbstractCollection<Segment>
        Since:
        100.0.0
        See Also:
        getPointCount(), get(int)
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<Segment>
        Specified by:
        isEmpty in interface java.util.List<Segment>
        Overrides:
        isEmpty in class java.util.AbstractCollection<Segment>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<Segment>
        Specified by:
        contains in interface java.util.List<Segment>
        Overrides:
        contains in class java.util.AbstractCollection<Segment>
      • getStartPoint

        public Point getStartPoint()
        Gets a Point representing the start of the first Segment of the ImmutablePart. This is a shortcut to getting the first Segment in the ImmutablePart, then getting its start point using Segment.getStartPoint(), or getting the first Point using getPoint(int).
        Returns:
        a Point representing the start point
        Since:
        100.0.0
        See Also:
        getEndPoint()
      • getEndPoint

        public Point getEndPoint()
        Gets a Point representing the end of the last Segment of the ImmutablePart. This is a shortcut to getting the last Segment in the ImmutablePart, then getting its end point using Segment.getEndPoint(), or getting the last Point using getPoint(int).
        Returns:
        a Point representing the end point
        See Also:
        getStartPoint()
      • getPoints

        public java.lang.Iterable<Point> getPoints()
        Gets an iterator of Points representing the ends of the Segments in this ImmutablePart (the vertices in the shape).

        In ImmutableParts, adjacent segments always share a start and end location (there is no gap between the segments), and this is represented by a single Point in this iterator.

        Returns:
        an iterator of Points
        Since:
        100.0.0
      • getPoint

        public Point getPoint​(int index)
        Gets the Point at the given index in the ImmutablePart. Use getPointCount() to determine the maximum possible index.

        The vertices of a Multipart geometry can be represented as a series of Points, which can be accessed using this method, or by the getPoints() iterator. If the geometry contains curves, this cannot be represented by points; segment-based methods such as get(int) and java.util.AbstractList.iterator() may be more appropriate instead.

        Parameters:
        index - the index of the Point to get
        Returns:
        the Point at the given index
        Throws:
        java.lang.IndexOutOfBoundsException - if index is out of range (index < 0 || index >= getPointCount())
        Since:
        100.0.0
      • getPointCount

        public int getPointCount()
        Returns the number of Points in the ImmutablePart, representing the number of vertices in the shape. Use this to find the maximum index for calling getPoint(int).

        For Polylines, this number is one greater than the number of Segments in this ImmutablePart (size()), but for Polygons it equals the number of Segments.

        Where two adjacent segments share a start and end location (there is no gap between the segments), this is represented by a single Point. Gaps are eliminated when geometries are built using the GeometryBuilder.toGeometry() method. Completed Multipart geometries do not have gaps between the segments of a part, but separate ImmutableParts may be disjoint.

        Returns:
        the number of Points in the ImmutablePart
        Since:
        100.0.0
        See Also:
        size(), getPoints()
      • hasCurves

        public boolean hasCurves()
        Indicates if this ImmutablePart contains Segments that represent true curves.

        The ArcGIS system supports polygon and polyline geometries that contain curved segments in some types of data, for example geodatabases, feature services, and JSON. At the current release this SDK can display curved geometries, but you cannot work with curves using the API; any curved segments in a geometry will be represented as LineSegments, and the curve information will be lost. In editing workflows, use this method to determine if this ImmutablePart contains curve information which would be lost if used in an editing workflow.

        Prior to v100.12, if this property returned true, there was no way to access the curve segment information contained by the part. Retrieving the Segment instances of the part would return only LineSegment instances.

        From v100.12, when this property returns true, curve segments may be returned from get(int). A part may contain a mix of linear and curve segments.

        Returns:
        true if this ImmutablePart contains curved segments; false otherwise
        Since:
        100.0.0
      • getSegmentIndexFromStartPointIndex

        public int getSegmentIndexFromStartPointIndex​(int startPointIndex)
        Gets the index of the segment that has a given start point.
        Parameters:
        startPointIndex - the 0-based index of the start point
        Returns:
        the index of the segment, or -1 if startPointIndex does not correspond to a segment start point
        Throws:
        java.lang.IndexOutOfBoundsException - if startPointIndex is out of bounds
        Since:
        100.1.0
      • getSegmentIndexFromEndPointIndex

        public int getSegmentIndexFromEndPointIndex​(int endPointIndex)
        Gets the index of the segment that has a given end point.
        Parameters:
        endPointIndex - the 0-based index of the end point
        Returns:
        the index of the segment, or -1 if endPointIndex does not correspond to a segment end point
        Throws:
        java.lang.IndexOutOfBoundsException - if endPointIndex is out of bounds
        Since:
        100.1.0
      • getStartPointIndexFromSegmentIndex

        public int getStartPointIndexFromSegmentIndex​(int segmentIndex)
        Gets the index of the start point of a segment.
        Parameters:
        segmentIndex - the 0-based index of the segment
        Returns:
        the index of the start point
        Throws:
        java.lang.IndexOutOfBoundsException - if segmentIndex is out of bounds
        Since:
        100.1.0
      • getEndPointIndexFromSegmentIndex

        public int getEndPointIndexFromSegmentIndex​(int segmentIndex)
        Gets the index of the end point of a segment.
        Parameters:
        segmentIndex - the 0-based index of the segment
        Returns:
        the index of the end point
        Throws:
        java.lang.IndexOutOfBoundsException - if segmentIndex is out of bounds
        Since:
        100.1.0