Class MapControls

  • Direct Known Subclasses:
    ClassicMapControls, CornerMapControls

    public abstract class MapControls
    extends FreeColClientHolder
    A collection of panels and buttons that are used to provide the user with a more detailed view of certain elements on the map and also to provide a means of input in case the user can't use the keyboard.
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • infoPanel

        protected final InfoPanel infoPanel
        The info panel, showing current active unit et al.
      • miniMap

        protected final MiniMap miniMap
        The mini map, showing the whole of map context.
      • miniMapToggleBorders

        protected final UnitButton miniMapToggleBorders
        Special purpose buttons for the mini map.
      • miniMapToggleFogOfWarButton

        protected final UnitButton miniMapToggleFogOfWarButton
        Special purpose buttons for the mini map.
      • miniMapZoomOutButton

        protected final UnitButton miniMapZoomOutButton
        Special purpose buttons for the mini map.
      • miniMapZoomInButton

        protected final UnitButton miniMapZoomInButton
        Special purpose buttons for the mini map.
      • unitButtons

        protected final java.util.List<UnitButton> unitButtons
        The buttons to control unit actions.
    • Constructor Detail

      • MapControls

        protected MapControls​(FreeColClient freeColClient,
                              boolean useSkin)
        The basic constructor.
        Parameters:
        freeColClient - The FreeColClient for the game.
        useSkin - Use a skin or not in the info panel.
    • Method Detail

      • updateLayoutIfNeeded

        public void updateLayoutIfNeeded()
        Updates the layout with possibly a new skin and/or size.
      • initializeUnitButtons

        protected boolean initializeUnitButtons()
        Initialize the unit buttons. Initialization is deferred until in-game and the action manager is available.
        Returns:
        True if initialization occurs.
      • getComponentsToAdd

        public abstract java.util.List<java.awt.Component> getComponentsToAdd​(java.awt.Dimension size)
        Prepare and return a list of map controls components to add to the canvas.
        Parameters:
        size - The Dimension of the canvas.
        Returns:
        A list of Components to add to the canvas.
      • getComponentsPresent

        public abstract java.util.List<java.awt.Component> getComponentsPresent()
        Prepare and return a list of map controls components to remove from the canvas.
        Returns:
        A list of Components to remove from the canvas.
      • canZoomInMapControls

        public boolean canZoomInMapControls()
      • canZoomOutMapControls

        public boolean canZoomOutMapControls()
      • repaint

        public void repaint()
      • update

        public void update​(GUI.ViewMode viewMode,
                           Unit active,
                           Tile tile)
        Updates this MapControls.
        Parameters:
        viewMode - The gui ViewMode.
        active - The active Unit if any.
        tile - The selected Tile if any.
      • zoomIn

        public void zoomIn()
      • zoomOut

        public void zoomOut()
      • newInstance

        public static MapControls newInstance​(FreeColClient freeColClient)
        Create a new map controls instance for a FreeColClient.
        Parameters:
        freeColClient - The FreeColClient to query.
        Returns:
        A new MapControls or null on error.