Class MapPointItem
- All Implemented Interfaces:
IFeedbackProvider,IDrawable,EventListener
- Direct Known Subclasses:
MapMilSymbolItem
Use cases
Cities, airports, GPS waypoints, observation stations, or any location marker that should remain at the same geographic position when the projection changes.
Rendering
On each draw, the geographic location is projected through the active
IMapProjection to device pixels.
If the point is on the far side of the globe (non-finite projection result,
e.g. orthographic back-hemisphere), the item is not drawn.
The item can display either an ImageIcon or a symbol from
SymbolType, controlled by the style.
Alignment for icon drawing follows SwingUtilities constants
(LEFT/CENTER/RIGHT horizontally, TOP/CENTER/BOTTOM vertically).
Interaction
- Drag — moves the geographic location by the screen-space delta converted through the map projection. Unlike the raw lon/lat delta used by multi-point items, this conversion is exact at all latitudes because both the start and current pixel positions are independently inverse-projected to geographic coordinates.
- Resize / Rotate — not applicable to a point; silently ignored.
Focus
The AItem._focus field holds the geographic location directly
(x = longitude, y = latitude in radians). AMapItem.getFocusPoint(edu.cnu.mdi.container.IContainer)
handles the projection to device pixels.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ImageIconOptional icon to display instead of a symbol.Fields 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
ConstructorsConstructorDescriptionMapPointItem(Layer layer) Creates an unplaced map point item.MapPointItem(Layer layer, Point2D.Double location) Creates a map point item at the given geographic location.MapPointItem(Layer layer, Point2D.Double location, Object... keyVals) Creates a map point item at the given geographic location, with optional property key/value pairs.MapPointItem(Layer layer, Point2D.Double location, ImageIcon icon) Creates a map point item that displays an icon. -
Method Summary
Modifier and TypeMethodDescriptionvoiddrawItem(Graphics2D g2, IContainer container) Draws the point at its projected screen location.intintgetBounds(IContainer container) Returns the device-space bounding rectangle for this point item.voidgetFeedbackStrings(IContainer container, Point pp, Point2D.Double wp, List<String> feedbackStrings) Populate the feedback string list with information about this item.Return the world-coordinate bounding rectangle of this item.voidmodify()Update this item's geometry in response to a mouse movement during an active modification.voidsetAlignmentH(int xAlignment) voidsetAlignmentV(int yAlignment) voidsetFocus(Point2D.Double location) Set the world-coordinate focus of this item.booleanshouldDraw(Graphics2D g2, IContainer container) Returntrueif this item should be drawn on the current frame.voidClassify and begin a drag, resize, or rotate modification.voidtranslateWorld(double dx, double dy) Translate this item by(dx, dy)in world coordinates.Methods inherited from class edu.cnu.mdi.mapping.item.AMapItem
getFocusPoint, updateFocusMethods inherited from class edu.cnu.mdi.item.AItem
acceptModification, applyGeometryProperties, applyProperties, applyStyleProperties, contains, createPopupMenu, doubleClicked, draw, drawSelections, enclosed, equals, focusFill, geometryChanged, getAzimuth, getContainer, getDisplayName, getFocus, getItemModification, getLastDrawnPolygon, getLayer, getLine, getPath, getPopupMenu, getResizePolicy, getRotatePoint, getSelectionPoints, getStyle, getStyleSafe, getView, hashCode, inASelectRect, inRotatePoint, inSelectPoint, isConnectable, isDeletable, isDirty, isDoubleClickable, isDraggable, isEnabled, isLocked, isResizable, isRightClickable, isRotatable, isSelectable, isSelected, isStyleEditable, isTrackable, isVisible, modificationRejected, prepareForPopup, prepareForRemoval, setAzimuth, setConnectable, setDeletable, setDirty, setDisplayName, setDoubleClickable, setDraggable, setEnabled, setFillFocus, setLocked, setModification, setResizable, setResizePolicy, setRightClickable, setRotatable, setSelectable, setSelected, setStyle, setStyleEditable, setVisible, stopModification, translateLocal
-
Field Details
-
icon
Optional icon to display instead of a symbol. When non-null, icon drawing takes precedence over the style'sSymbolType.
-
-
Constructor Details
-
MapPointItem
Creates an unplaced map point item. The focus is initialised to (Double.NaN,Double.NaN); callsetFocus(java.awt.geom.Point2D.Double)before the item is drawn.- Parameters:
layer- the layer; must not benull
-
MapPointItem
Creates a map point item at the given geographic location.- Parameters:
layer- the layer; must not benulllocation- geographic location in radians (x = longitude, y = latitude)
-
MapPointItem
Creates a map point item at the given geographic location, with optional property key/value pairs.- Parameters:
layer- the layer; must not benulllocation- geographic location in radianskeyVals- optionalPropertyUtilskey/value pairs
-
MapPointItem
Creates a map point item that displays an icon.- Parameters:
layer- the layer; must not benulllocation- geographic location in radiansicon- the icon to display; ifnullthe style symbol is used
-
-
Method Details
-
drawItem
Draws the point at its projected screen location.The item is not drawn if the focus is unplaced (NaN) or projects to a non-finite coordinate. Icon drawing takes priority over symbol drawing.
- Specified by:
drawItemin classAItem- Parameters:
g2- the graphics contextcontainer- the rendering container; must be aMapContainer
-
shouldDraw
Returntrueif this item should be drawn on the current frame.This is a secondary visibility check beyond the simple
AItem._visibleflag. A typical implementation checks whether the item's screen bounds intersect the current clip rectangle.Returns
falseif the focus is unplaced or the projected bounds do not intersect the visible component area.- Specified by:
shouldDrawin classAItem- Parameters:
g2- the graphics context (may be used to read clip bounds)container- the container being rendered- Returns:
trueifAItem.drawItem(java.awt.Graphics2D, edu.cnu.mdi.container.IContainer)should be called
-
getBounds
Returns the device-space bounding rectangle for this point item.For icon items: the rectangle is positioned according to the alignment settings. For symbol items: a square of size
style.getSymbolSize()centred on the focus point.Returns
nullif the focus is unplaced or off-map. -
getWorldBounds
Return the world-coordinate bounding rectangle of this item.Returns a
nullworld bounding rectangle — a geographic point has no extent in world space.- Specified by:
getWorldBoundsin classAItem- Returns:
- the world-coordinate bounding rectangle
-
startModification
public void startModification()Classify and begin a drag, resize, or rotate modification.Priority: rotate (if start point is in rotation handle) → resize (if start point is in a selection handle) → drag (otherwise).
This method is a no-op if
AItem._modificationisnull.Records the geographic start location so drag can compute an absolute delta from the snapshot rather than accumulating incremental moves.
- Overrides:
startModificationin classAItem
-
modify
public void modify()Update this item's geometry in response to a mouse movement during an active modification.Called repeatedly while the user is dragging, resizing, or rotating. The current mouse position is available through
AItem._modification.DRAG: converts the start and current mouse positions independently to geographic coordinates and moves the focus by the difference. This gives an exact result at all latitudes — no raw lon/lat approximation.
RESIZE / ROTATE: silently ignored for a point item.
-
setFocus
Set the world-coordinate focus of this item.Stores the geographic location directly, with NaN used to represent an unplaced item.
-
translateWorld
public void translateWorld(double dx, double dy) Translate this item by(dx, dy)in world coordinates.Adds the lon/lat offset to the stored geographic location. A no-op if the focus is unplaced (NaN) or the delta is negligible.
- Specified by:
translateWorldin classAItem- Parameters:
dx- the world-coordinate offset along the X axisdy- the world-coordinate offset along the Y axis
-
getFeedbackStrings
public void getFeedbackStrings(IContainer container, Point pp, Point2D.Double wp, List<String> feedbackStrings) Populate the feedback string list with information about this item. The default implementation is a no-op.Reports the geographic coordinates of this point when the cursor is near it.
- Specified by:
getFeedbackStringsin interfaceIFeedbackProvider- Overrides:
getFeedbackStringsin classAItem- Parameters:
container- the container rendering this itempp- the current mouse position in screen coordinateswp- the corresponding world-coordinate positionfeedbackStrings- the list to add strings to
-
getAlignmentH
public int getAlignmentH()- Returns:
- horizontal alignment for icon drawing
(
SwingConstants.LEFT,SwingConstants.CENTER, orSwingConstants.RIGHT)
-
setAlignmentH
public void setAlignmentH(int xAlignment) - Parameters:
xAlignment- horizontal alignment constant fromSwingUtilities
-
getAlignmentV
public int getAlignmentV()- Returns:
- vertical alignment for icon drawing
(
SwingConstants.TOP,SwingConstants.CENTER, orSwingConstants.BOTTOM)
-
setAlignmentV
public void setAlignmentV(int yAlignment) - Parameters:
yAlignment- vertical alignment constant fromSwingUtilities
-