- java.lang.Object
-
- org.arakhne.afc.gis.primitive.AbstractGISElement<C,T>
-
- org.arakhne.afc.gis.primitive.AbstractBoundedGISElement<GISElementContainer<?>,MapElement>
-
- org.arakhne.afc.gis.mapelement.MapElement
-
- org.arakhne.afc.gis.mapelement.MapComposedElement
-
- org.arakhne.afc.gis.mapelement.MapPolyline
-
- All Implemented Interfaces:
Serializable,Cloneable,EventListener,AttributeChangeListener,AttributeCollection,AttributeProvider,BoundedGISElement,FlagContainer,GISCloneable<MapElement>,GISContentElement<GISElementContainer<?>>,GISEditable,GISElement,GISFlagContainer,GISPrimitive,BoundedElement2afp<Rectangle2d>,JsonableObject
- Direct Known Subclasses:
RoadPolyline
public class MapPolyline extends MapComposedElement
Class the permits to display a polyline.- Since:
- 14.0
- Version:
- 17.0 2020-01-04 14:41:53
- Author:
- Stéphane GALLAND
- See Also:
- Serialized Form
- Maven Group Id:
- org.arakhne.afc.gis
- Maven Artifact Id:
- giscore
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.arakhne.afc.gis.mapelement.MapComposedElement
MapComposedElement.PointGroup
-
Nested classes/interfaces inherited from class org.arakhne.afc.gis.mapelement.MapElement
MapElement.VisualizationType
-
-
Field Summary
-
Fields inherited from class org.arakhne.afc.gis.mapelement.MapElement
ATTR_COLOR, ATTR_USE_CONTAINER_COLOR, ATTR_VISUALIZATION_TYPE
-
Fields inherited from interface org.arakhne.afc.gis.primitive.FlagContainer
FLAG_READONLY, FLAG_SELECTED
-
Fields inherited from interface org.arakhne.afc.gis.primitive.GISElement
ATTR_NAME, NAME_COMPARATOR
-
Fields inherited from interface org.arakhne.afc.gis.primitive.GISPrimitive
COMPARATOR
-
-
Constructor Summary
Constructors Constructor Description MapPolyline()Create a new map element.MapPolyline(UUID id)Create a new map element.MapPolyline(UUID id, AttributeCollection attributeSource)Create a new map element.MapPolyline(AttributeCollection attributeSource)Create a new map element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Rectangle2dcalcBounds()Compute the bounds of this element.protected voidcomputeGeoLocationForDistance(double desired_distance, double shifting, Point2D<?,?> geoLocation, Vector2D<?,?> tangent)Replies the geo-location of the point described by the specified distance.doubledistance(Point2D<?,?> point, double width)Replies the distance between this figure and the specified point.doubledistanceToEnd(Point2D<?,?> point)Replies the distance between the nearest end of this MapElement and the point.doubledistanceToEnd(Point2D<?,?> point, double width)Replies the distance between the nearest end of this MapElement and the point.doublegetDistance(Point2D<?,?> point)Replies the distance between this MapElement and point.doublegetLength()Replies the length of this polyline.intgetNearestEndIndex(double x, double y)Replies the index of the nearest end of line according to the specified point.intgetNearestEndIndex(double x, double y, OutputParameter<Double> distance)Replies the index of the nearest end of line according to the specified point.Point1dgetNearestPosition(Point2D<?,?> pos)Return the nearest point 1.5D from a 2D position.Point1dgetNearestPosition(Point2D<?,?> pos, double lateralDistance)Return the nearest point 1.5D from a 2D position.Shape2d<?>getShape()Replies the shape of this this element.Segment1D<?,?>getSubSegmentForDistance(double distance)Replies the subsegment which is corresponding to the given position.doublegetWidth()Returns the poly-element width in the geo-located referencial.booleanintersects(Shape2D<?,?,?,?,?,? extends Rectangle2afp<?,?,?,?,?,?>> rectangle)Replies if this element has an intersection with the specified rectangle.booleanisWidePolyline()Replies if this polyline must be drawn with a wide height.voidresetBoundingBox()Clear the current bounding box to force the computation of it at the next call toAbstractBoundedGISElement.getBoundingBox().voidsetWidePolyline(boolean isWidePolyline)Set if this polyline must be drawn with a wide height.voidtoJson(JsonBuffer buffer)Replies the Json representation of this node.Path2dtoPath2D()Replies the Path2D that corresponds to this polyline.Path2dtoPath2D(double startPosition, double endPosition)Replies the Path2D that corresponds to this polyline.voidtoPath2D(Path2d path)Replies the Path2D that corresponds to this polyline.voidtoPath2D(Path2d path, double startPosition, double endPosition)Replies the Path2D that corresponds to this polyline.protected Segment1D<?,?>toSegment1D()Replies the Segment1D representation of this object.-
Methods inherited from class org.arakhne.afc.gis.mapelement.MapComposedElement
addGroup, addGroup, addPoint, addPoint, addPoint, addPoint, canonize, clear, clone, contains, containsPoint, containsPoint, equals, getFirstPointIndexInGroup, getGeoLocation, getGroupAt, getGroupCount, getLastPointIndexInGroup, getPointAt, getPointAt, getPointCount, getPointCountInGroup, getPointFusionValidator, getPointIndex, getPointIndex, groupIterator, groups, hashCode, insertPointAt, insertPointAt, invert, invertPointsIn, pointIterator, points, removeGroupAt, removePointAt, setPointAt, setPointAt, setPointAt, setPointAt, setPointAt, setPointAt, setPointAt, setPointAt
-
Methods inherited from class org.arakhne.afc.gis.mapelement.MapElement
addGISEditableChangeListener, boundsContains, boundsIntersects, contains, equals, finalize, fireElementChanged, fireGraphicalAttributeChanged, fireShapeChanged, getColor, getFlags, getRawColor, getVisualizationType, hasFlag, isContainerColorUsed, isReadOnlyObject, onAttributeChanged, removeGISEditableChangeListener, setColor, setContainerColorUse, setFlag, setReadOnlyObject, setUUID, setVisualizationType, switchFlag, unsetFlag
-
Methods inherited from class org.arakhne.afc.gis.primitive.AbstractBoundedGISElement
getBoundingBox, setBoundingBox
-
Methods inherited from class org.arakhne.afc.gis.primitive.AbstractGISElement
addAttributeChangeListener, addAttributes, addAttributes, attributes, copyAttributes, flush, freeMemory, getAllAttributeNames, getAllAttributes, getAllAttributesByType, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttributeAsBool, getAttributeAsDate, getAttributeAsDouble, getAttributeAsEnumeration, getAttributeAsEnumeration, getAttributeAsFloat, getAttributeAsInetAddress, getAttributeAsInt, getAttributeAsJavaClass, getAttributeAsLong, getAttributeAsString, getAttributeAsURI, getAttributeAsURL, getAttributeAsUUID, getAttributeCollection, getAttributeCount, getAttributeObject, getAttributeProvider, getContainer, getGeoId, getName, getTopContainer, getUUID, hasAttribute, hashKey, isEventFirable, onAttributeChangeEvent, removeAllAttributes, removeAttribute, removeAttributeChangeListener, renameAttribute, renameAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setAttributes, setAttributeType, setContainer, setEventFirable, setName, toMap, toMap, toString
-
Methods inherited from interface org.arakhne.afc.attrs.collection.AttributeCollection
addAttributeChangeListener, addAttributes, addAttributes, flush, isEventFirable, removeAllAttributes, removeAttribute, removeAttributeChangeListener, renameAttribute, renameAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setAttributes, setAttributeType, setEventFirable
-
Methods inherited from interface org.arakhne.afc.attrs.collection.AttributeProvider
attributes, freeMemory, getAllAttributeNames, getAllAttributes, getAllAttributesByType, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttribute, getAttributeAsBool, getAttributeAsDate, getAttributeAsDouble, getAttributeAsEnumeration, getAttributeAsEnumeration, getAttributeAsFloat, getAttributeAsInetAddress, getAttributeAsInt, getAttributeAsJavaClass, getAttributeAsLong, getAttributeAsString, getAttributeAsURI, getAttributeAsURL, getAttributeAsUUID, getAttributeCount, getAttributeObject, hasAttribute, toMap, toMap
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISContentElement
getContainer, getTopContainer, setContainer
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISEditable
getName, setName
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISElement
copyAttributes, getName, hashKey, setName
-
Methods inherited from interface org.arakhne.afc.gis.primitive.GISPrimitive
getGeoId, getUUID
-
-
-
-
Constructor Detail
-
MapPolyline
public MapPolyline()
Create a new map element.
-
MapPolyline
public MapPolyline(AttributeCollection attributeSource)
Create a new map element.- Parameters:
attributeSource- is the source of the attributes for this map element.
-
MapPolyline
public MapPolyline(UUID id)
Create a new map element.- Parameters:
id- is the unique identifier of this element, ornullif unknown.- Since:
- 4.0
-
MapPolyline
public MapPolyline(UUID id, AttributeCollection attributeSource)
Create a new map element.- Parameters:
id- is the unique identifier of this element, ornullif unknown.attributeSource- is the source of the attributes for this map element.- Since:
- 4.0
-
-
Method Detail
-
toJson
@Pure public void toJson(JsonBuffer buffer)
Description copied from interface:JsonableObjectReplies the Json representation of this node.- Specified by:
toJsonin interfaceJsonableObject- Overrides:
toJsonin classMapComposedElement- Parameters:
buffer- the Json buffer.
-
setWidePolyline
public void setWidePolyline(boolean isWidePolyline)
Set if this polyline must be drawn with a wide height.- Parameters:
isWidePolyline- istrueif this polyline must have a wide height, otherwisefalse
-
isWidePolyline
@Pure public boolean isWidePolyline()
Replies if this polyline must be drawn with a wide height.- Returns:
trueif this polyline must have a wide height, otherwisefalse
-
getDistance
@Pure public final double getDistance(Point2D<?,?> point)
Replies the distance between this MapElement and point.- Specified by:
getDistancein classMapElement- Parameters:
point- the point to compute the distance to.- Returns:
- the distance. Should be negative depending of the MapElement type.
-
distance
@Pure public double distance(Point2D<?,?> point, double width)
Replies the distance between this figure and the specified point.- Parameters:
point- is the x-coordinate of the point.width- is the width of the polyline.- Returns:
- the computed distance; the distance could be negative if the point lies on the polyline shape (if the polyline has wide width).
-
distanceToEnd
@Pure public final double distanceToEnd(Point2D<?,?> point)
Replies the distance between the nearest end of this MapElement and the point.- Parameters:
point- the point.- Returns:
- the distance. Should be negative depending of the MapElement type.
-
distanceToEnd
@Pure public double distanceToEnd(Point2D<?,?> point, double width)
Replies the distance between the nearest end of this MapElement and the point.- Parameters:
point- is the x-coordinate of the point.width- is the width of the polyline.- Returns:
- the computed distance
-
getNearestEndIndex
@Pure public final int getNearestEndIndex(double x, double y)Replies the index of the nearest end of line according to the specified point.- Parameters:
x- x coordinatey- y coordinate- Returns:
- index of the nearest end point.
-
getNearestEndIndex
@Pure public final int getNearestEndIndex(double x, double y, OutputParameter<Double> distance)Replies the index of the nearest end of line according to the specified point.- Parameters:
x- is the point coordinate from which the distance must be computedy- is the point coordinate from which the distance must be computeddistance- is the distance value that will be set by this function (if the parameter is notnull).- Returns:
- index of the nearest end point.
-
getNearestPosition
@Pure public Point1d getNearestPosition(Point2D<?,?> pos)
Return the nearest point 1.5D from a 2D position.- Parameters:
pos- is the testing position.- Returns:
- the nearest 1.5D position on the polyline.
- See Also:
getNearestPosition(Point2D, double)
-
getNearestPosition
@Pure public Point1d getNearestPosition(Point2D<?,?> pos, double lateralDistance)
Return the nearest point 1.5D from a 2D position.- Parameters:
pos- is the testing position.lateralDistance- the lateral distance to put into the point. The sign of the given value is ignored. The replied pointpwill have a lateral distance such thatabs(lateralDistance) == abs(p.getLateralDistance()).- Returns:
- the nearest 1.5D position on the polyline.
- Since:
- 16.0
- See Also:
getNearestPosition(Point2D)
-
resetBoundingBox
public void resetBoundingBox()
Clear the current bounding box to force the computation of it at the next call toAbstractBoundedGISElement.getBoundingBox().- Specified by:
resetBoundingBoxin interfaceBoundedGISElement- Overrides:
resetBoundingBoxin classMapElement
-
getLength
@Pure public double getLength()
Replies the length of this polyline. The length is the distance between first point and the last point of the polyline.The returned value is the sum of the lengths of the polyline' groups that compose this polyline.
- Returns:
- the length of the segment in meters.
-
getSubSegmentForDistance
@Pure public Segment1D<?,?> getSubSegmentForDistance(double distance)
Replies the subsegment which is corresponding to the given position.A subsegment is a pair if connected points in the polyline.
- Parameters:
distance- is position on the polyline (in0togetLength()).- Returns:
- the point pair, never
null.
-
getWidth
@Pure public double getWidth()
Returns the poly-element width in the geo-located referencial. The width is the distance between the border lines of the polyline.The implementation provided by the MapPolyline class always replies 1 meter. The function
getWidth()must be overrided to provide other way to compute the width the polyelements.- Returns:
- the width of the poly-element in meters.
-
intersects
@Pure public boolean intersects(Shape2D<?,?,?,?,?,? extends Rectangle2afp<?,?,?,?,?,?>> rectangle)
Replies if this element has an intersection with the specified rectangle.- Specified by:
intersectsin classMapElement- Parameters:
rectangle- the rectangle- Returns:
trueif this MapElement is intersecting the specified area, otherwisefalse
-
getShape
public Shape2d<?> getShape()
Description copied from interface:BoundedGISElementReplies the shape of this this element.The bounding box replied by
BoundedElement2afp.getBoundingBox()encloses the replied shape.- Returns:
- the shape or
nullif not applicable.
-
toPath2D
@Pure public final Path2d toPath2D()
Replies the Path2D that corresponds to this polyline.- Returns:
- the 2D path.
-
toPath2D
@Pure public final void toPath2D(Path2d path)
Replies the Path2D that corresponds to this polyline.- Parameters:
path- the 2D path to update.
-
toPath2D
@Pure public final Path2d toPath2D(double startPosition, double endPosition)
Replies the Path2D that corresponds to this polyline. If startPosition is greater to zero, the replied path will be clipped to ignore the part of the polyline before the given value. If endPosition is lower to the length of the polyline, the replied path will be clipped to ignore the part of the polyline after the given value.- Parameters:
startPosition- is the curviline position from which the polyline is drawn.endPosition- is the curviline position to which the polyline is drawn.- Returns:
- the clipped 2D path.
- Since:
- 4.0
-
toPath2D
@Pure public final void toPath2D(Path2d path, double startPosition, double endPosition)
Replies the Path2D that corresponds to this polyline. If startPosition is greater to zero, the replied path will be clipped to ignore the part of the polyline before the given value. If endPosition is lower to the length of the polyline, the replied path will be clipped to ignore the part of the polyline after the given value.- Parameters:
path- the path to fill out.startPosition- is the curviline position from which the polyline is drawn.endPosition- is the curviline position to which the polyline is drawn.- Since:
- 4.0
-
calcBounds
@Pure protected Rectangle2d calcBounds()
Compute the bounds of this element. This function does not update the internal attribute replied byAbstractBoundedGISElement.getBoundingBox()- Overrides:
calcBoundsin classMapComposedElement- Returns:
- the bounds
-
toSegment1D
@Pure protected Segment1D<?,?> toSegment1D()
Replies the Segment1D representation of this object.- Returns:
- the Segment1D, never
null. - Since:
- 4.0
-
computeGeoLocationForDistance
protected final void computeGeoLocationForDistance(double desired_distance, double shifting, Point2D<?,?> geoLocation, Vector2D<?,?> tangent)Replies the geo-location of the point described by the specified distance. The desired distance is0for the starting point andgetLength()for the ending point.- Parameters:
desired_distance- is the distance for which the geo location must be computed.shifting- is the shifting distance.geoLocation- is the point to set with geo-localized coordinates.tangent- is the vector which will be set by the coordinates of the tangent at the replied point. Ifnullthe tangent will not be computed.
-
-