Class MapControlPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class MapControlPanel extends JPanel
Side-panel control widget for MapView2D.

Provides interactive controls for:

  • Projection — a factory-backed selector containing MDI's built-ins and projections registered through addProjection(String, Function).
  • Map theme — radio buttons selecting between the built-in MapTheme presets (Light, Dark, Blue).
  • Application controls — components registered through addControl(JComponent) and displayed below the standard controls.

Coupling

This panel holds a direct reference to a MapView2D and calls its public API in response to user interaction. The coupling is intentional and kept minimal: the panel only calls well-defined accessors on the view (MapView2D.getMapProjection(), MapView2D.setProjection(IMapProjection), BaseView.refresh()).

See Also:
  • Constructor Details

    • MapControlPanel

      public MapControlPanel(MapView2D mapView)
      Creates a control panel bound to the given map view.
      Parameters:
      mapView - the view to control; must not be null
  • Method Details

    • addProjection

      public void addProjection(String name, Function<MapTheme,? extends IMapProjection> factory)
      Adds an application-supplied projection to the standard selector.

      The factory receives the currently selected theme whenever its entry is chosen. Applications can therefore expose custom projections without replacing the rest of the map control panel.

      Parameters:
      name - display name; must not be blank or duplicate an existing name
      factory - factory receiving the active theme; must return a non-null projection
      Throws:
      IllegalArgumentException - if the name is blank or already present
    • addControl

      public void addControl(JComponent control)
      Adds an application-supplied component below the standard projection and theme controls.

      Controls appear in registration order. This method supplies standard vertical spacing, left alignment, layout validation, and repainting so callers do not need to depend on this panel's Swing layout details. Adding the same component more than once is an idempotent no-op.

      As with other Swing component mutations, callers should invoke this method on the event-dispatch thread.

      Parameters:
      control - component to add; must not be null
      Throws:
      NullPointerException - if control is null
    • getCurrentTheme

      public MapTheme getCurrentTheme()
      Returns the MapTheme currently selected by the theme radio buttons.

      Called by MapView2D.setProjection(EProjection) so that a newly constructed projection can be initialized with the theme the user has already selected.

      Returns:
      the currently active theme; never null