Class PointCollection

  • All Implemented Interfaces:
    Iterable<Point>, Collection<Point>, List<Point>

    public final class PointCollection
    extends 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
    • 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​(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​(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 List<Point>
        Specified by:
        get in class AbstractList<Point>
        Parameters:
        index - the index of the Point to get
        Returns:
        a copy of the Point at the given index
        Throws:
        IndexOutOfBoundsException - if index is out of range (index < 0 || index >= size())
        Since:
        100.0.0
      • 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 List<Point>
        Overrides:
        set in class 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:
        IndexOutOfBoundsException - if index < 0 || index >= size()
        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:
        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 Collection<Point>
        Specified by:
        add in interface List<Point>
        Overrides:
        add in class AbstractList<Point>
        Parameters:
        point - the Point to append to this PointCollection
        Returns:
        always true
        Throws:
        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:
        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 List<Point>
        Overrides:
        add in class AbstractList<Point>
        Parameters:
        index - the index of the Point to insert in the Part
        point - the Point to insert at the given index
        Throws:
        NullPointerException - if point is null
        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:
        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:
        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 List<Point>
        Overrides:
        remove in class AbstractList<Point>
        Parameters:
        index - the index of the Point to remove from the Part
        Returns:
        a copy of the removed Point
        Throws:
        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 Collection<Point>
        Specified by:
        clear in interface List<Point>
        Overrides:
        clear in class AbstractList<Point>
        Since:
        100.0.0
        See Also:
        isEmpty()