Class PartCollection

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

    public final class PartCollection
    extends java.util.AbstractList<Part>
    Represents a mutable collection of parts for creating a Multipart geometry from a MultipartBuilder. Parts can be added to, inserted into, and removed from PartCollections in order to define or change the complete shape of a Multipart (for example a Polygon or Polyline).

    The SpatialReference of any Parts added to a PartCollection must match that of the PartCollection, or be null (in which case the geometries in that Part are assumed to have the same SpatialReference as the PartCollection).

    Since:
    100.0.0
    See Also:
    PolylineBuilder, PolygonBuilder, Polyline, Polygon
    • Field Summary

      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      PartCollection​(ImmutablePart part)
      Creates a new PartCollection with one Part, and copies the geometries from the given ImmutablePart into the Part.
      PartCollection​(ImmutablePartCollection parts)
      Creates a new PartCollection and copies the ImmutableParts in the given ImmutablePartCollection into new Parts in the new PartCollection.
      PartCollection​(ImmutablePartCollection parts, SpatialReference spatialReference)
      Creates a new PartCollection with the given SpatialReference, and copies the ImmutableParts in the given ImmutablePartCollection into new Parts in the new PartCollection.
      PartCollection​(ImmutablePart part, SpatialReference spatialReference)
      Creates a new PartCollection with one Part and with the given SpatialReference, and copies the geometries from the given ImmutablePart into the Part.
      PartCollection​(ImmutablePointCollection partAsPoints)
      Creates a new PartCollection with one Part, and copies the geometries from the given ImmutablePointCollection into the Part.
      PartCollection​(ImmutablePointCollection partAsPoints, SpatialReference spatialReference)
      Creates a new PartCollection with one Part and the given SpatialReference, and copies the geometries from the given ImmutablePointCollection into the Part.
      PartCollection​(Part part)
      Creates a new PartCollection and adds the given Part to the collection.
      PartCollection​(PartCollection parts)
      Creates a new PartCollection containing the Parts in the given PartCollection.
      PartCollection​(PartCollection parts, SpatialReference spatialReference)
      Creates a new PartCollection with the given SpatialReference, containing the Parts in the given PartCollection.
      PartCollection​(Part part, SpatialReference spatialReference)
      Creates a new PartCollection with the given SpatialReference, and adds the given Part to the collection.
      PartCollection​(PointCollection partAsPoints)
      Creates a new PartCollection with one Part, and copies the Points from the given PointCollection into the Part.
      PartCollection​(PointCollection partAsPoints, SpatialReference spatialReference)
      Creates a new PartCollection with one Part and with the given SpatialReference, and copies the Points from the given PointCollection into the Part.
      PartCollection​(SpatialReference spatialReference)
      Creates a new empty PartCollection with the given SpatialReference.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int index, Part part)
      Inserts the given Part at the given index position in this PartCollection.
      void add​(int index, PointCollection pointCollection)
      Inserts a new Part at the given index position in this PartCollection, and copies each Point from the given PointCollection into the added Part.
      boolean add​(Part part)
      Appends the given Part to the end of this PartCollection.
      boolean add​(PointCollection pointCollection)
      Appends a new Part to the end of the PartCollection, and copies each Point from the given PointCollection into the added Part.
      void clear()
      Removes all Parts from the PartCollection.
      Part get​(int index)
      Gets the Part at the given index position in this PartCollection.
      java.lang.Iterable<Point> getPartsAsPoints()
      Returns a copy of an iterable containing all the Points in all of the parts of this PartCollection, ordered continuously from the first to last part in this collection.
      SpatialReference getSpatialReference()
      Gets the SpatialReference of the geometries in this PartCollection.
      int indexOf​(java.lang.Object o)  
      boolean isEmpty()  
      Part remove​(int index)
      Removes the Part at the specified index position from this PartCollection.
      Part set​(int index, Part part)
      Replaces the Part at the given index position with the given Part.
      int size()
      Returns the number of Parts in this PartCollection.
      • Methods inherited from class java.util.AbstractList

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

        addAll, contains, 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, contains, containsAll, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
    • Constructor Detail

      • PartCollection

        public PartCollection​(SpatialReference spatialReference)
        Creates a new empty PartCollection with the given SpatialReference. SpatialReference cannot be changed after instantiation.

        Parts can be instantiated directly, or by using the MultipartBuilder.addPart() method or one of its overloads.

        Parameters:
        spatialReference - the SpatialReference of the new PartCollection. May be null.
        Since:
        100.0.0
      • PartCollection

        public PartCollection​(Part part)
        Creates a new PartCollection and adds the given Part to the collection. The SpatialReference of the new PartCollection will match that of the given Part, and cannot be changed after instantiation.
        Parameters:
        part - the Part to add to the new PartCollection
        Throws:
        java.lang.NullPointerException - if part is null
        Since:
        100.0.0
      • PartCollection

        public PartCollection​(Part part,
                              SpatialReference spatialReference)
        Creates a new PartCollection with the given SpatialReference, and adds the given Part to the collection. The SpatialReference cannot be changed after instantiation.

        This overload can be used to create a PartCollection with a specific SpatialReference from a Part that has a null SpatialReference (the points are assigned the given SpatialReference-they are not projected).

        Parameters:
        part - the part to add to the new PartCollection
        spatialReference - the SpatialReference of the new PartCollection. May be null.
        Throws:
        ArcGISRuntimeException - if the SpatialReference of part does not match the match the spatialReference argument.
        java.lang.NullPointerException - if part is null
        Since:
        100.0.0
      • PartCollection

        public PartCollection​(ImmutablePart part)
        Creates a new PartCollection with one Part, and copies the geometries from the given ImmutablePart into the Part. The SpatialReference of the new PartCollection will match that of the given ImmutablePart, and cannot be changed after instantiation.
        Parameters:
        part - the ImmutablePart used to populate the Part in the new PartCollection
        Since:
        100.0.0
      • PartCollection

        public PartCollection​(ImmutablePart part,
                              SpatialReference spatialReference)
        Creates a new PartCollection with one Part and with the given SpatialReference, and copies the geometries from the given ImmutablePart into the Part. The SpatialReference cannot be changed after instantiation.

        This overload can be used to create a PartCollection with a specific SpatialReference by using an ImmutablePart from an existing Multipart geometry that has a null SpatialReference, in which case the input geometries are simply assigned the given SpatialReference.

        Parameters:
        part - the ImmutablePart used to populate the Part in the new PartCollection
        spatialReference - the SpatialReference of the new PartCollection. May be null.
        Since:
        100.0.0
      • PartCollection

        public PartCollection​(PointCollection partAsPoints)
        Creates a new PartCollection with one Part, and copies the Points from the given PointCollection into the Part. The SpatialReference of the new PartCollection will match that of the given PointCollection, and cannot be changed after instantiation.
        Parameters:
        partAsPoints - the PointCollection used to populate the Part in the new PartCollection
        Since:
        100.0.0
      • PartCollection

        public PartCollection​(PointCollection partAsPoints,
                              SpatialReference spatialReference)
        Creates a new PartCollection with one Part and with the given SpatialReference, and copies the Points from the given PointCollection into the Part. The SpatialReference of the new PartCollection cannot be changed after instantiation.

        This overload can be used to create a PartCollection with a specific SpatialReference from a PointCollection that has a null SpatialReference, in which case the input geometries are simply assigned the given SpatialReference.

        Parameters:
        partAsPoints - the PointCollection used to populate the Part in the new PartCollection
        spatialReference - the SpatialReference of the new PartCollection. May be null.
        Since:
        100.0.0
      • PartCollection

        public PartCollection​(ImmutablePointCollection partAsPoints)
        Creates a new PartCollection with one Part, and copies the geometries from the given ImmutablePointCollection into the Part. The SpatialReference of the new PartCollection will match that of the given ImmutablePointCollection, and cannot be changed after instantiation.
        Parameters:
        partAsPoints - the ImmutablePointCollection used to populate the Part in the new PartCollection
        Since:
        100.0.0
      • PartCollection

        public PartCollection​(ImmutablePointCollection partAsPoints,
                              SpatialReference spatialReference)
        Creates a new PartCollection with one Part and the given SpatialReference, and copies the geometries from the given ImmutablePointCollection into the Part. The SpatialReference of the new PartCollection cannot be changed after instantiation.

        This overload can be used to create a PartCollection with a specific SpatialReference from an ImmutablePointCollection that has a null SpatialReference, in which case the input geometries are simply assigned the given SpatialReference.

        Parameters:
        partAsPoints - the ImmutablePointCollection used to populate the Part in the new PartCollection
        spatialReference - the SpatialReference of the new PartCollection. May be null.
        Since:
        100.0.0
      • PartCollection

        public PartCollection​(PartCollection parts)
        Creates a new PartCollection containing the Parts in the given PartCollection. The SpatialReference of the new PartCollection will match that of the given PartCollection, and cannot be changed after instantiation.
        Parameters:
        parts - the collection of Parts to add to the new PartCollection
        Throws:
        java.lang.NullPointerException - if parts is null
        Since:
        100.0.0
      • PartCollection

        public PartCollection​(PartCollection parts,
                              SpatialReference spatialReference)
        Creates a new PartCollection with the given SpatialReference, containing the Parts in the given PartCollection. This overload can be used to create a PartCollection with a specific SpatialReference from a PartCollection that has a null SpatialReference, in which case the input geometries are simply assigned the given SpatialReference.
        Parameters:
        parts - the collection of Parts to add to the new PartCollection
        spatialReference - the SpatialReference of the new PartCollection. May be null.
        Throws:
        java.lang.NullPointerException - if parts is null
        Since:
        100.0.0
      • PartCollection

        public PartCollection​(ImmutablePartCollection parts)
        Creates a new PartCollection and copies the ImmutableParts in the given ImmutablePartCollection into new Parts in the new PartCollection. The SpatialReference of the new PartCollection will match that of the given ImmutablePartCollection, and cannot be changed after instantiation.
        Parameters:
        parts - the collection of ImmutableParts used to populate new Parts in the new PartCollection
        Since:
        100.0.0
      • PartCollection

        public PartCollection​(ImmutablePartCollection parts,
                              SpatialReference spatialReference)
        Creates a new PartCollection with the given SpatialReference, and copies the ImmutableParts in the given ImmutablePartCollection into new Parts in the new PartCollection.

        This overload can be used to create a PartCollection with a specific SpatialReference from an ImmutablePartCollection that has a null SpatialReference, in which case the input geometries are simply assigned the given SpatialReference.

        Parameters:
        parts - the collection of ImmutableParts used to populate new Parts in the new PartCollection
        spatialReference - the SpatialReference of the new PartCollection. May be null.
        Since:
        100.0.0
    • Method Detail

      • getSpatialReference

        public SpatialReference getSpatialReference()
        Gets the SpatialReference of the geometries in this PartCollection. The SpatialReference defines how coordinates correspond to locations in the real world. This is set during instantiation and cannot be changed. May be null.
        Returns:
        the SpatialReference of the geometries in this PartCollection
        Since:
        100.0.0
      • get

        public Part get​(int index)
        Gets the Part at the given index position in this PartCollection. Use this to access the individual parts that compose a MultipartBuilders current state. The part is returned by reference, therefore changes made to the part affect the builder.
        Specified by:
        get in interface java.util.List<Part>
        Specified by:
        get in class java.util.AbstractList<Part>
        Parameters:
        index - the index of the Part to return
        Returns:
        the Part at the given index
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= size()
        Since:
        100.0.0
      • getPartsAsPoints

        public java.lang.Iterable<Point> getPartsAsPoints()
        Returns a copy of an iterable containing all the Points in all of the parts of this PartCollection, ordered continuously from the first to last part in this collection. If the PartCollection isEmpty(), this method returns an empty iterable.

        The points represent the ends of the Segments in all of the Parts in this collection (all the vertices in the shape currently under construction in the MultipartBuilder). Where two adjacent segments share a start and end location (there is no gap between the segments), this is represented by a single Point.

        Returns:
        an iterable set of all the Points in all the parts of this PartCollection
        Since:
        100.0.0
        See Also:
        Part.getPoints()
      • size

        public int size()
        Returns the number of Parts in this PartCollection. Use this to find the maximum index for calling get(int).
        Specified by:
        size in interface java.util.Collection<Part>
        Specified by:
        size in interface java.util.List<Part>
        Specified by:
        size in class java.util.AbstractCollection<Part>
        Since:
        100.0.0
        See Also:
        get(int)
      • isEmpty

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

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

        public Part set​(int index,
                        Part part)
        Replaces the Part at the given index position with the given Part. The Part is set by reference-changes made to the added Part are reflected immediately in the PartCollection.

        Use this method to change a Part of a PartCollection-for example, to replace one ring in a Polygon with a different existing ring.

        Specified by:
        set in interface java.util.List<Part>
        Overrides:
        set in class java.util.AbstractList<Part>
        Parameters:
        index - the index of the Part to replace
        part - the Part to set into the PartCollection
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= size()
        java.lang.NullPointerException - if part is null
        ArcGISRuntimeException - if the part has a SpatialReference that does not match that of this PartCollection. The SpatialReference of the part may however be null.
        Since:
        100.0.0
        See Also:
        add(int, Part)
      • add

        public boolean add​(Part part)
        Appends the given Part to the end of this PartCollection. The Part is added by reference-changes made to the added Part are reflected immediately in the PartCollection.

        Alternatively, use the addPart convenience methods directly on MultipartBuilder.

        Specified by:
        add in interface java.util.Collection<Part>
        Specified by:
        add in interface java.util.List<Part>
        Overrides:
        add in class java.util.AbstractList<Part>
        Parameters:
        part - the Part to add to the PartCollection
        Returns:
        always true
        Throws:
        java.lang.NullPointerException - if part is null
        ArcGISRuntimeException - if the part has a SpatialReference that does not match that of this PartCollection. The SpatialReference of part may however be null.
        Since:
        100.0.0
        See Also:
        add(int, Part), MultipartBuilder.addPart(Part)
      • add

        public void add​(int index,
                        Part part)
        Inserts the given Part at the given index position in this PartCollection. The index positions of all existing Parts at that index or greater increase by one.

        The Part is added by reference-changes made to the inserted Part are reflected immediately in the PartCollection.

        Specified by:
        add in interface java.util.List<Part>
        Overrides:
        add in class java.util.AbstractList<Part>
        Parameters:
        index - the index position at which to add the Part
        part - the Part to insert into the PartCollection
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index > size()
        java.lang.NullPointerException - if part is null
        See Also:
        MultipartBuilder.addPart(Part)
      • add

        public boolean add​(PointCollection pointCollection)
        Appends a new Part to the end of the PartCollection, and copies each Point from the given PointCollection into the added Part.

        Alternatively, use the MultipartBuilder.addPart(PointCollection) convenience method directly on MultipartBuilder.

        Parameters:
        pointCollection - the collection of points to copy to the new Part in the PartCollection
        Returns:
        true, if successful
        Throws:
        java.lang.NullPointerException - if pointCollection is null
        Since:
        100.0.0
        See Also:
        MultipartBuilder.addPart(PointCollection)
      • add

        public void add​(int index,
                        PointCollection pointCollection)
        Inserts a new Part at the given index position in this PartCollection, and copies each Point from the given PointCollection into the added Part. The index positions of all existing Parts at that index or greater increase by one.
        Parameters:
        index - the index position at which to insert the new Part
        pointCollection - the collection of points to copy to the new Part in the PartCollection
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index > size()
        java.lang.NullPointerException - if pointCollection is null
        Since:
        100.0.0
      • remove

        public Part remove​(int index)
        Removes the Part at the specified index position from this PartCollection.

        Note if calling this method on a PartCollection from a Polygon, removing a part from a PolygonBuilder can affect which parts represent outer rings and which represent inner rings.

        Specified by:
        remove in interface java.util.List<Part>
        Overrides:
        remove in class java.util.AbstractList<Part>
        Parameters:
        index - the index of the Part to remove
        Returns:
        the removed Part
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= size()
        Since:
        100.0.0
        See Also:
        size(), clear()
      • clear

        public void clear()
        Removes all Parts from the PartCollection. Using this method is more efficient than removing all Parts individually. The state of the removed Parts is not affected.
        Specified by:
        clear in interface java.util.Collection<Part>
        Specified by:
        clear in interface java.util.List<Part>
        Overrides:
        clear in class java.util.AbstractList<Part>
        Since:
        100.0.0