Class Part
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<Segment>
-
- com.esri.arcgisruntime.geometry.Part
-
public final class Part extends AbstractList<Segment>
Represents a mutable collection ofSegment
s that define the shape of a part of aMultipart
geometry under construction. Used inPolygon
andPolyline
constructors, and byMultipartBuilder.getParts()
andMultipartBuilder.getParts()
(both builders inherit fromMultipartBuilder
).Use the methods inherited from the generic Java
AbstractList<T>
class to define and change the shape of thePart
by adding, removing, or changing its segments. Additionally, the helper methodsaddPoint()
,addPoints()
,setPoint()
, andremovePoint()
are allPoint
-based and allow working with points that represent the vertices of thePart
, instead of working with segments.Adjacent segments which share an end point and a start point are connected, and the shared vertex is not duplicated when accessing points. The
Part
can represent gaps between one end point and an adjacent start. However, this is only recommended as a temporary state while modifying amultipart builder
; when usingGeometryBuilder.toGeometry()
the gaps are closed with line segments.The SpatialReference of any geometries added to a
Part
must match that of thePart
, or be null (in which case the geometry is assumed to have the same SpatialReference as thePart
). Added geometries are not reprojected.Parts can then be added to, inserted into, and removed from a
PartCollection
, in order to build up the complete shape of a geometry with multiple parts. Again, the SpatialReferences must be compatible.Prior to v100.12, only
LineSegment
linear segments were available to be added to parts when building geometries. The SDK could display curved geometries, but you could not work with curves using the API; any curved segments in a geometry would be represented asLineSegments
, and the curve information would be lost. You can callhasCurves()
to determine if the part contains any curve segments.From v100.12, geometry builders support curve segments. You can call
hasCurves()
to determine if the part contains any curve segments.- Since:
- 100.0.0
- See Also:
CubicBezierSegment
,EllipticArcSegment
,LineSegment
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description Part(ImmutablePointCollection points)
Creates a new part from the givenImmutablePointCollection
.Part(ImmutablePointCollection points, SpatialReference spatialReference)
Creates a new part from the given ImmutablePointCollection and SpatialReference.Part(PointCollection points)
Creates a new part from the givenPointCollection
.Part(PointCollection points, SpatialReference spatialReference)
Creates a new part from the givenPointCollection
andSpatialReference
.Part(SpatialReference spatialReference)
Creates a new emptyPart
with the given SpatialReference.Part(Iterable<Segment> segments)
Creates a new part with the given set ofSegment
s.Part(Iterable<Segment> segments, SpatialReference spatialReference)
Creates a new part with the given set ofSegment
s andSpatialReference
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, Segment segment)
Inserts the givenSegment
at the given index position in thisPart
.boolean
add(Segment segment)
Appends the givenSegment
to the end of thisPart
.void
addAllPoints(int index, Collection<? extends Point> points)
Inserts the given collection ofPoint
s at the given index position in thisPart
.void
addPoint(double x, double y)
Creates a newPoint
from the given x,y coordinates and appends it to the end of thisPart
, resulting in a new LineSegment between the previous lastPoint
and the appendedPoint
.void
addPoint(double x, double y, double z)
Creates a newPoint
from the given x,y coordinates and z value, and appends it to the end of thisPart
, resulting in a newLineSegment
between the previous lastPoint
and the appendedPoint
.void
addPoint(int index, double x, double y)
Creates a newPoint
from the given x,y coordinates and inserts it at the given index position in thisPart
, by mreplacing an existingSegment
with two newLineSegment
.void
addPoint(int index, double x, double y, double z)
Creates a newPoint
from the given x,y coordinates and z value, and inserts it at the given index position in thisPart
, by replacing an existingSegment
with two newLineSegment
s.void
addPoint(int index, Point point)
Inserts the givenPoint
at the given index position in thisPart
, by replacing an existingSegment
with two newLineSegment
s.void
addPoint(Point point)
Appends the givenPoint
to the end of thisPart
, resulting in a new LineSegment between the previous lastPoint
and the appendedPoint
.void
addPoints(Collection<? extends Point> points)
Appends the given collection ofPoint
s to the end of thisPart
, resulting in newLineSegment
s between the previous lastPoint
and each appended Point.void
clear()
Removes allSegment
s from thePart
.boolean
contains(Object o)
Segment
get(int index)
Gets a copy of theSegment
at the given index position in thisPart
.Point
getEndPoint()
Gets a copy of aPoint
representing the end of the last Segment of thePart
.int
getEndPointIndexFromSegmentIndex(int segmentIndex)
Gets the index of the end point of a segment.Point
getPoint(int index)
Gets a copy of thePoint
at the given index in thePart
.int
getPointCount()
Returns the number ofPoint
s in the Part, representing the number of vertices in the shape.Iterable<Point>
getPoints()
Gets an iterator ofPoint
s representing the ends of the Segments in thisPart
(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 thisPart
.Point
getStartPoint()
Gets a copy of aPoint
representing the start of the first Segment of thePart
.int
getStartPointIndexFromSegmentIndex(int segmentIndex)
Gets the index of the start point of a segment.boolean
hasCurves()
Indicates if thisPart
containsSegment
s that represent true curves.int
indexOf(Object o)
boolean
isEmpty()
Segment
remove(int index)
Removes theSegment
at the specified index position from thisPart
.boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
Point
removePoint(int index)
Removes thePoint
at the given index position from thePart
.boolean
retainAll(Collection<?> c)
Segment
set(int index, Segment segment)
Replaces theSegment
at the given index position with the givenSegment
.void
setPoint(int index, Point point)
Sets the givenPoint
at the given point index position in thisPart
.int
size()
Returns the number ofSegment
s in thisPart
.-
Methods inherited from class java.util.AbstractList
addAll, equals, hashCode, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, 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, containsAll, replaceAll, sort, spliterator, toArray, toArray
-
-
-
-
Constructor Detail
-
Part
public Part(SpatialReference spatialReference)
Creates a new emptyPart
with the given SpatialReference. SpatialReference cannot be changed after instantiation.- Parameters:
spatialReference
- the SpatialReference of the newPart
. May be null.- Since:
- 100.0.0
-
Part
public Part(Iterable<Segment> segments)
Creates a new part with the given set ofSegment
s. The segments in the part can be modified after instantiation. TheSpatialReference
of the newPart
will match that of the given segments.- Parameters:
segments
- the set of Segments that this Part will be initialized with. For example, this argument may be an existing Part, ImmutablePart, or standard generic Java ArrayList containing Segments. If null, an empty Part is created.- Throws:
ArcGISRuntimeException
- ifsegments
contains Segments that have differing SpatialReferences set.- Since:
- 100.0.0
- See Also:
ImmutablePart
-
Part
public Part(Iterable<Segment> segments, SpatialReference spatialReference)
Creates a new part with the given set ofSegment
s andSpatialReference
. The segments in the part can be modified after instantiation.Use this constructor to create a new
Part
with a specificSpatialReference
from an existing set of segments that have nullSpatialReference
s (the segments are assigned the givenSpatialReference
; they are not projected). Can also be used where theSpatialReference
of some segments matches that of the argument, but is null for other segments.- Parameters:
segments
- the set of Segments that this Part will be initialized with. For example, this argument may be an existing Part, ImmutablePart, or standard generic JavaArrayList
containing Segments. If null, an emptyPart
is created.spatialReference
- the SpatialReference of the new Part. May be null.- Throws:
ArcGISRuntimeException
- if thesegments
argument contains Segments with SpatialReferences that do not match thespatialReference
argument.- Since:
- 100.0.0
- See Also:
ImmutablePart
-
Part
public Part(PointCollection points)
Creates a new part from the givenPointCollection
. The part can be modified after instantiation. TheSpatialReference
of the newPart
will match that of the given points.- Parameters:
points
- the set of Points that this Part will be initialized with. If null, an empty Part is created.- Since:
- 100.0.0
-
Part
public Part(PointCollection points, SpatialReference spatialReference)
Creates a new part from the givenPointCollection
andSpatialReference
. The part can be modified after instantiation.Use this constructor to create a new
Part
with a specificSpatialReference
from an existingPointCollection
that has a nullSpatialReference
(the points are assigned the givenSpatialReference
; they are not projected).- Parameters:
points
- the set of Points that this Part will be initialized with. If null, an empty Part is created.spatialReference
- the SpatialReference of the new Part. May be null.- Throws:
ArcGISRuntimeException
- if thepoints
argument contains Points with SpatialReferences that do not match thespatialReference
argument.- Since:
- 100.0.0
-
Part
public Part(ImmutablePointCollection points)
Creates a new part from the givenImmutablePointCollection
. The part can be modified after instantiation. TheSpatialReference
of the newPart
will match that of the given points.Use this constructor to create a new
Part
from aPart
of an existingPolygon
orPolyline
by usingImmutablePart.getPoints()
.- Parameters:
points
- the set of Points that this Part will be initialized with- Since:
- 100.0.0
-
Part
public Part(ImmutablePointCollection points, SpatialReference spatialReference)
Creates a new part from the given ImmutablePointCollection and SpatialReference. The part can be modified after instantiation.Use this constructor to create a new
Part
with a specificSpatialReference
from an existingImmutablePointCollection
that has a nullSpatialReference
(the points are assigned the givenSpatialReference
; they are not projected). An example of this is to create a newPart
from aPart
of an existingPolygon
orPolyline
by usingImmutablePart.getPoints()
.- Parameters:
points
- the set of Points that this Part will be initialized with. If null, an empty Part is created.spatialReference
- spatialReference the SpatialReference of the new Part. May be null.- Since:
- 100.0.0
-
-
Method Detail
-
getSpatialReference
public SpatialReference getSpatialReference()
Gets the SpatialReference of the geometries in thisPart
. 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 Part
- Since:
- 100.0.0
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<Segment>
- Specified by:
isEmpty
in interfaceList<Segment>
- Overrides:
isEmpty
in classAbstractCollection<Segment>
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<Segment>
- Specified by:
contains
in interfaceList<Segment>
- Overrides:
contains
in classAbstractCollection<Segment>
-
get
public Segment get(int index)
Gets a copy of theSegment
at the given index position in thisPart
.- Specified by:
get
in interfaceList<Segment>
- Specified by:
get
in classAbstractList<Segment>
- Parameters:
index
- the index of the Segment to copy- Returns:
- a copy of the Segment at the given index
- Throws:
IndexOutOfBoundsException
- ifindex < 0 || index >= size()
- Since:
- 100.0.0
-
size
public int size()
Returns the number ofSegment
s in thisPart
. Use this to find the maximum index for callingget(int)
.A
Part
can also be represented by a set ofPoint
s representing each vertex; thegetPointCount()
method returns the number ofPoint
s in thePart
. SeegetPointCount()
for an explanation of how the two relate.- Specified by:
size
in interfaceCollection<Segment>
- Specified by:
size
in interfaceList<Segment>
- Specified by:
size
in classAbstractCollection<Segment>
- Since:
- 100.0.0
- See Also:
getPointCount()
,get(int)
-
indexOf
public int indexOf(Object o)
-
set
public Segment set(int index, Segment segment)
Replaces theSegment
at the given index position with the givenSegment
.Use this method to update a segment in a
Part
- as segments are immutable, properties of existing segments cannot be changed.- Specified by:
set
in interfaceList<Segment>
- Overrides:
set
in classAbstractList<Segment>
- Parameters:
index
- the index of the Segment to replacesegment
- the Segment to set at the given index- Throws:
IndexOutOfBoundsException
- ifindex
< 0 ||index
>= size()NullPointerException
- ifsegment
is nullArcGISRuntimeException
- if thesegment
has a SpatialReference that does not match that of this Part. The SpatialReference of thesegment
may however be null.- Since:
- 100.0.0
- See Also:
add(int, Segment)
-
add
public boolean add(Segment segment)
Appends the givenSegment
to the end of thisPart
. If thestart point
of the segment matches the previousend point
, the segment will share this point.The count of points will increase by 1 if the segment connects, or 2 points if it is disconnected.
If the
start point
of the appendedSegment
is at a different location from theend point
of the previousSegment
, a gap will be introduced to thePart
. Any gaps will be replaced by new connecting segments in the return value ofGeometryBuilder.toGeometry()
.A more efficient way to add a
LineSegment
to a part is to use of the point addition methods. For example,addPoint(double, double)
.- Specified by:
add
in interfaceCollection<Segment>
- Specified by:
add
in interfaceList<Segment>
- Overrides:
add
in classAbstractList<Segment>
- Parameters:
segment
- the Segment to append to this PointCollection- Returns:
- always true
- Throws:
NullPointerException
- ifsegment
is nullArcGISRuntimeException
- if thesegment
has a SpatialReference that does not match that of this Part. The SpatialReference of thesegment
may however be null.- Since:
- 100.0.0
- See Also:
addPoint(Point)
,add(int, Segment)
-
add
public void add(int index, Segment segment)
Inserts the givenSegment
at the given index position in thisPart
. The index positions of all existingSegment
s at that index or greater increase by one.If the
start point
and/orend point
of the insertedSegment
is at a different location to those of the adjacentSegment
s, gap(s) will be introduced to thePart
. Any gaps will be replaced by new connecting segments in the return value ofGeometryBuilder.toGeometry()
. Alternatively, use theaddPoint(int, Point)
method to insert aPoint
in thePart
.- Specified by:
add
in interfaceList<Segment>
- Overrides:
add
in classAbstractList<Segment>
- Parameters:
index
- the index of the Segment to insert in the Partsegment
- the Segment to insert at the given index- Throws:
NullPointerException
- ifsegment
is nullArcGISRuntimeException
- if thesegment
has a SpatialReference that does not match that of this Part. The SpatialReference of thesegment
may however be null.IndexOutOfBoundsException
- ifindex
< 0 ||index
> size()- Since:
- 100.0.0
- See Also:
add(Segment)
-
remove
public Segment remove(int index)
Removes theSegment
at the specified index position from thisPart
. No other segments are changed when this method is called, which may result in a gap between the segment ends.- Specified by:
remove
in interfaceList<Segment>
- Overrides:
remove
in classAbstractList<Segment>
- Parameters:
index
- the index of the Segment to remove- Returns:
- a copy of the removed Segment
- Throws:
IndexOutOfBoundsException
- ifindex
< 0 ||index
>= size()- Since:
- 100.0.0
- See Also:
size()
,clear()
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<Segment>
- Specified by:
remove
in interfaceList<Segment>
- Overrides:
remove
in classAbstractCollection<Segment>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<Segment>
- Specified by:
removeAll
in interfaceList<Segment>
- Overrides:
removeAll
in classAbstractCollection<Segment>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<Segment>
- Specified by:
retainAll
in interfaceList<Segment>
- Overrides:
retainAll
in classAbstractCollection<Segment>
-
getPointCount
public int getPointCount()
Returns the number ofPoint
s in the Part, representing the number of vertices in the shape. Use this to find the maximum index for callinggetPoint(int)
.Typically this number is one greater than the number of
Segment
s in the part (size()
). Where two adjacent segments share a start and end location (there is no gap between the segments), this is represented by a singlePoint
. If using point-based methods to construct Parts, there will be no gaps between segments. However if using Segments to construct Parts, it is possible to introduce gaps between segments.Gaps are eliminated when geometries are built using the
GeometryBuilder.toGeometry()
method. CompletedMultipart
geometries do not have gaps between the segments of a part, but separatePart
s may be disjoint.- Returns:
- the number of Points in the Part
- Since:
- 100.0.0
- See Also:
size()
,getPoints()
-
getStartPoint
public Point getStartPoint()
Gets a copy of aPoint
representing the start of the first Segment of thePart
. This is a shortcut to getting the first Segment in thePart
, then getting its start point usingSegment.getStartPoint()
, or getting the first Point in thePart
usinggetPoint(int)
.- Returns:
- a Point representing the start point
- Since:
- 100.0.0
- See Also:
getEndPoint()
-
getEndPoint
public Point getEndPoint()
Gets a copy of aPoint
representing the end of the last Segment of thePart
. This is a shortcut to getting the last Segment in thePart
, then getting its end point usingSegment.getEndPoint()
, or getting the last Point in thePart
usinggetPoint(int)
.- Returns:
- a Point representing the end point
- Since:
- 100.0.0
- See Also:
getStartPoint()
-
hasCurves
public boolean hasCurves()
Indicates if thisPart
containsSegment
s 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.
Prior to v100.12, only
LineSegment
linear segments were available to be added to parts when building geometries. The SDK could display curved geometries, but you could not work with curves using the API; any curved segments in a geometry would be represented asLineSegments
, and the curve information would be lost. In editing workflows, use this method to determine if thisPart
contains curve information which would be lost if used in an editing workflow.From v100.12, geometry builders support curve segments. This method returns true if any segments where
Segment.isCurve()
is true have been added to the part.- Returns:
- true if the part contains any curve segments; false otherwise
- Since:
- 100.12.0
- See Also:
Geometry.hasCurves()
,GeometryBuilder.hasCurves()
,Segment.isCurve()
-
getPoints
public Iterable<Point> getPoints()
Gets an iterator ofPoint
s representing the ends of the Segments in thisPart
(the vertices in the shape).Where two adjacent segments share a start and end location (there is no gap between the segments), this is represented by a single
Point
. SeegetPointCount()
for more information.- Returns:
- an iterator of Points
- Since:
- 100.0.0
- See Also:
PartCollection.getPartsAsPoints()
-
getPoint
public Point getPoint(int index)
Gets a copy of thePoint
at the given index in thePart
. UsegetPointCount()
to determine the maximum possible index. Note that points are copied, and therefore returned by-value.The vertices of a
MultipartBuilder
's current state can be represented as a series ofPoint
s, which can be accessed using this method, or by thegetPoints()
iterator. If the geometry containscurves
, that information cannot be represented by points; segment-based methods such asget(int)
anditerator()
may be more appropriate instead. Note that at the current release, true curves are not supported.- Parameters:
index
- the index of the Point to get- Returns:
- a copy of the Point at the given index
- Throws:
IndexOutOfBoundsException
- ifindex
< 0 ||index
>= getPointCount()- Since:
- 100.0.0
-
addPoint
public void addPoint(Point point)
Appends the givenPoint
to the end of thisPart
, resulting in a new LineSegment between the previous lastPoint
and the appendedPoint
. This is a common method to use when buildingMultipart
shapes without curves, as it may be simpler than usingadd(Segment)
and creatingSegment
s explicitly.Alternatives exist to append a new Point by specifying coordinates directly, using
addPoint(double, double)
) or similar overloads. Use theaddPoint(int, Point)
to insert aPoint
at a position other than the end of thePart
.- Parameters:
point
- the Point to append to this Part- Throws:
NullPointerException
- ifpoint
is nullArcGISRuntimeException
- if thepoint
has a SpatialReference that does not match that of this Part. The SpatialReference of thepoint
may however be null.- Since:
- 100.0.0
-
addPoint
public void addPoint(double x, double y)
Creates a newPoint
from the given x,y coordinates and appends it to the end of thisPart
, resulting in a new LineSegment between the previous lastPoint
and the appendedPoint
. This is a common method to use when buildingMultipart
shapes without curves, as it may be simpler than usingadd(Segment)
and creatingSegment
s explicitly.The appended
Point
will have default z and m values, and will take on the spatial reference of thePart
; therefore ensure that thex
andy
parameters are defined in the spatial reference of thisPart
. If either x or y are NaN, the added Point will beempty
. Alternatively, append an existing Point object to aPart
usingaddPoint(Point)
).- Parameters:
x
- the x coordinate of the new Point added to the Party
- the y coordinate of the new Point added to the Part- Since:
- 100.0.0
-
addPoint
public void addPoint(double x, double y, double z)
Creates a newPoint
from the given x,y coordinates and z value, and appends it to the end of thisPart
, resulting in a newLineSegment
between the previous lastPoint
and the appendedPoint
. This is a common method to use when buildingMultipart
shapes without curves, as it may be simpler than usingadd(Segment)
and creatingSegment
s explicitly.The appended
Point
will take on the spatial reference of thePart
; therefore ensure that thex
andy
parameters are defined in the spatial reference of thisPart
. Alternatively, append an existing Point object to aPart
usingaddPoint(Point)
).- Parameters:
x
- the x coordinate of the new Point added to the Party
- the y coordinate of the new Point added to the Partz
- the z value of the new Point added to the Part- Since:
- 100.0.0
-
addPoints
public void addPoints(Collection<? extends Point> points)
Appends the given collection ofPoint
s to the end of thisPart
, resulting in newLineSegment
s between the previous lastPoint
and each appended Point. This is a common method to use when buildingMultipart
shapes without curves, as it may be simpler than usingaddAll(Collection)
and creatingSegment
s explicitly.- Parameters:
points
- the collection of Points to append to the end of this Part- Throws:
NullPointerException
- ifpoints
is nullArcGISRuntimeException
- if thepoints
have a SpatialReference that does not match that of this Part. The SpatialReference of thepoints
may however be null.- Since:
- 100.0.0
-
addPoint
public void addPoint(int index, Point point)
Inserts the givenPoint
at the given index position in thisPart
, by replacing an existingSegment
with two newLineSegment
s. The index positions of all subsequentSegment
s (andPoint
s) increase by one. Gaps between adjacent segments cannot be introduced by point-based methods, but existing gaps may be maintained; if affected segments already have a gap.Alternatively, use the
addPoint(Point)
method to append aPoint
to the end of thePart
.- Parameters:
index
- the index of the Point to insert in the Partpoint
- the Point to insert at the given index- Throws:
NullPointerException
- ifpoint
is nullArcGISRuntimeException
- if thepoint
has a SpatialReference that does not match that of this Part. The SpatialReference of thepoint
may however be null.IndexOutOfBoundsException
- ifindex
< 0 ||index
> getPointCount()- Since:
- 100.0.0
- See Also:
add(int, Segment)
-
addPoint
public void addPoint(int index, double x, double y)
Creates a newPoint
from the given x,y coordinates and inserts it at the given index position in thisPart
, by mreplacing an existingSegment
with two newLineSegment
. The index positions of all subsequentSegment
s (andPoint
s) increase by one. Gaps between adjacent segments cannot be introduced byPoint
-based methods, but existing gaps may be maintained; if affected segments already have a gap.- Parameters:
index
- the index of the Point to insert in the Partx
- the x coordinate of the new Point inserted into the Party
- the y coordinate of the new Point inserted into the Part- Throws:
IndexOutOfBoundsException
- ifindex
< 0 ||index
> getPointCount()- Since:
- 100.0.0
-
addPoint
public void addPoint(int index, double x, double y, double z)
Creates a newPoint
from the given x,y coordinates and z value, and inserts it at the given index position in thisPart
, by replacing an existingSegment
with two newLineSegment
s. The index positions of all subsequentSegment
s (andPoint
s) increase by one. Gaps between adjacent segments cannot be introduced byPoint
-based methods, but existing gaps may be maintained; if affected segments already have a gap.- Parameters:
index
- the index of the Point to insert in the Partx
- the x coordinate of the new Point inserted into the Party
- the y coordinate of the new Point inserted into the Partz
- the z value of the new Point inserted into the Part- Throws:
IndexOutOfBoundsException
- ifindex
< 0 ||index
> getPointCount()- Since:
- 100.0.0
-
addAllPoints
public void addAllPoints(int index, Collection<? extends Point> points)
Inserts the given collection ofPoint
s at the given index position in thisPart
. Up to two existingSegment
s may be removed and replaced by newLineSegment
s connecting to the newPoint
s; additionally newLineSegment
s are created between each insertedPoint
. This is a common method to use when buildingMultipart
shapes without curves, as it may be simpler than usingaddAll(int, Collection)
and creating Segments explicitly.- Parameters:
index
- the index position at which to begin inserting the points into the Partpoints
- the collection of Points to insert at the given position- Throws:
NullPointerException
- ifpoints
is nullArcGISRuntimeException
- if any Point inpoints
has a SpatialReference that does not match that of this Part. The SpatialReference of a Point may however be null.IndexOutOfBoundsException
- ifindex
< 0 ||index
> getPointCount()- Since:
- 100.0.0
-
setPoint
public void setPoint(int index, Point point)
Sets the givenPoint
at the given point index position in thisPart
. This replaces thePoint
previously at that position and updates the segments that use it.The points in the part correspond to start and end points of segments. Setting a new point will affect 1 or 2 segments using the point at the specified index. The type of affected segment(s) (
LineSegment
,CubicBezierSegment
orEllipticArcSegment
) will remain the same.For affected cubic bezier segments, the shape of the curve may change because the control points remain the same, as does the unchanged start or end point location. For elliptic arc segments, the arc parameters are adjusted enough to ensure the unchanged start or end point location remains the same.
- Parameters:
index
- the index position within the Part at which to set the Pointpoint
- the Point to set- Throws:
IndexOutOfBoundsException
- ifindex
< 0 ||index
>= getPointCount()IllegalArgumentException
- if point is null- Since:
- 100.3.0
-
removePoint
public Point removePoint(int index)
Removes thePoint
at the given index position from thePart
. The two existingSegment
s that start and end at thisPoint
are removed, and replaced by a newLineSegment
that connects the adjacentPoint
s.This is a common method to use when editing
Multipart
shapes without curves, as it may be simpler than working withSegment
s and usingremove(int)
.- Parameters:
index
- the index of the Point to remove from the Part- Returns:
- a copy of the removed Point
- Throws:
IndexOutOfBoundsException
- ifindex
< 0 ||index
>= getPointCount()- 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:
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:
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:
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:
IndexOutOfBoundsException
- if segmentIndex is out of bounds- Since:
- 100.1.0
-
clear
public void clear()
Removes allSegment
s from thePart
. Using this method is more efficient than removing allSegment
s individually.After calling this method, the
Part
will have asize()
of zero. It will also have agetPointCount()
of zero because the Points in aPart
represent the ends of its currentSegment
s.- Specified by:
clear
in interfaceCollection<Segment>
- Specified by:
clear
in interfaceList<Segment>
- Overrides:
clear
in classAbstractList<Segment>
- Since:
- 100.0.0
- See Also:
isEmpty()
-
-