Interface IBoardView

All Known Implementing Classes:
AbstractBoardView, BoardView

public interface IBoardView
  • Method Details

    • draw

      void draw(Graphics graphics)
      This method should be overridden to do the actual drawing of the board image into the provided Graphics.
      Parameters:
      graphics - The Graphics object to draw the board onto
    • zoomOut

      void zoomOut()
      Zooms out the board (shows more of it at smaller size), if the minimum zoom has not been reached already.
    • zoomIn

      void zoomIn()
      Zooms in the board (shows less of it at bigger size), if the maximum zoom has not been reached already.
    • zoomOverviewToggle

      void zoomOverviewToggle()
      Toggles between two Zoom levels.
    • getBoardSize

      Dimension getBoardSize()
      Returns the pixel size of the entire board if drawn at the current zoom level. This should not include any padding, just the board itself.
      Returns:
      The pixel size of the entire board at the current zoom level
    • getComponent

      Component getComponent()
      Returns:
      a JScrollPane containing the board's panel.
    • setDisplayInvalidFields

      void setDisplayInvalidFields(boolean displayInvalidFields)
      Sets this BoardView to show or hide a warning in fields (hexes) that contain invalid information such as terrains that cannot be used together in a single hex. Usually this warning is shown in the board editor but not in a game.
      Parameters:
      displayInvalidFields - True when the invalid marker should be shown
    • displayInvalidFields

      default boolean displayInvalidFields()
    • setLocalPlayer

      void setLocalPlayer(int playerId)
      Sets the BoardView to use the given player ID as the player in whose client this BoardView is shown. This may affect what is shown and what is hidden in this BoardView; it will also affect what is considered an enemy and ally.
      Parameters:
      playerId - The local player's ID as stored in the game.
    • getLocalPlayer

      Player getLocalPlayer()
    • dispose

      void dispose()
      Frees the resources this BoardView uses and removes listeners. Call when this BoardView is not used anymore. The BoardView will no longer be functional after calling this method. When overriding this method, include a call to super.dispose().
    • setUseLosTool

      void setUseLosTool(boolean useLosTool)
    • getPanel

      JPanel getPanel()
      Returns:
      The JPanel that contains this BoardView.
    • addBoardViewListener

      void addBoardViewListener(BoardViewListener listener)
      Adds the specified board listener to receive board events from this board.
      Parameters:
      listener - the board listener.
    • removeBoardViewListener

      void removeBoardViewListener(BoardViewListener listener)
      Removes the specified board listener.
      Parameters:
      listener - the board listener.
    • addOverlay

      void addOverlay(IDisplayable overlay)
      Adds the given overlay to this BoardView. Overlays are displayed above the actual board and fixed with respect to the screen, like the chatbox or unit overview.
      Parameters:
      overlay - The overlay to add
    • removeOverlay

      void removeOverlay(IDisplayable overlay)
      Removes the given overlay from this BoardView.
      Parameters:
      overlay - The overlay to add
      See Also:
    • refreshDisplayables

      default void refreshDisplayables()
    • getEntireBoardImage

      RenderedImage getEntireBoardImage(boolean hideUnits, boolean useBaseZoom)
      Returns an image of the entire board. Depending on parameters, the board may contain any currently present units or other game objects, and it may be drawn at zoom 1 or the current zoom level.
      Parameters:
      hideUnits - If true, no units are drawn, only the board
      useBaseZoom - If true, zoom = 1 is used, otherwise the current board zoom
      Returns:
      an image of the whole board
    • centerOnHex

      void centerOnHex(Coords coords)
      Notifies this BoardView to center itself on the given Coords. Override this to be safe for null Coords.
      Parameters:
      coords - The coordinates to center on
    • getAnimatedImages

      Set<Integer> getAnimatedImages()
      Returns:
      A set of hashCodes of those image that are animated (such as animated tileset images) and therefore should prevent the hex image from being cached.
    • getScrollableUnitIncrement

      int getScrollableUnitIncrement(Rectangle arg0, int arg1, int arg2)
      Override this to provide a return value exactly as the Scrollable interface method of the same name.
      See Also:
    • getScrollableBlockIncrement

      int getScrollableBlockIncrement(Rectangle arg0, int arg1, int arg2)
      Override this to provide a return value exactly as the Scrollable interface method of the same name.
      See Also:
    • getCoordsAt

      Coords getCoordsAt(Point point)
      Returns:
      the coords at the specified point in the BoardView's image area. The point may be given e.g. as part of a MouseEvent.
    • setTooltipProvider

      void setTooltipProvider(BoardViewTooltipProvider provider)
      Adds the given BoardViewTooltipProvider to this BoardView to provide the tooltips that are shown, replacing the previous BoardViewTooltipProvider, if any.
      Parameters:
      provider - The BoardViewTooltipProvider
      See Also:
    • repaint

      void repaint()
      Schedules a repaint of the BoardView.
      See Also:
    • addSprite

      default void addSprite(Sprite sprite)
      Adds a Sprite to be shown on this BoardView to its set of sprites.
      Parameters:
      sprite - the Sprite to show
    • addSprites

      void addSprites(Collection<? extends Sprite> sprites)
      Adds the given collection of Sprite to be shown on this BoardView to its set of sprites.
      Parameters:
      sprites - the Sprites to show
    • removeSprite

      default void removeSprite(Sprite sprite)
      Removes the given Sprite from this BoardView's set of sprites.
      Parameters:
      sprite - the Sprites to remove
    • removeSprites

      void removeSprites(Collection<? extends Sprite> sprites)
      Removes the given collection of Sprite from this BoardView's set of sprites.
      Parameters:
      sprites - the Sprites to remove
    • highlight

      void highlight(Coords coords)
      Highlights the given coords, if they are on the board. When coords is null, remove the highlight. Note that a BoardView implementation may choose to do nothing.
      Parameters:
      coords - the Coords to highlight
    • select

      void select(Coords coords)
      Selects the given coords, if they are on the board. When coords is null, remove the selection. Note that a BoardView implementation may choose to do nothing.
      Parameters:
      coords - the Coords to select
    • cursor

      void cursor(Coords coords)
      Places a cursor on the given coords, if they are on the board. When coords is null, remove the cursor. Note that a BoardView implementation may choose to do nothing.
      Parameters:
      coords - the Coords to cursor
    • clearMarkedHexes

      default void clearMarkedHexes()
      Removes the markers set by the select(), cursor() and highlight() methods.
    • getBoardId

      default int getBoardId()
      Returns:
      This BoardView's board ID. Defaults to 0 for all implementations that don't support multiple boards.
    • isShowingAnimation

      default boolean isShowingAnimation()
      Returns true when this BoardView is showing some animation and should not be centered on another hex or be hidden right now. An example is showing a unit's move animation.
      Returns:
      True when this BoardView is in the process of showing some animation