Class MapPolylineItem
- All Implemented Interfaces:
IFeedbackProvider,IDrawable,EventListener
Use cases
Flight routes, ship tracks, hiking trails, pipeline routes, or any sequence of waypoints that should follow the surface of the Earth rather than a straight line in projection space.
Geometry
Each edge between adjacent vertices is sampled as a great-circle arc by
MapGraphics, which handles seam splitting automatically for global
projections. The polyline is open: the last vertex is not connected back to
the first. To create a closed shape use MapPolygonItem.
Interaction
- Drag — moves all vertices by the geographic delta of the mouse.
- Resize — moves the grabbed handle vertex to the cursor.
- Rotate — not supported (see
AMapMultiPointItemclass doc).
Creation
Typically created by MapToolHandler from
a polyline rubberband gesture:
Point2D.Double[] latLons = ...; // convert screen vertices to geographic
MapPolylineItem item = new MapPolylineItem(layer, latLons);
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.cnu.mdi.mapping.item.AMapMultiPointItem
AMapMultiPointItem.MultiPointStartState -
Field Summary
Fields inherited from class edu.cnu.mdi.mapping.item.AMapMultiPointItem
_latLons, _projectedShapeFields inherited from class edu.cnu.mdi.item.AItem
_connectable, _deletable, _dirty, _displayName, _doubleClickable, _draggable, _enabled, _focus, _FOCUSFILL, _lastDrawnPolygon, _layer, _line, _locked, _modification, _path, _popupMenu, _resizable, _resizePolicy, _rightClickable, _rotatable, _selectable, _selected, _style, _styleEditable, _visible, rotateIcon, RPSIZE, RPSIZE2, SPSIZE, SPSIZE2 -
Constructor Summary
ConstructorsConstructorDescriptionMapPolylineItem(Layer layer, Point2D.Double[] latLons) Creates a map-native great-circle polyline.MapPolylineItem(Layer layer, Point2D.Double[] latLons, Object... keyVals) Creates a map-native great-circle polyline with optional property key/value pairs. -
Method Summary
Modifier and TypeMethodDescriptionprotected MapGraphics.ProjectedMapShapeBuild the projected shape from the current vertices.protected booleancontainsPoint(MapGraphics.ProjectedMapShape shape, Point screenPoint) Tests whether a screen point hits the projected shape.voiddrawItem(Graphics2D g2, IContainer container) Draws each edge as a seam-aware great-circle arc and caches the projected shape for subsequent hit-testing and bounds queries.Methods inherited from class edu.cnu.mdi.mapping.item.AMapMultiPointItem
contains, copyVertices, ensureProjectedShape, getBounds, getFeedbackStrings, getLatLons, getSelectionPoints, getVertexCount, getWorldBounds, localToLatLon, modify, prepareForRemoval, projectLatLon, setDirty, setLatLons, shouldDraw, startModification, translateWorld, updateFocusMethods inherited from class edu.cnu.mdi.mapping.item.AMapItem
getFocusPointMethods inherited from class edu.cnu.mdi.item.AItem
acceptModification, applyGeometryProperties, applyProperties, applyStyleProperties, createPopupMenu, doubleClicked, draw, drawSelections, enclosed, equals, focusFill, geometryChanged, getAzimuth, getContainer, getDisplayName, getFocus, getItemModification, getLastDrawnPolygon, getLayer, getLine, getPath, getPopupMenu, getResizePolicy, getRotatePoint, getStyle, getStyleSafe, getView, hashCode, inASelectRect, inRotatePoint, inSelectPoint, isConnectable, isDeletable, isDirty, isDoubleClickable, isDraggable, isEnabled, isLocked, isResizable, isRightClickable, isRotatable, isSelectable, isSelected, isStyleEditable, isTrackable, isVisible, modificationRejected, prepareForPopup, setAzimuth, setConnectable, setDeletable, setDisplayName, setDoubleClickable, setDraggable, setEnabled, setFillFocus, setFocus, setLocked, setModification, setResizable, setResizePolicy, setRightClickable, setRotatable, setSelectable, setSelected, setStyle, setStyleEditable, setVisible, stopModification, translateLocal
-
Constructor Details
-
MapPolylineItem
Creates a map-native great-circle polyline.- Parameters:
layer- the layer this item lives on; must not benulllatLons- geographic vertices in radians (x = longitude, y = latitude); must not benull, length ≥ 2
-
MapPolylineItem
Creates a map-native great-circle polyline with optional property key/value pairs.- Parameters:
layer- the layer this item lives on; must not benulllatLons- geographic vertices in radians; must not benull, length ≥ 2keyVals- optionalPropertyUtilskey/value pairs
-
-
Method Details
-
drawItem
Draws each edge as a seam-aware great-circle arc and caches the projected shape for subsequent hit-testing and bounds queries.- Specified by:
drawItemin classAItem- Parameters:
g2- the graphics contextcontainer- the rendering container; must be aMapContainer
-
buildShape
Build the projected shape from the current vertices.Use
MapGraphics.buildProjectedPolyline(edu.cnu.mdi.mapping.container.MapContainer, java.awt.geom.Point2D.Double[])for open items,MapGraphics.buildProjectedPolygon(edu.cnu.mdi.mapping.container.MapContainer, java.awt.geom.Point2D.Double[])for closed items.Builds an open (polyline) projected shape.
- Specified by:
buildShapein classAMapMultiPointItem- Parameters:
mc- the owning map container- Returns:
- projected shape; never
null
-
containsPoint
Description copied from class:AMapMultiPointItemTests whether a screen point hits the projected shape.Default: 6-pixel proximity (correct for open polylines).
MapPolygonItemoverrides to also test interior containment.- Overrides:
containsPointin classAMapMultiPointItem- Parameters:
shape- projected shape (may benull)screenPoint- device-space test point- Returns:
trueif the point hits the shape
-