Class PointCollection
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<Point>
-
- com.esri.arcgisruntime.geometry.PointCollection
-
public final class PointCollection extends AbstractList<Point>
Represents a mutable collection of Points for creating aMultipoint
geometry from aMultipointBuilder
.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(Iterable<Point> points)
Creates a new PointCollection with the given iterable set of Points.PointCollection(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(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.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. TheSpatialReference
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 JavaArrayList
containing Points. If null, an empty PointCollection is created.- Throws:
ArcGISRuntimeException
- ifpoints
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 JavaArrayList
containing Points. If null, an empty PointCollection is created.spatialReference
- the SpatialReference of the new PointCollection. May be null.- Throws:
ArcGISRuntimeException
- if thepoints
argument contains Points with SpatialReferences that do not match thespatialReference
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 JavaArrayList
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 JavaArrayList
containing Points. If null, an empty PointCollection is created.spatialReference
- the SpatialReference of the new PointCollection. May be null.- Throws:
ArcGISRuntimeException
- if thepart
argument has a SpatialReference that does not match thespatialReference
argument.- Since:
- 100.0.0
-
-
Method Detail
-
getSpatialReference
public SpatialReference getSpatialReference()
Gets the SpatialReference of the geometries in this PointCollection. TheSpatialReference
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. Usesize()
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 interfaceList<Point>
- Specified by:
get
in classAbstractList<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
-
size
public int size()
Returns the number of Points in this PointCollection. Use this to find the maximum index for callingget(int)
.- Specified by:
size
in interfaceCollection<Point>
- Specified by:
size
in interfaceList<Point>
- Specified by:
size
in classAbstractCollection<Point>
- Since:
- 100.0.0
- See Also:
get(int)
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<Point>
- Specified by:
isEmpty
in interfaceList<Point>
- Overrides:
isEmpty
in classAbstractCollection<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 interfaceList<Point>
- Overrides:
set
in classAbstractList<Point>
- Parameters:
index
- the index of the Point to replacepoint
- the Point to set at the given index- Returns:
- the Point that was replaced
- Throws:
IndexOutOfBoundsException
- ifindex
< 0 ||index
>= size()NullPointerException
- ifpoint
is nullArcGISRuntimeException
- if thepoint
has a SpatialReference that does not match that of this PointCollection. The SpatialReference of thepoint
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
andy
parameters should be defined in the SpatialReference of this PointCollection.- Parameters:
index
- the index of the Point to replacex
- the x coordinate of the new Pointy
- the y coordinate of the new Point- Returns:
- the Point that was replaced
- Throws:
IndexOutOfBoundsException
- ifindex
< 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 interfaceCollection<Point>
- Specified by:
add
in interfaceList<Point>
- Overrides:
add
in classAbstractList<Point>
- Parameters:
point
- the Point to append to this PointCollection- Returns:
- always true
- Throws:
NullPointerException
- ifpoint
is nullArcGISRuntimeException
- if thepoint
has a SpatialReference that does not match that of this PointCollection. The SpatialReference of thepoint
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 PointCollectiony
- the y coordinate of the new Point appended to this PointCollection- Returns:
- always true
- Throws:
NullPointerException
- ifpoint
is nullArcGISRuntimeException
- if thepoint
has a SpatialReference that does not match that of this PointCollection. The SpatialReference of thepoint
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 PointCollectiony
- the y coordinate of the new Point appended to this PointCollectionz
- 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 interfaceList<Point>
- Overrides:
add
in classAbstractList<Point>
- Parameters:
index
- the index of the Point to insert in the Partpoint
- the Point to insert at the given index- Throws:
NullPointerException
- ifpoint
is nullIndexOutOfBoundsException
- ifindex
< 0 ||index
> size()ArcGISRuntimeException
- if thepoint
has a SpatialReference that does not match that of this PointCollection. The SpatialReference of thepoint
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 atx
- the x coordinate of the new Point inserted into this PointCollectiony
- the y coordinate of the new Point inserted into this PointCollection- Throws:
IndexOutOfBoundsException
- ifindex
< 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 atx
- the x coordinate of the new Point inserted into this PointCollectiony
- the y coordinate of the new Point inserted into this PointCollectionz
- the z value of the new Point inserted into this PointCollection- Throws:
IndexOutOfBoundsException
- ifindex
< 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 interfaceList<Point>
- Overrides:
remove
in classAbstractList<Point>
- Parameters:
index
- the index of the Point to remove from the Part- Returns:
- a copy of the removed Point
- Throws:
IndexOutOfBoundsException
- ifindex
< 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 interfaceCollection<Point>
- Specified by:
clear
in interfaceList<Point>
- Overrides:
clear
in classAbstractList<Point>
- Since:
- 100.0.0
- See Also:
isEmpty()
-
indexOf
public int indexOf(Object object)
- Specified by:
indexOf
in interfaceList<Point>
- Overrides:
indexOf
in classAbstractList<Point>
- Throws:
NullPointerException
- if object is null- Since:
- 100.0.0
-
-