Class AbstractBoardViewOverlay

java.lang.Object
megamek.client.ui.clientGUI.boardview.overlay.AbstractBoardViewOverlay
All Implemented Interfaces:
IDisplayable, IPreferenceChangeListener
Direct Known Subclasses:
KeyBindingsOverlay, PlanetaryConditionsOverlay, TurnDetailsOverlay

public abstract class AbstractBoardViewOverlay extends Object implements IDisplayable, IPreferenceChangeListener
This is a framework for boardview overlays that can show a list of data, conditions etc.
  • Field Details

    • clientGui

      protected final ClientGUI clientGui
      The ClientGUI of the boardview. May be null!
    • GUIP

      protected static final GUIPreferences GUIP
    • boardView

      protected final BoardView boardView
    • currentPhase

      protected GamePhase currentPhase
      The current game phase.
    • currentGame

      protected final Game currentGame
    • font

      protected final Font font
  • Constructor Details

    • AbstractBoardViewOverlay

      public AbstractBoardViewOverlay(BoardView boardView, Font font)
  • Method Details

    • addHeader

      protected void addHeader(List<String> lines)
    • getHeaderText

      protected abstract String getHeaderText()
      Override to return the localized header text, possibly including the current keyboard shortcut to toggle it.
    • draw

      public void draw(Graphics graph, Rectangle clipBounds)
      Description copied from interface: IDisplayable
      Draw this IDisplayable to the Graphics graph, which is the BoardView graphics. The currently visible part of the BoardView is given by the Rectangle rect, so the upper left corner of the visible BoardView is rect.x, rect.y.
      Specified by:
      draw in interface IDisplayable
    • assembleTextLines

      protected abstract List<String> assembleTextLines()
      Override to return a List of all text lines to be shown. Use addHeader(List).
    • setVisible

      public void setVisible(boolean vis)
      Activates or deactivates the overlay, fading it in or out. Also saves the visibility to the GUIPreferences so MegaMek remembers it.
    • isVisible

      public boolean isVisible()
    • isSliding

      public boolean isSliding()
      Description copied from interface: IDisplayable
      Return true while sliding. "Sliding" means that this IDisplayable is in the process of opening, closing moving or fading. The BoardView will repaint at some fps while an IDisplayable is sliding. The default for this method will always return false.
      Specified by:
      isSliding in interface IDisplayable
    • slide

      public boolean slide()
      Description copied from interface: IDisplayable
      Conducts a frame update when sliding. "Sliding" means that this IDisplayable is in the process of opening, closing moving or fading. The BoardView will repaint at some fps while an IDisplayable is sliding. Return true as long as the slide process is not finished. See ChatterBox2 and KeyBindingsOverlay for examples. The default for this method will always return false.
      Specified by:
      slide in interface IDisplayable
    • setDirty

      protected void setDirty()
    • gameTurnOrPhaseChange

      protected void gameTurnOrPhaseChange()
    • getTextColor

      public static Color getTextColor()
    • getVisibilityGUIPreference

      protected abstract boolean getVisibilityGUIPreference()
    • getDistTop

      protected abstract int getDistTop(Rectangle clipBounds, int overlayHeight)
    • getDistSide

      protected abstract int getDistSide(Rectangle clipBounds, int overlayWidth)
    • colorToHex

      public static String colorToHex(Color color)
    • colorToHex

      public static String colorToHex(Color color, float brightnessMultiplier)
    • preferenceChange

      public void preferenceChange(PreferenceChangeEvent e)
      Specified by:
      preferenceChange in interface IPreferenceChangeListener
    • scheduleBoardViewRepaint

      protected void scheduleBoardViewRepaint()
      Makes the BoardView redraw, updating the overlay in the process.