Class ImmutablePart
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<Segment>
-
- com.esri.arcgisruntime.geometry.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 ofSegments
that define the shape of a part of an immutableMultipart
geometry -Polygon
orPolyline
. Point-based helper methods also allow working with the part as a series ofPoints
.Use
Multipart.getParts()
to return anImmutablePartCollection
, which can then be used to iterate through the Segments and Points in each ImmutablePart. Usejava.util.AbstractList.iterator()
orgetPoints()
to return an iterator, or useget(int)
orgetPoint(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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(java.lang.Object o)
Segment
get(int index)
Gets theSegment
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 ofSegments
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
-
-
-
-
Method Detail
-
getSpatialReference
public SpatialReference getSpatialReference()
Gets the SpatialReference of the geometries in this ImmutablePart. TheSpatialReference
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 theSegment
at the given index position in this ImmutablePart.To work with the Part as a series of Points, use
getPoint(int)
andgetPointCount()
instead.- Specified by:
get
in interfacejava.util.List<Segment>
- Specified by:
get
in classjava.util.AbstractList<Segment>
- Parameters:
index
- the index of the Segment to return- Returns:
- the Segment at the given index
- Throws:
java.lang.IndexOutOfBoundsException
- ifindex < 0 || index >= size()
- Since:
- 100.0.0
-
indexOf
public int indexOf(java.lang.Object o)
-
size
public int size()
Returns the number ofSegments
in this ImmutablePart. Use this to find the maximum index for callingget(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 interfacejava.util.Collection<Segment>
- Specified by:
size
in interfacejava.util.List<Segment>
- Specified by:
size
in classjava.util.AbstractCollection<Segment>
- Since:
- 100.0.0
- See Also:
getPointCount()
,get(int)
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(java.lang.Object o)
-
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 usingSegment.getStartPoint()
, or getting the first Point usinggetPoint(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 usingSegment.getEndPoint()
, or getting the last Point usinggetPoint(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. UsegetPointCount()
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 containscurves
, this cannot be represented by points; segment-based methods such asget(int)
andjava.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 callinggetPoint(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 onlyLineSegment
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
-
-