Class MapContainer

All Implemented Interfaces:
IContainer, HoverListener, ItemChangeListener, ImageObserver, MenuContainer, Serializable, EventListener

public class MapContainer extends BaseContainer
Map-specific container supporting projection-aware recentering, geographic coordinate conversion, country-name hover popups, and drag-and-drop placement of military symbols.
See Also:
  • Constructor Details

    • MapContainer

      public MapContainer(Rectangle2D.Double worldSystem)
      Creates a map container with the given initial world coordinate system.
      Parameters:
      worldSystem - the initial world coordinate rectangle
  • Method Details

    • zoomLatLon

      public void zoomLatLon(double minLat, double maxLat, double minLon, double maxLon)
      Zooms to a geographic bounding box expressed in decimal degrees.

      The corner coordinates are projected with the active map projection and used to replace the container's world-coordinate bounds.

      Parameters:
      minLat - minimum latitude in degrees
      maxLat - maximum latitude in degrees
      minLon - minimum longitude in degrees
      maxLon - maximum longitude in degrees
    • recenter

      public void recenter(Point pp)
      Recenters the active projection on the geographic location beneath a screen-space point.

      Clicks that cannot be converted to finite geographic coordinates, or projections that do not support recentering, are ignored.

      Specified by:
      recenter in interface IContainer
      Overrides:
      recenter in class BaseContainer
      Parameters:
      pp - point in container coordinates; may be null
    • localToLatLon

      public void localToLatLon(Point pp, Point2D.Double ll)
      Converts a screen-space point to geographic lon/lat in radians.
      Parameters:
      pp - screen-space point
      ll - A geographic point is represented as a Point2D.Double where x = λ (longitude) and y = φ (latitude).
    • latLonToLocal

      public void latLonToLocal(Point pp, Point2D.Double ll)
      Converts geographic lon/lat in radians to screen-space coordinates.
      Parameters:
      pp - output screen-space point
      ll - A geographic point is represented as a Point2D.Double where x = λ (longitude) and y = φ (latitude) in radians.
    • worldToLatLon

      public void worldToLatLon(Point2D.Double ll, Point2D.Double wp)
      Converts projection world coordinates to geographic lon/lat.
      Parameters:
      ll - A geographic point is represented as a Point2D.Double where x = λ (longitude) and y = φ (latitude).
      wp - input world point
    • updateStatusText

      public void updateStatusText(Point pp, Point2D.Double wp)
      Update the toolbar status text with the current mouse location.
      Specified by:
      updateStatusText in interface IContainer
      Overrides:
      updateStatusText in class BaseContainer
      Parameters:
      pp - the current mouse location in local (screen) coordinates
      wp - the current mouse location in world coordinates
    • formatElevationStatus

      public static String formatElevationStatus(double elevationMeters, boolean onLand)
      Formats the elevation status string for display in the toolbar.
      Parameters:
      elevationMeters - the elevation in meters
      onLand - true if the point is on land, false if over water
      Returns:
      a formatted string representing the elevation or depth
    • feedbackTrigger

      public void feedbackTrigger(MouseEvent mouseEvent, boolean dragging)
      Convenience method to update the location string in the toolbar.

      Updates the toolbar status text (if present) and feedback control (if present) with the current mouse location in both local and world coordinates.

      Specified by:
      feedbackTrigger in interface IContainer
      Overrides:
      feedbackTrigger in class BaseContainer
      Parameters:
      mouseEvent - the causal event.
      dragging - true if we are dragging
    • createToolHandler

      protected BaseToolHandler createToolHandler()
      Factory method that creates the BaseToolHandler appropriate for this container.

      The default implementation returns a plain BaseToolHandler. Subclasses that require specialised tool behaviour (e.g. MapContainer) should override this method to return their own handler rather than relying on an instanceof check in BaseContainer.setToolBar(edu.cnu.mdi.graphics.toolbar.AToolBar).

      Overrides:
      createToolHandler in class BaseContainer
      Returns:
      a new tool handler bound to this container; never null