Interface IBoardView
- All Known Implementing Classes:
AbstractBoardView,BoardView
public interface IBoardView
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddBoardViewListener(BoardViewListener listener) Adds the specified board listener to receive board events from this board.voidaddOverlay(IDisplayable overlay) Adds the given overlay to thisBoardView.default voidAdds aSpriteto be shown on this BoardView to its set of sprites.voidaddSprites(Collection<? extends Sprite> sprites) Adds the given collection ofSpriteto be shown on this BoardView to its set of sprites.voidcenterOnHex(Coords coords) Notifies this BoardView to center itself on the given Coords.default voidRemoves the markers set by the select(), cursor() and highlight() methods.voidPlaces a cursor on the given coords, if they are on the board.default booleanvoiddispose()Frees the resources thisBoardViewuses and removes listeners.voidThis method should be overridden to do the actual drawing of the board image into the provided Graphics.default intReturns the pixel size of the entire board if drawn at the current zoom level.getCoordsAt(Point point) getEntireBoardImage(boolean hideUnits, boolean useBaseZoom) Returns an image of the entire board.getPanel()intgetScrollableBlockIncrement(Rectangle arg0, int arg1, int arg2) Override this to provide a return value exactly as the Scrollable interface method of the same name.intgetScrollableUnitIncrement(Rectangle arg0, int arg1, int arg2) Override this to provide a return value exactly as the Scrollable interface method of the same name.voidHighlights the given coords, if they are on the board.default booleanReturns true when thisBoardViewis showing some animation and should not be centered on another hex or be hidden right now.default voidvoidremoveBoardViewListener(BoardViewListener listener) Removes the specified board listener.voidremoveOverlay(IDisplayable overlay) Removes the given overlay from thisBoardView.default voidremoveSprite(Sprite sprite) Removes the givenSpritefrom this BoardView's set of sprites.voidremoveSprites(Collection<? extends Sprite> sprites) Removes the given collection ofSpritefrom this BoardView's set of sprites.voidrepaint()Schedules a repaint of the BoardView.voidSelects the given coords, if they are on the board.voidsetDisplayInvalidFields(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.voidsetLocalPlayer(int playerId) voidsetTooltipProvider(BoardViewTooltipProvider provider) Adds the given BoardViewTooltipProvider to this BoardView to provide the tooltips that are shown, replacing the previous BoardViewTooltipProvider, if any.voidsetUseLosTool(boolean useLosTool) voidzoomIn()Zooms in the board (shows less of it at bigger size), if the maximum zoom has not been reached already.voidzoomOut()Zooms out the board (shows more of it at smaller size), if the minimum zoom has not been reached already.voidToggles between two Zoom levels.
-
Method Details
-
draw
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 theBoardViewto use the given player ID as the player in whose client thisBoardViewis shown. This may affect what is shown and what is hidden in thisBoardView; 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() -
setUseLosTool
void setUseLosTool(boolean useLosTool) -
getPanel
JPanel getPanel()- Returns:
- The JPanel that contains this BoardView.
-
addBoardViewListener
Adds the specified board listener to receive board events from this board.- Parameters:
listener- the board listener.
-
removeBoardViewListener
Removes the specified board listener.- Parameters:
listener- the board listener.
-
addOverlay
Adds the given overlay to thisBoardView. 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
Removes the given overlay from thisBoardView.- Parameters:
overlay- The overlay to add- See Also:
-
refreshDisplayables
default void refreshDisplayables() -
getEntireBoardImage
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 boarduseBaseZoom- If true, zoom = 1 is used, otherwise the current board zoom- Returns:
- an image of the whole board
-
centerOnHex
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
- 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
Override this to provide a return value exactly as the Scrollable interface method of the same name.- See Also:
-
getScrollableBlockIncrement
Override this to provide a return value exactly as the Scrollable interface method of the same name.- See Also:
-
getCoordsAt
- 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
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
Adds aSpriteto be shown on this BoardView to its set of sprites.- Parameters:
sprite- the Sprite to show
-
addSprites
Adds the given collection ofSpriteto be shown on this BoardView to its set of sprites.- Parameters:
sprites- the Sprites to show
-
removeSprite
Removes the givenSpritefrom this BoardView's set of sprites.- Parameters:
sprite- the Sprites to remove
-
removeSprites
Removes the given collection ofSpritefrom this BoardView's set of sprites.- Parameters:
sprites- the Sprites to remove
-
highlight
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
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
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 thisBoardViewis 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
BoardViewis in the process of showing some animation
-