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 ofSegments that define the shape of a part of aMultipartgeometry under construction. Used inPolygonandPolylineconstructors, 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 thePartby 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
Partcan 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
Partmust 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
LineSegmentlinear 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 givenPointCollectionandSpatialReference.Part(SpatialReference spatialReference)Creates a new emptyPartwith the given SpatialReference.Part(Iterable<Segment> segments)Creates a new part with the given set ofSegments.Part(Iterable<Segment> segments, SpatialReference spatialReference)Creates a new part with the given set ofSegments andSpatialReference.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, Segment segment)Inserts the givenSegmentat the given index position in thisPart.booleanadd(Segment segment)Appends the givenSegmentto the end of thisPart.voidaddAllPoints(int index, Collection<? extends Point> points)Inserts the given collection ofPoints at the given index position in thisPart.voidaddPoint(double x, double y)Creates a newPointfrom the given x,y coordinates and appends it to the end of thisPart, resulting in a new LineSegment between the previous lastPointand the appendedPoint.voidaddPoint(double x, double y, double z)Creates a newPointfrom the given x,y coordinates and z value, and appends it to the end of thisPart, resulting in a newLineSegmentbetween the previous lastPointand the appendedPoint.voidaddPoint(int index, double x, double y)Creates a newPointfrom the given x,y coordinates and inserts it at the given index position in thisPart, by mreplacing an existingSegmentwith two newLineSegment.voidaddPoint(int index, double x, double y, double z)Creates a newPointfrom the given x,y coordinates and z value, and inserts it at the given index position in thisPart, by replacing an existingSegmentwith two newLineSegments.voidaddPoint(int index, Point point)Inserts the givenPointat the given index position in thisPart, by replacing an existingSegmentwith two newLineSegments.voidaddPoint(Point point)Appends the givenPointto the end of thisPart, resulting in a new LineSegment between the previous lastPointand the appendedPoint.voidaddPoints(Collection<? extends Point> points)Appends the given collection ofPoints to the end of thisPart, resulting in newLineSegments between the previous lastPointand each appended Point.voidclear()Removes allSegments from thePart.booleancontains(Object o)Segmentget(int index)Gets a copy of theSegmentat the given index position in thisPart.PointgetEndPoint()Gets a copy of aPointrepresenting the end of the last Segment of thePart.intgetEndPointIndexFromSegmentIndex(int segmentIndex)Gets the index of the end point of a segment.PointgetPoint(int index)Gets a copy of thePointat the given index in thePart.intgetPointCount()Returns the number ofPoints in the Part, representing the number of vertices in the shape.Iterable<Point>getPoints()Gets an iterator ofPoints representing the ends of the Segments in thisPart(the vertices in the shape).intgetSegmentIndexFromEndPointIndex(int endPointIndex)Gets the index of the segment that has a given end point.intgetSegmentIndexFromStartPointIndex(int startPointIndex)Gets the index of the segment that has a given start point.SpatialReferencegetSpatialReference()Gets the SpatialReference of the geometries in thisPart.PointgetStartPoint()Gets a copy of aPointrepresenting the start of the first Segment of thePart.intgetStartPointIndexFromSegmentIndex(int segmentIndex)Gets the index of the start point of a segment.booleanhasCurves()Indicates if thisPartcontainsSegments that represent true curves.intindexOf(Object o)booleanisEmpty()Segmentremove(int index)Removes theSegmentat the specified index position from thisPart.booleanremove(Object o)booleanremoveAll(Collection<?> c)PointremovePoint(int index)Removes thePointat the given index position from thePart.booleanretainAll(Collection<?> c)Segmentset(int index, Segment segment)Replaces theSegmentat the given index position with the givenSegment.voidsetPoint(int index, Point point)Sets the givenPointat the given point index position in thisPart.intsize()Returns the number ofSegments 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 emptyPartwith 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 ofSegments. The segments in the part can be modified after instantiation. TheSpatialReferenceof the newPartwill 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- ifsegmentscontains 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 ofSegments andSpatialReference. The segments in the part can be modified after instantiation.Use this constructor to create a new
Partwith a specificSpatialReferencefrom an existing set of segments that have nullSpatialReferences (the segments are assigned the givenSpatialReference; they are not projected). Can also be used where theSpatialReferenceof 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 JavaArrayListcontaining Segments. If null, an emptyPartis created.spatialReference- the SpatialReference of the new Part. May be null.- Throws:
ArcGISRuntimeException- if thesegmentsargument contains Segments with SpatialReferences that do not match thespatialReferenceargument.- 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. TheSpatialReferenceof the newPartwill 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 givenPointCollectionandSpatialReference. The part can be modified after instantiation.Use this constructor to create a new
Partwith a specificSpatialReferencefrom an existingPointCollectionthat 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 thepointsargument contains Points with SpatialReferences that do not match thespatialReferenceargument.- Since:
- 100.0.0
-
Part
public Part(ImmutablePointCollection points)
Creates a new part from the givenImmutablePointCollection. The part can be modified after instantiation. TheSpatialReferenceof the newPartwill match that of the given points.Use this constructor to create a new
Partfrom aPartof an existingPolygonorPolylineby 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
Partwith a specificSpatialReferencefrom an existingImmutablePointCollectionthat has a nullSpatialReference(the points are assigned the givenSpatialReference; they are not projected). An example of this is to create a newPartfrom aPartof an existingPolygonorPolylineby 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. TheSpatialReferencedefines 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:
isEmptyin interfaceCollection<Segment>- Specified by:
isEmptyin interfaceList<Segment>- Overrides:
isEmptyin classAbstractCollection<Segment>
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<Segment>- Specified by:
containsin interfaceList<Segment>- Overrides:
containsin classAbstractCollection<Segment>
-
get
public Segment get(int index)
Gets a copy of theSegmentat the given index position in thisPart.- Specified by:
getin interfaceList<Segment>- Specified by:
getin 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 ofSegments in thisPart. Use this to find the maximum index for callingget(int).A
Partcan also be represented by a set ofPoints representing each vertex; thegetPointCount()method returns the number ofPoints in thePart. SeegetPointCount()for an explanation of how the two relate.- Specified by:
sizein interfaceCollection<Segment>- Specified by:
sizein interfaceList<Segment>- Specified by:
sizein 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 theSegmentat 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:
setin interfaceList<Segment>- Overrides:
setin 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- ifsegmentis nullArcGISRuntimeException- if thesegmenthas a SpatialReference that does not match that of this Part. The SpatialReference of thesegmentmay however be null.- Since:
- 100.0.0
- See Also:
add(int, Segment)
-
add
public boolean add(Segment segment)
Appends the givenSegmentto the end of thisPart. If thestart pointof 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 pointof the appendedSegmentis at a different location from theend pointof 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
LineSegmentto a part is to use of the point addition methods. For example,addPoint(double, double).- Specified by:
addin interfaceCollection<Segment>- Specified by:
addin interfaceList<Segment>- Overrides:
addin classAbstractList<Segment>- Parameters:
segment- the Segment to append to this PointCollection- Returns:
- always true
- Throws:
NullPointerException- ifsegmentis nullArcGISRuntimeException- if thesegmenthas a SpatialReference that does not match that of this Part. The SpatialReference of thesegmentmay however be null.- Since:
- 100.0.0
- See Also:
addPoint(Point),add(int, Segment)
-
add
public void add(int index, Segment segment)Inserts the givenSegmentat the given index position in thisPart. The index positions of all existingSegments at that index or greater increase by one.If the
start pointand/orend pointof the insertedSegmentis at a different location to those of the adjacentSegments, 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 aPointin thePart.- Specified by:
addin interfaceList<Segment>- Overrides:
addin classAbstractList<Segment>- Parameters:
index- the index of the Segment to insert in the Partsegment- the Segment to insert at the given index- Throws:
NullPointerException- ifsegmentis nullArcGISRuntimeException- if thesegmenthas a SpatialReference that does not match that of this Part. The SpatialReference of thesegmentmay however be null.IndexOutOfBoundsException- ifindex< 0 ||index> size()- Since:
- 100.0.0
- See Also:
add(Segment)
-
remove
public Segment remove(int index)
Removes theSegmentat 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:
removein interfaceList<Segment>- Overrides:
removein 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:
removein interfaceCollection<Segment>- Specified by:
removein interfaceList<Segment>- Overrides:
removein classAbstractCollection<Segment>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<Segment>- Specified by:
removeAllin interfaceList<Segment>- Overrides:
removeAllin classAbstractCollection<Segment>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<Segment>- Specified by:
retainAllin interfaceList<Segment>- Overrides:
retainAllin classAbstractCollection<Segment>
-
getPointCount
public int getPointCount()
Returns the number ofPoints 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
Segments 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. CompletedMultipartgeometries do not have gaps between the segments of a part, but separateParts 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 aPointrepresenting 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 thePartusinggetPoint(int).- Returns:
- a Point representing the start point
- Since:
- 100.0.0
- See Also:
getEndPoint()
-
getEndPoint
public Point getEndPoint()
Gets a copy of aPointrepresenting 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 thePartusinggetPoint(int).- Returns:
- a Point representing the end point
- Since:
- 100.0.0
- See Also:
getStartPoint()
-
hasCurves
public boolean hasCurves()
Indicates if thisPartcontainsSegments 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
LineSegmentlinear 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 thisPartcontains 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 ofPoints 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 thePointat 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 ofPoints, 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 givenPointto the end of thisPart, resulting in a new LineSegment between the previous lastPointand the appendedPoint. This is a common method to use when buildingMultipartshapes without curves, as it may be simpler than usingadd(Segment)and creatingSegments 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 aPointat a position other than the end of thePart.- Parameters:
point- the Point to append to this Part- Throws:
NullPointerException- ifpointis nullArcGISRuntimeException- if thepointhas a SpatialReference that does not match that of this Part. The SpatialReference of thepointmay however be null.- Since:
- 100.0.0
-
addPoint
public void addPoint(double x, double y)Creates a newPointfrom the given x,y coordinates and appends it to the end of thisPart, resulting in a new LineSegment between the previous lastPointand the appendedPoint. This is a common method to use when buildingMultipartshapes without curves, as it may be simpler than usingadd(Segment)and creatingSegments explicitly.The appended
Pointwill have default z and m values, and will take on the spatial reference of thePart; therefore ensure that thexandyparameters 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 aPartusingaddPoint(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 newPointfrom the given x,y coordinates and z value, and appends it to the end of thisPart, resulting in a newLineSegmentbetween the previous lastPointand the appendedPoint. This is a common method to use when buildingMultipartshapes without curves, as it may be simpler than usingadd(Segment)and creatingSegments explicitly.The appended
Pointwill take on the spatial reference of thePart; therefore ensure that thexandyparameters are defined in the spatial reference of thisPart. Alternatively, append an existing Point object to aPartusingaddPoint(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 ofPoints to the end of thisPart, resulting in newLineSegments between the previous lastPointand each appended Point. This is a common method to use when buildingMultipartshapes without curves, as it may be simpler than usingaddAll(Collection)and creatingSegments explicitly.- Parameters:
points- the collection of Points to append to the end of this Part- Throws:
NullPointerException- ifpointsis nullArcGISRuntimeException- if thepointshave a SpatialReference that does not match that of this Part. The SpatialReference of thepointsmay however be null.- Since:
- 100.0.0
-
addPoint
public void addPoint(int index, Point point)Inserts the givenPointat the given index position in thisPart, by replacing an existingSegmentwith two newLineSegments. The index positions of all subsequentSegments (andPoints) 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 aPointto 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- ifpointis nullArcGISRuntimeException- if thepointhas a SpatialReference that does not match that of this Part. The SpatialReference of thepointmay 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 newPointfrom the given x,y coordinates and inserts it at the given index position in thisPart, by mreplacing an existingSegmentwith two newLineSegment. The index positions of all subsequentSegments (andPoints) 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 newPointfrom the given x,y coordinates and z value, and inserts it at the given index position in thisPart, by replacing an existingSegmentwith two newLineSegments. The index positions of all subsequentSegments (andPoints) 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 ofPoints at the given index position in thisPart. Up to two existingSegments may be removed and replaced by newLineSegments connecting to the newPoints; additionally newLineSegments are created between each insertedPoint. This is a common method to use when buildingMultipartshapes 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- ifpointsis nullArcGISRuntimeException- if any Point inpointshas 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 givenPointat the given point index position in thisPart. This replaces thePointpreviously 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,CubicBezierSegmentorEllipticArcSegment) 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 thePointat the given index position from thePart. The two existingSegments that start and end at thisPointare removed, and replaced by a newLineSegmentthat connects the adjacentPoints.This is a common method to use when editing
Multipartshapes without curves, as it may be simpler than working withSegments 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 allSegments from thePart. Using this method is more efficient than removing allSegments individually.After calling this method, the
Partwill have asize()of zero. It will also have agetPointCount()of zero because the Points in aPartrepresent the ends of its currentSegments.- Specified by:
clearin interfaceCollection<Segment>- Specified by:
clearin interfaceList<Segment>- Overrides:
clearin classAbstractList<Segment>- Since:
- 100.0.0
- See Also:
isEmpty()
-
-