Class PointCollection

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

    public final class PointCollection
    extends java.util.AbstractList<Point>
    Represents a mutable collection of Points for creating a Multipoint geometry from a MultipointBuilder. Points can be added to, inserted into, and removed from the collection in order to define or change the shape of the Multipoint. Also used in geometry constructors and builders.

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

    Since:
    100.0.0
    See Also:
    MultipointBuilder, Multipoint, ImmutablePointCollection
    • Field Summary

      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      PointCollection​(Part part)
      Creates a new PointCollection by copying the points from the given Part.
      PointCollection​(Part part, SpatialReference spatialReference)
      Creates a new PointCollection with the given SpatialReference by copying the points from the given Part (the points are assigned the given SpatialReference-they are not projected).
      PointCollection​(SpatialReference spatialReference)
      Creates a new empty PointCollection with the given SpatialReference.
      PointCollection​(java.lang.Iterable<Point> points)
      Creates a new PointCollection with the given iterable set of Points.
      PointCollection​(java.lang.Iterable<Point> points, SpatialReference spatialReference)
      Creates a new PointCollection with the given iterable set of Points and SpatialReference.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(double x, double y)
      Creates a new Point with the given x,y coordinates and appends it to the end of this PointCollection.
      boolean add​(double x, double y, double z)
      Creates a new Point with the given x,y coordinates and z value, and appends it to the end of this PointCollection.
      void add​(int index, double x, double y)
      Creates a new Point with the given x,y coordinates and inserts it at the given index of this PointCollection.
      void add​(int index, double x, double y, double z)
      Creates a new Point with the given x,y coordinates and z value, and inserts it at the given index of this PointCollection.
      void add​(int index, Point point)
      Inserts the given Point at the given index of this PointCollection.
      boolean add​(Point point)
      Appends the given Point to the end of this PointCollection.
      void clear()
      Removes all Points from the PointCollection.
      Point get​(int index)
      Gets a copy of the Point at the given index in the PointCollection.
      SpatialReference getSpatialReference()
      Gets the SpatialReference of the geometries in this PointCollection.
      int indexOf​(java.lang.Object object)
      boolean isEmpty()  
      Point remove​(int index)
      Removes the Point at the given index position from the PointCollection.
      Point set​(int index, double x, double y)
      Replaces the Point at the given index position with a new Point that has the given x,y coordinates.
      Point set​(int index, Point point)
      Replaces the Point at the given index position with the given Point.
      int size()
      Returns the number of Points in this PointCollection.
      • 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

      • PointCollection

        public PointCollection​(SpatialReference spatialReference)
        Creates a new empty PointCollection with the given SpatialReference. The SpatialReference defines how coordinates correspond to locations in the real world. This is set during instantiation and cannot be changed. May be null.
        Parameters:
        spatialReference - the SpatialReference of the Points in this collection
        Since:
        100.0.0
      • PointCollection

        public PointCollection​(java.lang.Iterable<Point> points)
        Creates a new PointCollection with the given iterable set of Points. The SpatialReference of the new PointCollection will match that of the given points.
        Parameters:
        points - the set of Points that this PointCollection will be initialised with. For example, this argument may be an existing PointCollection, ImmutablePointCollection, or standard generic Java ArrayList containing Points. If null, an empty PointCollection is created.
        Throws:
        ArcGISRuntimeException - if points contains Points that have differing SpatialReferences set.
        Since:
        100.0.0
      • PointCollection

        public PointCollection​(java.lang.Iterable<Point> points,
                               SpatialReference spatialReference)
        Creates a new PointCollection with the given iterable set of Points and SpatialReference.

        Use this constructor to create a new PointCollection with a specific SpatialReference from an existing set of points that have null SpatialReferences (the points are assigned the given SpatialReference-they are not projected). Can also be used where the SpatialReference of some points matches that of the argument, but is null for other points.

        Parameters:
        points - the set of Points that this PointCollection will be initialised with. For example, this argument may be an existing PointCollection, ImmutablePointCollection, or standard generic Java ArrayList containing Points. If null, an empty PointCollection is created.
        spatialReference - the SpatialReference of the new PointCollection. May be null.
        Throws:
        ArcGISRuntimeException - if the points argument contains Points with SpatialReferences that do not match the spatialReference argument.
        Since:
        100.0.0
      • PointCollection

        public PointCollection​(Part part)
        Creates a new PointCollection by copying the points from the given Part. The SpatialReference of the new PointCollection will match that of the given Part.
        Parameters:
        part - the Part containing Points that will be copied into this PointCollection. For example, this argument may be an existing PointCollection, ImmutablePointCollection, or standard generic Java ArrayList containing Points. If null, an empty PointCollection is created.
        Since:
        100.0.0
      • PointCollection

        public PointCollection​(Part part,
                               SpatialReference spatialReference)
        Creates a new PointCollection with the given SpatialReference by copying the points from the given Part (the points are assigned the given SpatialReference-they are not projected).
        Parameters:
        part - the Part containing Points that will be copied into this PointCollection. For example, this argument may be an existing PointCollection, ImmutablePointCollection, or standard generic Java ArrayList containing Points. If null, an empty PointCollection is created.
        spatialReference - the SpatialReference of the new PointCollection. May be null.
        Throws:
        ArcGISRuntimeException - if the part argument has a SpatialReference that does not match the spatialReference argument.
        Since:
        100.0.0
    • Method Detail

      • getSpatialReference

        public SpatialReference getSpatialReference()
        Gets the SpatialReference of the geometries in this PointCollection. 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 PointCollection
        Since:
        100.0.0
      • get

        public Point get​(int index)
        Gets a copy of the Point at the given index in the PointCollection. Use size() to determine the maximum possible index.

        Use the set(int, Point) method or its overloads to replace an existing Point with a different Point.

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

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

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

        public Point set​(int index,
                         Point point)
        Replaces the Point at the given index position with the given Point.

        Use this method to replace a Point in the collection with a different instance - as Points are immutable, properties of existing Points cannot be changed.

        Specified by:
        set in interface java.util.List<Point>
        Overrides:
        set in class java.util.AbstractList<Point>
        Parameters:
        index - the index of the Point to replace
        point - the Point to set at the given index
        Returns:
        the Point that was replaced
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= size()
        java.lang.NullPointerException - if point is null
        ArcGISRuntimeException - if the point has a SpatialReference that does not match that of this PointCollection. The SpatialReference of the point may however be null.
        Since:
        100.0.0
        See Also:
        set(int, double, double)
      • set

        public Point set​(int index,
                         double x,
                         double y)
        Replaces the Point at the given index position with a new Point that has the given x,y coordinates.

        Use this method to replace a Point in the collection with a different instance - as Points are immutable, properties of existing Points cannot be changed. The x and y parameters should be defined in the SpatialReference of this PointCollection.

        Parameters:
        index - the index of the Point to replace
        x - the x coordinate of the new Point
        y - the y coordinate of the new Point
        Returns:
        the Point that was replaced
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= size()
        Since:
        100.0.0
      • add

        public boolean add​(Point point)
        Appends the given Point to the end of this PointCollection.
        Specified by:
        add in interface java.util.Collection<Point>
        Specified by:
        add in interface java.util.List<Point>
        Overrides:
        add in class java.util.AbstractList<Point>
        Parameters:
        point - the Point to append to this PointCollection
        Returns:
        always true
        Throws:
        java.lang.NullPointerException - if point is null
        ArcGISRuntimeException - if the point has a SpatialReference that does not match that of this PointCollection. The SpatialReference of the point may however be null.
        Since:
        100.0.0
      • add

        public boolean add​(double x,
                           double y)
        Creates a new Point with the given x,y coordinates and appends it to the end of this PointCollection.
        Parameters:
        x - the x coordinate of the new Point appended to this PointCollection
        y - the y coordinate of the new Point appended to this PointCollection
        Returns:
        always true
        Throws:
        java.lang.NullPointerException - if point is null
        ArcGISRuntimeException - if the point has a SpatialReference that does not match that of this PointCollection. The SpatialReference of the point may however be null.
        Since:
        100.0.0
      • add

        public boolean add​(double x,
                           double y,
                           double z)
        Creates a new Point with the given x,y coordinates and z value, and appends it to the end of this PointCollection.

        Calling this method on the PointCollection of a MultipointBuilder will set hasZ to true, because a z value has been explicitly set.

        Parameters:
        x - the x coordinate of the new Point appended to this PointCollection
        y - the y coordinate of the new Point appended to this PointCollection
        z - the z value of the new Point appended to this PointCollection
        Returns:
        always true
        Since:
        100.0.0
      • add

        public void add​(int index,
                        Point point)
        Inserts the given Point at the given index of this PointCollection. The index positions of all subsequent Points increase by one. If the point index is equal to the point count, this method is equivalent to adding a point to the end of the collection.
        Specified by:
        add in interface java.util.List<Point>
        Overrides:
        add in class java.util.AbstractList<Point>
        Parameters:
        index - the index of the Point to insert in the Part
        point - the Point to insert at the given index
        Throws:
        java.lang.NullPointerException - if point is null
        java.lang.IndexOutOfBoundsException - if index < 0 || index > size()
        ArcGISRuntimeException - if the point has a SpatialReference that does not match that of this PointCollection. The SpatialReference of the point may however be null.
        Since:
        100.0.0
      • add

        public void add​(int index,
                        double x,
                        double y)
        Creates a new Point with the given x,y coordinates and inserts it at the given index of this PointCollection. The index positions of all subsequent Points increase by one.
        Parameters:
        index - the index to insert the point at
        x - the x coordinate of the new Point inserted into this PointCollection
        y - the y coordinate of the new Point inserted into this PointCollection
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index > size()
        Since:
        100.0.0
      • add

        public void add​(int index,
                        double x,
                        double y,
                        double z)
        Creates a new Point with the given x,y coordinates and z value, and inserts it at the given index of this PointCollection. The index positions of all subsequent Points increase by one.

        Calling this method on the PointCollection of a MultipointBuilder will set hasZ to true, because a z value has been explicitly set.

        Parameters:
        index - the index to insert the point at
        x - the x coordinate of the new Point inserted into this PointCollection
        y - the y coordinate of the new Point inserted into this PointCollection
        z - the z value of the new Point inserted into this PointCollection
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= size()
        Since:
        100.0.0
      • remove

        public Point remove​(int index)
        Removes the Point at the given index position from the PointCollection.
        Specified by:
        remove in interface java.util.List<Point>
        Overrides:
        remove in class java.util.AbstractList<Point>
        Parameters:
        index - the index of the Point to remove from the Part
        Returns:
        a copy of the removed Point
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >= size()
        Since:
        100.0.0
      • clear

        public void clear()
        Removes all Points from the PointCollection. Using this method is more efficient than removing all Points individually.
        Specified by:
        clear in interface java.util.Collection<Point>
        Specified by:
        clear in interface java.util.List<Point>
        Overrides:
        clear in class java.util.AbstractList<Point>
        Since:
        100.0.0
        See Also:
        isEmpty()
      • indexOf

        public int indexOf​(java.lang.Object object)
        Specified by:
        indexOf in interface java.util.List<Point>
        Overrides:
        indexOf in class java.util.AbstractList<Point>
        Throws:
        java.lang.NullPointerException - if object is null
        Since:
        100.0.0