soc.client
Class SOCBoardPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by soc.client.SOCBoardPanel
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class SOCBoardPanel
extends java.awt.Canvas
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

This is a component that can display a Settlers of Catan Board. It can be used in an applet or an application. It loads gifs from a directory named "images" in the same directory as this class.

The main drawing methods are drawBoardEmpty(Graphics) for hexes and ports, and drawBoard(Graphics) for placed pieces like settlements and the robber. The board background color is set in SOCPlayerInterface. Since all areas outside the board boundaries are filled with water hex tiles, this color is only a fallback; it's briefly visible at window creation while the hexes are loading and rendering.

When the mouse is over the game board, a tooltip shows information such as a hex's resource, a piece's owner, a port's ratio, or the number under the robber. See hoverTip.

During game play, moving the mouse over the board shows ghosted roads, settlements, cities, and ships at locations the player can build. See: hilight, SOCBoardPanel.BoardToolTip.hoverRoadID. Right-click to build, or use the SOCBuildingPanel's buttons.

Before the game begins, the boardpanel is full of water hexes. You can show a short message text of 1 or 2 lines by calling setSuperimposedText(String, String).

During game play, you can show a short 1-line message text in the top-center part of the panel by calling setSuperimposedTopText(String).

This panel's minimum width and height in pixels is getMinimumSize(). To set its size, call setSize(int, int) or setBounds(int, int, int, int); these methods will set a flag to rescale board graphics if needed. If the game has 6 players but not SOCGame.hasSeaBoard, the board is also rotated 90 degrees clockwise. Pixel coordinates can be transformed between actual (scaled/rotated) and unscaled/un-rotated "internal" coordinates with scaleFromActualX(int), scaleFromActualY(int), scaleToActualX(int), scaleToActualY(int).

Sequence for loading, rendering, and drawing images:

See Also:
Serialized Form

Nested Class Summary
protected  class SOCBoardPanel.BoardPanelSendBuildTask
          Used for the delay between sending a build-request message, and receiving a game-state message.
private  class SOCBoardPanel.BoardPopupMenu
          This class creates a popup menu on the board, to trade or build or cancel building.
protected  class SOCBoardPanel.BoardToolTip
          (tooltip) Hover text for info on pieces/parts of the board.
private  class SOCBoardPanel.ConfirmAttackPirateFortressDialog
          Modal dialog to confirm the player wants to attack the pirate fortress and end their turn.
private  class SOCBoardPanel.ConfirmPlaceShipDialog
          For scenario _SC_FTRI, modal dialog to confirm placing a ship at an edge with a "gift" trade port.
protected static class SOCBoardPanel.DelayedRepaint
          With a recent board resize, one or more rescaled images still hasn't been completed after 7 seconds.
private  class SOCBoardPanel.MoveRobberConfirmDialog
          Modal dialog to confirm moving the robber next to our own settlement or city.
(package private) static class SOCBoardPanel.ResourceTradeAllMenu
          Menu for right-click on 3-for-1 port to trade all resource types with bank/port.
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private static java.awt.Color ARROW_COLOR
          Current-player arrow color: cyan: r=106,g=183,b=183
private static java.awt.Color ARROW_COLOR_PLACING
          Player arrow color when game is over, and during SOCGame.SPECIAL_BUILDING phase of the 6-player game.
private static int ARROW_SZ
          Current-player arrow fits in a 37 x 37 square.
private static int[] arrowXL
          Current-player arrow, left-pointing.
private static int[] arrowXR
          Current-player arrow, right-pointing.
private static int[] arrowY
          Current-player arrow, y-coordinates: same whether pointing left or right.
private  SOCBoard board
          The board in the game
private static int BOARDHEIGHT_VISUAL_MIN
          When isLargeBoard, Minimum visual SOCBoard.getBoardHeight() = 17 for enough height for SOCHandPanels to left and right.
private static int BOARDWIDTH_VISUAL_MIN
          When isLargeBoard, Minimum visual SOCBoard.getBoardWidth() = 18 for good-looking aspect ratio, and enough width for SOCBuildingPanel contents below.
private  java.awt.Image buffer
          offscreen buffer of everything (board, pieces, hovering pieces, tooltip), to prevent flicker.
protected static int BUILD_REQUEST_MAX_DELAY_SEC
          for popup-menu build request, network send maximum delay (seconds)
protected  SOCBoardPanel.BoardPanelSendBuildTask buildReqTimerTask
          For right-click build menu; used for fallback part of client-server-client communication of a build request.
private static int[] cityX
          city
private static int[] cityY
           
static int CONSIDER_LM_CITY
           
static int CONSIDER_LM_ROAD
           
static int CONSIDER_LM_SETTLEMENT
           
static int CONSIDER_LT_CITY
           
static int CONSIDER_LT_ROAD
           
static int CONSIDER_LT_SETTLEMENT
           
private  boolean debugShowCoordsTooltip
          Debugging flag where board item tooltip includes the item's coordinates.
(package private)  boolean[] debugShowPotentials
          For debugging, flags to show player 0's potential/legal coordinate sets.
private static int deltaX
          How many pixels to move over for a new hex.
private static int[] DELTAX_FACING
          x-offset to move over 1 hex, for each port facing direction (1-6).
private static int deltaY
          How many pixels to drop for each row of hexes.
private static int[] DELTAY_FACING
          y-offset to move over 1 hex, for each port facing direction (1-6).
private static java.awt.Image[] dice
          Dice number pictures (for the arrow; the hex dice numbers use Graphics.drawString).
private static java.awt.Color[] DICE_NUMBER_CIRCLE_COLORS
          Dice number circle background colors on hexes.
private static int DICE_NUMBER_CIRCLE_DIAMETER
          Diameter and font size (unscaled internal-pixels) for dice number circles on hexes.
private static int DICE_NUMBER_FONTPOINTS
          Diameter and font size (unscaled internal-pixels) for dice number circles on hexes.
private static int DICE_SZ
          Dice number graphic size in pixels; fits in a 25 x 25 square.
private  java.awt.FontMetrics diceNumberCircleFM
          FontMetrics of diceNumberCircleFont.
private  java.awt.Font diceNumberCircleFont
          Font of dice-number circles appearing on hexes, and dice numbers on cloth villages.
private static int[] downRoadX
          road looks like "\" along lower-left edge of hex
private static int[] downRoadY
           
private  long drawnEmptyAt
          Time of start of board repaint, as returned by System.currentTimeMillis().
private  int[] edgeMap
          Map grid sectors (from unscaled on-screen coordinates) to hex edges.
private  java.awt.Image emptyBoardBuffer
          offscreen buffer of board without any pieces placed, to prevent flicker.
private static int[] fortressX
          Fortress polygon for scenario SC_PIRI.
private static int[] fortressY
          Fortress polygon for scenario SC_PIRI.
private  SOCGame game
          The game which this board is a part of
private static int GAME_FORMING
           
private static int GAME_OVER
           
private static int HALF_HEXHEIGHT
          Half of HEXHEIGHT, in unscaled internal pixels, for use with various board graphics.
private static int halfdeltaX
          Each row moves a half hex over horizontally, compared to the row above/below it.
private static int halfdeltaY
          How many pixels for half a hex's height.
private  boolean hasCalledSetSize
          Ensure that super.setSize is called at least once.
private static java.awt.Color[] HEX_BORDER_COLORS
          Border colors for hex rendering.
private static int HEX_PORT_CIRCLE_DIA
          Diameter for rendering the hex port graphics' clear middle circle in renderPortImages().
private static int[] hexCornersX
          hex corners, clockwise from top-center, as located in waterHex.gif, hexBorder.gif, and other hex graphics: (27,0) (54,16) (54,46) (27,62) (0,46) (0,16).
private static int[] hexCornersY
          hex corners, clockwise from top-center.
private static int[] hexCornersY_RotatedOffset
          Offset to add to hexCornersY[] coordinates when used as (y,x) on rotated board.
private static java.awt.Image[] hexes
          Hex images - shared unscaled original-resolution from IMAGEDIR's GIF files.
private static int HEXHEIGHT
          hex size, in unscaled internal-pixels: 55 wide, 64 tall.
private  int[] hexIDtoNum
          Translate hex ID to hex number to get coords.
private  int[] hexMap
          Map grid sectors (from unscaled on-screen coordinates) to hexes.
private static int HEXWIDTH
          hex size, in unscaled internal-pixels: 55 wide, 64 tall.
private  int[] hexX
          hex coordinates for drawing pieces on the board.
private static int[] hexX_6pl
          hex coordinates for drawing the 6-player board, or null.
private static int HEXX_OFF_6PL
          In 6-player mode, the offset of hexX_6pl, hexY_6pl from hexX_st, hexY_st in unscaled board coordinates.
private static int[] hexX_st
          hex coordinates for drawing the standard board.
private  int[] hexY
          hex coordinates for drawing pieces on the board.
private static int[] hexY_6pl
          hex coordinates for drawing the 6-player board, or null.
private static int HEXY_OFF_6PL
          In 6-player mode, the offset of hexX_6pl, hexY_6pl from hexX_st, hexY_st in unscaled board coordinates.
private static int HEXY_OFF_6PL_FIND
          In 6-player mode, subtract this instead of HEXY_OFF_6PL in findEdge(int, int, boolean), findHex(int, int), findNode(int, int).
private static int HEXY_OFF_SLOPE_HEIGHT
          The vertical offset for A-nodes vs Y-nodes along a road; the height of the sloped top/bottom hex edges.
private static int[] hexY_st
           
private  int hilight
          Edge or node being pointed to.
private  boolean hilightIsShip
          If hilighting an edge, is the hilight a ship and not a road?
static int HOVER_OFFSET_X_FOR_INIT_PLACE
          During initial-piece placement, the tooltip is moved this far over to make room.
static int HOVER_OFFSET_X_FOR_ROBBER
          During robber placement, the tooltip is moved this far over to make room.
private  SOCBoardPanel.BoardToolTip hoverTip
          (tooltip) Hover text for info on pieces/parts of the board.
private static java.lang.String IMAGEDIR
          Hex and port graphics are in this directory.
private  boolean[] inactiveHexNums
          Hex numbers which aren't drawn, or null.
private  int initstlmt
          This holds the coord of the last stlmt placed in the initial phase.
protected  boolean is6player
          The board is configured for 6-player layout (and is isRotated); set in constructor by checking SOCBoard.getBoardEncodingFormat() <= SOCBoard.BOARD_ENCODING_6PLAYER and SOCGame.maxPlayers > 4.
protected  boolean isLargeBoard
          The board is configured Large-Board Format (up to 127x127, oriented like 4-player not 6-player); set in constructor by checking SOCBoard.getBoardEncodingFormat().
protected  boolean isRotated
          The board is visually rotated 90 degrees clockwise (6-player: game opt PL > 4) compared to the internal coordinates.
protected  boolean isScaled
          The board is currently scaled larger than panelMinBW x panelMinBH pixels.
protected  boolean isScaledOrRotated
          Convenience flag - The board is rotated and/or scaled up.
private  java.awt.Dimension minSize
          Minimum required width and height, as determined by options and isRotated.
private  int mode
          Modes of interaction; for correlation to game state, see updateMode().
private static int MOVE_SHIP
          Move a previously-placed ship on the large sea board.
private  int moveShip_fromEdge
          During MOVE_SHIP mode, the edge coordinate from which we're moving the ship.
private  boolean moveShip_isWarship
          During MOVE_SHIP mode, true if the ship being moved is a warship in scenario option _SC_PIRI.
private  int moveShip_toEdge
          During MOVE_SHIP mode, the edge coordinate to which we're moving the ship, 0 otherwise.
private  int[] nodeMap
          Map grid sectors (from unscaled on-screen coordinates) to hex nodes.
private static int NONE
          BoardPanel's modes.
private  SOCPlayer otherPlayer
          When in "consider" mode, this is the player we're talking to
protected  int panelMarginX
          Scaled (actual) panel margin on left, in pixels, for narrow boards, if board's unscaled width is less than panelMinBW.
protected  int panelMinBH
          panelMinBW and panelMinBH are the minimum width and height, in board-internal coordinates (not rotated or scaled).
protected  int panelMinBW
          panelMinBW and panelMinBH are the minimum width and height, in board-internal coordinates (not rotated or scaled).
private static int PANELPAD_LBOARD_RT
          When isLargeBoard, padding on right-hand side, in internal coordinates (like panelMinBW).
static int PANELX
          size of the whole panel, internal-pixels "scale".
static int PANELY
          size of the whole panel, internal-pixels "scale".
private static int PLACE_CITY
           
private static int PLACE_FREE_ROAD_OR_SHIP
          Place a free road or ship on the large sea board.
private static int PLACE_INIT_ROAD
          Place an initial road or ship.
private static int PLACE_INIT_SETTLEMENT
          Place an initial settlement, or just hover at a port.
private static int PLACE_PIRATE
          Move the pirate ship.
private static int PLACE_ROAD
          Place a road, or place a free road when not isLargeBoard.
private static int PLACE_ROBBER
          Place the robber, or just hover at a hex.
private static int PLACE_SETTLEMENT
           
private static int PLACE_SHIP
          Place a ship on the large sea board.
private  SOCPlayer player
          The player that is using this interface.
private  SOCPlayerInterface playerInterface
          the player interface that this board is a part of
private  int playerNumber
          player number of our player if in a game, or -1.
protected static int POPUP_MENU_IGNORE_MS
          for popup-menu build request, length of time after popup to ignore further mouse-clicks.
private  SOCBoardPanel.BoardPopupMenu popupMenu
          Context menu for build/cancel-build
private  long popupMenuSystime
          Tracks last menu-popup time.
private static int[][] portArrowsX
          For port hexes, the triangular arrowheads towards port settlement nodes: Array of shapes' X coordinates.
private static int[][] portArrowsY
          For port hexes, the triangular arrowheads towards port settlement nodes: Array of shapes' Y coordinates.
private  int ptrOldX
          Previous pointer coordinates for interface; the mouse was at this location when hilight was last determined in mouseMoved(MouseEvent).
private  int ptrOldY
          Previous pointer coordinates for interface; the mouse was at this location when hilight was last determined in mouseMoved(MouseEvent).
private static int RESCALE_MAX_RETRY_MS
          For repaint when retrying a failed rescale-image, the 7-second maximum time (in millis) after which no more retries will be done.
private static int RESCALE_RETRY_DELAY_MS
          For repaint when retrying a failed rescale-image, the 3-second delay (in millis) before which SOCBoardPanel.DelayedRepaint will call repaint().
protected  java.awt.Color[] robberGhostFill
          Cached colors, for use for robber's "ghost" (previous position) when moving the robber.
protected  java.awt.Color[] robberGhostOutline
          Cached colors, for use for robber's "ghost" (previous position) when moving the robber.
private static int[] robberX
          robber polygon.
private static int[] robberY
           
private static java.awt.Color[] ROTAT_HEX_BORDER_COLORS
          Border colors for hex rendering when isRotated.
private static java.awt.Image[] rotatHexes
          Hex images - rotated board; from IMAGEDIR/rotat's GIF files.
private static int[] ROW_START_HEXNUM
          Hex numbers of start of each row of hexes in the board coordinates.
private static int SC_FTRI_PLACE_PORT
          In scenario option _SC_FTRI game state SOCGame.PLACING_INV_ITEM, boardpanel mode to place a port next to player's coastal settlement/city.
private  int[] scaledArrowXL
          Current-player arrow, left-pointing and right-pointing.
private  int[] scaledArrowXR
          Current-player arrow, left-pointing and right-pointing.
private  int[] scaledArrowY
          Current-player arrow, left-pointing and right-pointing.
protected  long scaledAt
          Time of last request to resize and repaint, as returned by System.currentTimeMillis().
private  int[] scaledCityX
          city
private  int[] scaledCityY
          city
private  int[] scaledDownRoadX
          road looks like "\"
private  int[] scaledDownRoadY
          road looks like "\"
private  int[] scaledFortressX
          fortress (scenario _SC_PIRI)
private  int[] scaledFortressY
          fortress (scenario _SC_PIRI)
private  int[] scaledHexCornersX
          hex corner coordinates, as scaled to current board size.
private  int[] scaledHexCornersY
          hex corner coordinates, as scaled to current board size.
private  java.awt.Image[] scaledHexes
          Hex images - private scaled copy, if isScaled.
private  boolean[] scaledHexFail
          Hex/port images - Per-image flag to check if rescaling failed, if isScaled.
protected  boolean scaledMissedImage
          Flag used while drawing a scaled board.
protected  int scaledPanelX
          actual size on-screen, not internal-pixels size (panelMinBW, panelMinBH)
protected  int scaledPanelY
          actual size on-screen, not internal-pixels size (panelMinBW, panelMinBH)
private  int[][] scaledPortArrowsX
          For port hexes, the triangular arrowheads towards port settlement nodes.
private  int[][] scaledPortArrowsY
          For port hexes, the triangular arrowheads towards port settlement nodes.
private  boolean[] scaledPortFail
          Hex/port images - Per-image flag to check if rescaling failed, if isScaled.
private  java.awt.Image[] scaledPorts
          Port images - private copy, rotated and/or scaled if necessary.
private  int[] scaledRobberX
          robber
private  int[] scaledRobberY
          robber
private  int[] scaledSettlementX
          settlement
private  int[] scaledSettlementY
          settlement
private  int[] scaledShipX
          ship
private  int[] scaledShipY
          ship
private  int[] scaledUpRoadX
          road looks like "/"
private  int[] scaledUpRoadY
          road looks like "/"
private  int[] scaledVertRoadX
          Coordinate arrays for drawing the playing pieces.
private  int[] scaledVertRoadY
          Coordinate arrays for drawing the playing pieces.
private  int[] scaledVillageX
          village (scenario _SC_CLVI)
private  int[] scaledVillageY
          village (scenario _SC_CLVI)
private  int[] scaledWarshipX
          warship (scenario _SC_PIRI)
private  int[] scaledWarshipY
          warship (scenario _SC_PIRI)
private static int[] settlementX
          settlement
private static int[] settlementY
           
private static int[] shipX
          Ship.
private static int[] shipY
          Ship.
private static SOCStringManager strings
          i18n text strings
private  int superText_des
          Width, height of superText1 and superText2 if known, or 0.
private  int superText_h
          Width, height of superText1 and superText2 if known, or 0.
private static int SUPERTEXT_INSET
          Pixel spacing around superText1, superText2, superTextTop
private static int SUPERTEXT_PADDING_HORIZ
          Pixel spacing around superText1, superText2, superTextTop
private  java.lang.String superText1
          Text to be displayed as 2 lines superimposed over center of the board graphic (during game setup).
private  int superText1_w
          Width, height of superText1 and superText2 if known, or 0.
private  java.lang.String superText2
          Text to be displayed as 2 lines superimposed over center of the board graphic (during game setup).
private  int superText2_w
          Width, height of superText1 and superText2 if known, or 0.
private  int superTextBox_h
          Width, height of superText1 and superText2 if known, or 0.
private  int superTextBox_w
          Width, height of superText1 and superText2 if known, or 0.
private  int superTextBox_x
          Width, height of superText1 and superText2 if known, or 0.
private  int superTextBox_y
          Width, height of superText1 and superText2 if known, or 0.
private  java.lang.String superTextTop
          Text to be displayed as 1 line superimposed over the top-center of the board graphic (during game play).
private  int superTextTop_h
          Width, height of superTextTop if known, or 0.
private  int superTextTop_w
          Width, height of superTextTop if known, or 0.
private  int superTextTopBox_h
          Width, height of superTextTop if known, or 0.
private  int superTextTopBox_w
          Width, height of superTextTop if known, or 0.
private  int superTextTopBox_x
          Width, height of superTextTop if known, or 0.
private static int TURN_STARTING
           
private static int[] upRoadX
          road looks like "/" along upper-left edge of hex
private static int[] upRoadY
           
private static int[] vertRoadX
          road looks like "|" along left edge of hex
private static int[] vertRoadY
           
private static int[] villageX
          village polygon.
private static int[] villageY
          village polygon.
private static int[] warshipX
          Warship for scenario SC_PIRI.
private static int[] warshipY
          Warship for scenario SC_PIRI.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SOCBoardPanel(SOCPlayerInterface pi)
          create a new board panel in a game interface.
 
Method Summary
protected  void clearModeAndHilight(int ptype)
          Set board mode to NONE, no hilight, usually from a piece-placement mode.
protected  void doBoardMenuPopup(int x, int y)
          Bring up the popup menu; called from mousePressed.
private  void drawArrow(java.awt.Graphics g, int pnum, int diceResult)
          draw the arrow that shows whose turn it is.
private  void drawBoard_SC_FTRI_placePort(java.awt.Graphics g)
          Scenario game option _SC_FTRI: In board mode SC_FTRI_PLACE_PORT, draw the possible coastal edges where the port can be placed, and if the hilight cursor is at such an edge, draw the port semi-transparently and a solid hilight line at the edge.
private  void drawBoard(java.awt.Graphics g)
          Draw the whole board, including pieces and tooltip (hilight, hoverTip) if applicable.
private  void drawBoardEmpty_drawDebugShowPotentialRoad(java.awt.Graphics g, int x, int y, int r, int c, boolean isVert, java.awt.Color co, int offset)
          Draw around one potential/legal road edge, for drawBoardEmpty_drawDebugShowPotentials(Graphics).
private  void drawBoardEmpty_drawDebugShowPotentials(java.awt.Graphics g)
          If any bit in debugShowPotentials[] is set, besides 8, draw it on the board.
private  void drawBoardEmpty_drawPiratePath(java.awt.Graphics g, int[] ppath)
          For the _SC_PIRI game scenario on SOCBoardLarge, draw the path that the pirate fleet takes around the board.
private  void drawBoardEmpty_specialEdges(java.awt.Graphics g)
          For the _SC_FTRI game scenario on SOCBoardLarge, draw markers at all Special Edges for the players to reach and be rewarded.
private  void drawBoardEmpty_specialNodes(java.awt.Graphics g, java.lang.String partKey, java.awt.Color color)
          For a game scenario on SOCBoardLarge, draw markers at a set of Special Nodes for the players to reach and be rewarded, retrieved with SOCBoardLarge.getAddedLayoutPart(String).
private  void drawBoardEmpty(java.awt.Graphics g)
          Draw the whole board (water, hexes, ports, numbers) but no placed pieces.
private  void drawCity(java.awt.Graphics g, int nodeNum, int pn, boolean isHilight)
          draw a city
private  void drawFortress(java.awt.Graphics g, SOCFortress fo, int pn, boolean isHilight)
          Draw a pirate fortress, for scenario SC_PIRI.
private  void drawHex(java.awt.Graphics g, int hexNum)
          Draw a board tile by its hex number (v1 or v2 board encoding).
private  void drawHex(java.awt.Graphics g, int x, int y, int hexType, int portFacing, int hexNum)
          Draw a land, water, or port hex tile at a given location.
private  void drawMarker(java.awt.Graphics g, int x, int y, java.awt.Color color, int val)
          Draw a marker (village symbol) centered at a final (x,y) coordinate.
private  void drawPorts_LargeBoard(java.awt.Graphics g)
          Draw the ports for the large board.
private  void drawPortsRing(java.awt.Graphics g)
          for the 6-player board (if is6player), draw the ring of surrounding water/ports.
private  void drawRoadOrShip(java.awt.Graphics g, int edgeNum, int pn, boolean isHilight, boolean isRoadNotShip, boolean isWarship)
          draw a road or ship along an edge.
private  void drawRobber(java.awt.Graphics g, int hexID, boolean fullNotGhost, boolean fillNotOutline)
          Draw the robber.
private  void drawSeaEdgeLine(java.awt.Graphics g, int edge)
          For drawing the player's permitted sea edges for ships, draw a line covering the middle 60% of this edge on the board (leaves out 20% on each end).
private  void drawSeaEdgeLines(java.awt.Graphics g, java.awt.Color co, java.util.Collection<java.lang.Integer> lse)
          Draw a dotted line with some thickness at each of these sea edge coordinates.
private  void drawSettlement(java.awt.Graphics g, int nodeNum, int pn, boolean isHilight, boolean outlineOnly)
          draw a settlement
private  void drawSettlementOrCity(java.awt.Graphics g, int nodeNum, int pn, boolean isHilight, boolean outlineOnly, boolean isCity)
          draw a settlement or city; they have the same logic for determining (x,y) from nodeNum.
private  void drawSuperText(java.awt.Graphics g)
          Draw superText1, superText2; if necessary, calculate superText1_w and other fields.
private  void drawSuperTextTop(java.awt.Graphics g)
          Draw superTextTop; if necessary, calculate superTextTop_w and other fields.
private  void drawVillage(java.awt.Graphics g, SOCVillage v)
          Draw a cloth trade village (used in some scenarios in the large sea board).
private  int findEdge(int x, int y, boolean checkCoastal)
          given a pixel on the board, find the edge that contains it
private  int findHex(int x, int y)
          given a pixel on the board, find the hex that contains it
private  int findNode(int x, int y)
          given a pixel on the board, find the node that contains it
 void flushBoardLayoutAndRepaint()
          Clear the board layout (as rendered in the empty-board buffer) and trigger a repaint.
 void flushBoardLayoutAndRepaintIfDebugShowPotentials()
          Clear the board layout (as rendered in the empty-board buffer) and trigger a repaint, only if we're showing potential/legal settlements/roads/cities for debug purposes.
 java.awt.Dimension getMinimumSize()
          Minimum required width and height, as determined by options and isRotated().
(package private)  int getPlayerNumber()
          Get our player number.
 java.awt.Dimension getPreferredSize()
          DOCUMENT ME!
static java.awt.image.BufferedImage getScaledImageUp(java.awt.Image src, int w, int h)
          Scale up an image with decent quality.
 java.awt.Color hexColor(int hexType)
          Hex color for a hex resource type
private  void initCoordMappings()
          During the constructor, initialize the board-coordinate to screen-coordinate mappings: edgeMap, nodeMap, hexMap, hexIDtoNum, hexX, hexY, inactiveHexNums.
private  void initEdgeMapAux(int x1, int y1, int x2, int y2, int startHex)
          Initialize edgeMap's valid edges across 1 row of hexes, for use by findEdge(int, int, boolean).
private  void initHexIDtoNumAux(int begin, int end, int num)
           
private  void initHexMapAux(int x1, int y1, int x2, int y2, int startHex)
           
private  void initNodeMapAux(int x1, int y1, int x2, int y2, int startHex)
          Within nodeMap, set the node coordinates within a rectangular section from (x1,y1) to (x2,y2) covering all nodes of one horizontal row of hexes.
 boolean isRotated()
          Is the board currently rotated 90 degrees clockwise? If so, the minimum size swaps PANELX and PANELY.
 boolean isScaled()
          Is the board currently scaled larger than PANELX x PANELY pixels? If so, use scaleToActualX(int), scaleFromActualY(int), etc to convert between internal and actual screen pixel coordinates.
private static void loadHexesAndImages(java.awt.Image[] newHexes, java.lang.String imageDir, java.awt.MediaTracker tracker, java.awt.Toolkit tk, java.lang.Class<?> clazz, boolean wantsRotated)
          Load hex and other related images from either normal, or rotated, resource location.
private static void loadImages(java.awt.Component c, boolean wantsRotated)
          Load the images for the board: hexes, rotatHexes, and dice.
 void mouseClicked(java.awt.event.MouseEvent evt)
          DOCUMENT ME!
 void mouseDragged(java.awt.event.MouseEvent e)
          DOCUMENT ME!
 void mouseEntered(java.awt.event.MouseEvent e)
          Handle Events
 void mouseExited(java.awt.event.MouseEvent e)
          Mouse has left the panel; hide tooltip and any hovering piece.
 void mouseMoved(java.awt.event.MouseEvent e)
          Based on the board's current mode, update the hovering 'hilight' piece (hilight}.
 void mousePressed(java.awt.event.MouseEvent e)
          DOCUMENT ME!
 void mouseReleased(java.awt.event.MouseEvent e)
          DOCUMENT ME!
private  int[] nodeToXY(int nodeNum)
          Calculate the on-screen coordinates of a node.
 void paint(java.awt.Graphics g)
          Redraw the board using double buffering.
 void pieceValueUpdated(SOCPlayingPiece piece)
          A playing piece's value was updated: _SC_CLVI village cloth count, or _SC_PIRI pirate fortress strength.
 void popupClearBuildRequest()
          player decided to not build something, so cancel the TimerTask that's waiting to tell the server what they wanted to build.
 boolean popupExpectingBuildRequest()
          If the client has used the board popup menu to request building a piece, this method is used in client network-receive message treatment.
 void popupFireBuildingRequest()
          Have received gamestate placing message; send the building request in reply.
 void popupSetBuildRequest(int coord, int ptype)
           
private  java.awt.Image renderBorderedHex(java.awt.Image hex, java.awt.Image hexBorder, java.awt.Color borderColor)
          Render a border around the edge of this hex, returning a new image.
private  void renderPortImages()
          Based on the waterHex image, render the 6 port images (1 per "facing" rotation), each with arrows in its 2 settlement directions.
private  void rescaleBoard(int newW, int newH)
          Set the board fields to a new size, rescale graphics if needed.
private  void rescaleCoordinateArrays()
          Scale coordinate arrays for drawing pieces (from internal coordinates to actual on-screen pixels), or (if not isScaled) point to static arrays.
 int[] rotateScaleCopyYToActualX(int[] yorig, int width, boolean rescale)
          Copy and rotate this array of y-coordinates, optionally also rescaling.
 int[] scaleCopyToActualX(int[] xorig)
          Rescale to actual screen coordinates - Create a copy of array, and scale the copy's elements as X coordinates.
 int[] scaleCopyToActualY(int[] yorig)
          Rescale to actual screen coordinates - Create a copy of array, and scale the copy's elements as Y coordinates.
 int scaleFromActualX(int x)
          Convert an x-coordinate from actual-scaled to internal-scaled coordinates.
 int scaleFromActualY(int y)
          Convert a y-coordinate from actual-scaled to internal-scaled coordinates.
 int scaleToActualX(int x)
          Scale x-coordinate from internal to actual screen-pixel coordinates.
 void scaleToActualX(int[] xa)
          Scale x-array from internal to actual screen-pixel coordinates.
 int scaleToActualY(int y)
          Scale y-coordinate from internal to actual screen-pixel coordinates.
 void scaleToActualY(int[] ya)
          Scale y-array from internal to actual screen-pixel coordinates.
 void setBounds(int x, int y, int w, int h)
          Set the board to a new location and size, rescale graphics and repaint if needed.
(package private)  void setDebugShowCoordsFlag(boolean setOn)
          Set or clear the debug flag where the board item tooltip includes the item's coordinates.
(package private)  void setDebugShowPotentialsFlag(int pieceType, boolean setPotential, boolean setOn)
          Set or clear a debug flag to show player 0's potential/legal coordinate sets.
 void setMode(int m)
          Set the interaction mode, for debugging purposes.
 void setModeMoveShip(int edge)
          Set the interaction mode to "move ship"; the player must now click where they want the ship to be moved.
 void setOtherPlayer(SOCPlayer op)
          set the other player
 void setPlayer()
          set the player that is using this board panel to be the client's player in this game.
(package private)  void setPlayer(SOCPlayer pl)
          Temporarily change the player that is using this board panel.
 void setSize(java.awt.Dimension sz)
          Set the board to a new size, rescale graphics and repaint if needed.
 void setSize(int newW, int newH)
          Set the board to a new size, rescale graphics and repaint if needed.
 void setSuperimposedText(java.lang.String text1, java.lang.String text2)
          Text to be displayed as 2 lines superimposed over the center of the board graphic (during game setup).
 void setSuperimposedTopText(java.lang.String text)
          Text to be displayed as 1 lines superimposed over the top center of the board graphic (during game play).
private  void tryMoveShipToEdge()
          Check and move ship from moveShip_fromEdge to moveShip_toEdge.
 void update(java.awt.Graphics g)
          Overriden so the peer isn't painted, which clears background.
protected  void updateHoverTipToMode()
          Update hoverTip based on mode when it changes; called from updateMode().
 void updateMode()
          update the type of interaction mode, and trigger a repaint.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

strings

private static final SOCStringManager strings
i18n text strings


IMAGEDIR

private static java.lang.String IMAGEDIR
Hex and port graphics are in this directory. The rotated versions for the 6-player non-sea board are in IMAGEDIR/rotat. The images are loaded into the hexes, rotatHexes, scaledHexes, and scaledPorts arrays.


PANELX

public static final int PANELX
size of the whole panel, internal-pixels "scale". This constant may not reflect the current game board's minimum size: In board-internal coordinates, use panelMinBW and panelMinBH instead. For minimum acceptable size in on-screen pixels, call getMinimumSize() instead of using PANELX and PANELY directly. For actual current size in screen pixels, see scaledPanelX scaledPanelY; If isRotated(), the minimum size swaps PANELX and PANELY. If 6-player board or Large/Sea Board, the minimum size is larger.

Left/top margins for isLargeBoard: 0 for x, halfdeltaY for y.

See Also:
Constant Field Values

PANELY

public static final int PANELY
size of the whole panel, internal-pixels "scale". This constant may not reflect the current game board's minimum size: In board-internal coordinates, use panelMinBW and panelMinBH instead. For minimum acceptable size in on-screen pixels, call getMinimumSize() instead of using PANELX and PANELY directly. For actual current size in screen pixels, see scaledPanelX scaledPanelY; If isRotated(), the minimum size swaps PANELX and PANELY. If 6-player board or Large/Sea Board, the minimum size is larger.

Left/top margins for isLargeBoard: 0 for x, halfdeltaY for y.

See Also:
Constant Field Values

BOARDWIDTH_VISUAL_MIN

private static final int BOARDWIDTH_VISUAL_MIN
When isLargeBoard, Minimum visual SOCBoard.getBoardWidth() = 18 for good-looking aspect ratio, and enough width for SOCBuildingPanel contents below.

Since:
2.0.00
See Also:
Constant Field Values

BOARDHEIGHT_VISUAL_MIN

private static final int BOARDHEIGHT_VISUAL_MIN
When isLargeBoard, Minimum visual SOCBoard.getBoardHeight() = 17 for enough height for SOCHandPanels to left and right.

Since:
2.0.00
See Also:
Constant Field Values

PANELPAD_LBOARD_RT

private static final int PANELPAD_LBOARD_RT
When isLargeBoard, padding on right-hand side, in internal coordinates (like panelMinBW).

Since:
2.0.00
See Also:
Constant Field Values

deltaY

private static final int deltaY
How many pixels to drop for each row of hexes. @see #HEXHEIGHT

See Also:
Constant Field Values

deltaX

private static final int deltaX
How many pixels to move over for a new hex. @see #HEXWIDTH

See Also:
Constant Field Values

halfdeltaX

private static final int halfdeltaX
Each row moves a half hex over horizontally, compared to the row above/below it.

See Also:
deltaX, halfdeltaY, Constant Field Values

halfdeltaY

private static final int halfdeltaY
How many pixels for half a hex's height. Used in layout calculations when isLargeBoard.

Since:
2.0.00
See Also:
deltaY, halfdeltaX, HALF_HEXHEIGHT, Constant Field Values

DELTAX_FACING

private static final int[] DELTAX_FACING
x-offset to move over 1 hex, for each port facing direction (1-6). 0 is unused. Facing is the direction to the land hex touching the port. Facing 1 is NE, 2 is E, 3 is SE, 4 is SW, etc: see SOCBoard.FACING_E etc.

Since:
1.1.08
See Also:
DELTAY_FACING

DELTAY_FACING

private static final int[] DELTAY_FACING
y-offset to move over 1 hex, for each port facing direction (1-6). 0 is unused.

Since:
1.1.08
See Also:
DELTAX_FACING

hexX_st

private static final int[] hexX_st
hex coordinates for drawing the standard board. Upper-left corner of each hex, left-to-right in each row. These were called hexX, hexY before 1.1.08.

See Also:
hexX_6pl

hexY_st

private static final int[] hexY_st

hexX_6pl

private static int[] hexX_6pl
hex coordinates for drawing the 6-player board, or null. Initialized by constructor of the first 6-player boardpanel. To make room for the ring of ports/water which isn't in the coordinate system, the offset from hexX_st is HEXX_OFF_6PL, and the offset from hexY_st is HEXY_OFF_6PL.

Since:
1.1.08
See Also:
hexX

hexY_6pl

private static int[] hexY_6pl
hex coordinates for drawing the 6-player board, or null. Initialized by constructor of the first 6-player boardpanel. To make room for the ring of ports/water which isn't in the coordinate system, the offset from hexX_st is HEXX_OFF_6PL, and the offset from hexY_st is HEXY_OFF_6PL.

Since:
1.1.08
See Also:
hexX

HEXX_OFF_6PL

private static final int HEXX_OFF_6PL
In 6-player mode, the offset of hexX_6pl, hexY_6pl from hexX_st, hexY_st in unscaled board coordinates. Remember that x and y are swapped on-screen, because the board is rotated.

Since:
1.1.08
See Also:
Constant Field Values

HEXY_OFF_6PL

private static final int HEXY_OFF_6PL
In 6-player mode, the offset of hexX_6pl, hexY_6pl from hexX_st, hexY_st in unscaled board coordinates. Remember that x and y are swapped on-screen, because the board is rotated.

Since:
1.1.08
See Also:
Constant Field Values

HEXY_OFF_6PL_FIND

private static final int HEXY_OFF_6PL_FIND
In 6-player mode, subtract this instead of HEXY_OFF_6PL in findEdge(int, int, boolean), findHex(int, int), findNode(int, int).

Since:
1.1.08
See Also:
Constant Field Values

HEXY_OFF_SLOPE_HEIGHT

private static final int HEXY_OFF_SLOPE_HEIGHT
The vertical offset for A-nodes vs Y-nodes along a road; the height of the sloped top/bottom hex edges.

Since:
2.0.00
See Also:
hexCornersY, Constant Field Values

HEX_PORT_CIRCLE_DIA

private static final int HEX_PORT_CIRCLE_DIA
Diameter for rendering the hex port graphics' clear middle circle in renderPortImages(). The border drawn around the clear circle is also based on this.

Since:
1.1.20
See Also:
portArrowsX, Constant Field Values

vertRoadX

private static final int[] vertRoadX
road looks like "|" along left edge of hex


vertRoadY

private static final int[] vertRoadY

upRoadX

private static final int[] upRoadX
road looks like "/" along upper-left edge of hex


upRoadY

private static final int[] upRoadY

downRoadX

private static final int[] downRoadX
road looks like "\" along lower-left edge of hex


downRoadY

private static final int[] downRoadY

settlementX

private static final int[] settlementX
settlement


settlementY

private static final int[] settlementY

cityX

private static final int[] cityX
city


cityY

private static final int[] cityY

shipX

private static final int[] shipX
Ship. Center is (x=0.5, y=32 == HALF_HEXHEIGHT).

Since:
2.0.00
See Also:
warshipX

shipY

private static final int[] shipY
Ship. Center is (x=0.5, y=32 == HALF_HEXHEIGHT).

Since:
2.0.00
See Also:
warshipX

warshipX

private static final int[] warshipX
Warship for scenario SC_PIRI. Center is (x=0.5, y=32 == HALF_HEXHEIGHT). Design is based on the normal ship (shipX, shipY) with a second sail and a taller hull.

Since:
2.0.00

warshipY

private static final int[] warshipY
Warship for scenario SC_PIRI. Center is (x=0.5, y=32 == HALF_HEXHEIGHT). Design is based on the normal ship (shipX, shipY) with a second sail and a taller hull.

Since:
2.0.00

fortressX

private static final int[] fortressX
Fortress polygon for scenario SC_PIRI. X is -13 to +13; Y is -11 to +11. @since 2.0.00


fortressY

private static final int[] fortressY
Fortress polygon for scenario SC_PIRI. X is -13 to +13; Y is -11 to +11. @since 2.0.00


villageX

private static final int[] villageX
village polygon. X is -13 to +13; Y is -9 to +9. Used in drawVillage(Graphics, SOCVillage), and as a generic marker in drawMarker(Graphics, int, int, Color, int).

Since:
2.0.00

villageY

private static final int[] villageY
village polygon. X is -13 to +13; Y is -9 to +9. Used in drawVillage(Graphics, SOCVillage), and as a generic marker in drawMarker(Graphics, int, int, Color, int).

Since:
2.0.00

robberX

private static final int[] robberX
robber polygon. X is -4 to +4; Y is -8 to +8.


robberY

private static final int[] robberY

portArrowsX

private static final int[][] portArrowsX
For port hexes, the triangular arrowheads towards port settlement nodes: Array of shapes' X coordinates. For Y see portArrowsY.

First index is the shape number, second index is coordinates within the shape, clockwise from tip. Shape numbers are 0-5, for the 6 facing directions numbered the same way as SOCBoard#getAdjacentNodeToHex(int): clockwise from top (northern point of hex), 0 is north, 1 is northeast, etc, 5 is northwest.

Since:
1.1.20
See Also:
HEX_PORT_CIRCLE_DIA

portArrowsY

private static final int[][] portArrowsY
For port hexes, the triangular arrowheads towards port settlement nodes: Array of shapes' Y coordinates. For X and details see portArrowsX.

Since:
1.1.20

arrowXL

private static final int[] arrowXL
Current-player arrow, left-pointing. First point is top of arrow-tip's bevel, last point is bottom of tip. arrowXL[4] is rightmost X coordinate. (These points are important for adjustment when scaling in rescaleCoordinateArrays())

Since:
1.1.00
See Also:
arrowY, ARROW_SZ

arrowXR

private static int[] arrowXR
Current-player arrow, right-pointing. Calculated when needed by flipping arrowXL in rescaleCoordinateArrays().

Since:
1.1.00

arrowY

private static final int[] arrowY
Current-player arrow, y-coordinates: same whether pointing left or right. First point is top of arrow-tip's bevel, last point is bottom of tip.

Since:
1.1.00

ARROW_SZ

private static final int ARROW_SZ
Current-player arrow fits in a 37 x 37 square.

Since:
1.1.00
See Also:
arrowXL, Constant Field Values

ARROW_COLOR

private static final java.awt.Color ARROW_COLOR
Current-player arrow color: cyan: r=106,g=183,b=183

Since:
1.1.00
See Also:
ARROW_COLOR_PLACING

ARROW_COLOR_PLACING

private static final java.awt.Color ARROW_COLOR_PLACING
Player arrow color when game is over, and during SOCGame.SPECIAL_BUILDING phase of the 6-player game.

The game-over color was added in 1.1.09. Previously, ARROW_COLOR was used.

Since:
1.1.08

HEX_BORDER_COLORS

private static final java.awt.Color[] HEX_BORDER_COLORS
Border colors for hex rendering. Same indexes as hexes. Used in rescaleBoard(int, int) with mask hexBorder.gif.

Since:
1.1.20
See Also:
ROTAT_HEX_BORDER_COLORS

ROTAT_HEX_BORDER_COLORS

private static final java.awt.Color[] ROTAT_HEX_BORDER_COLORS
Border colors for hex rendering when isRotated. Same indexes as rotatHexes. Used in rescaleBoard(int, int) with mask hexBorder.gif.

Since:
1.1.20
See Also:
HEX_BORDER_COLORS

RESCALE_RETRY_DELAY_MS

private static final int RESCALE_RETRY_DELAY_MS
For repaint when retrying a failed rescale-image, the 3-second delay (in millis) before which SOCBoardPanel.DelayedRepaint will call repaint().

This constant was introduced in v1.1.20, previously the value was hardcoded.

Since:
1.1.20
See Also:
scaledMissedImage, RESCALE_MAX_RETRY_MS, Constant Field Values

RESCALE_MAX_RETRY_MS

private static final int RESCALE_MAX_RETRY_MS
For repaint when retrying a failed rescale-image, the 7-second maximum time (in millis) after which no more retries will be done.

This constant was introduced in v1.1.20, previously the value was hardcoded.

Since:
1.1.20
See Also:
scaledMissedImage, RESCALE_RETRY_DELAY_MS, Constant Field Values

NONE

private static final int NONE
BoardPanel's modes. NONE is normal gameplay, or not the client's turn. For correlation to game state, see updateMode().

If a mode is added, please also update clearModeAndHilight(int). If a piece or item hovers in this mode with the mouse cursor, update SOCBoardPanel.BoardToolTip.handleHover(int, int). If the player clicks to place or interact in the new mode, update mouseClicked(MouseEvent). See hilight and SOCBoardPanel.BoardToolTip.

See Also:
Constant Field Values

PLACE_ROAD

private static final int PLACE_ROAD
Place a road, or place a free road when not isLargeBoard.

See Also:
PLACE_FREE_ROAD_OR_SHIP, Constant Field Values

PLACE_SETTLEMENT

private static final int PLACE_SETTLEMENT
See Also:
Constant Field Values

PLACE_CITY

private static final int PLACE_CITY
See Also:
Constant Field Values

PLACE_ROBBER

private static final int PLACE_ROBBER
Place the robber, or just hover at a hex.

See Also:
PLACE_PIRATE, Constant Field Values

PLACE_INIT_SETTLEMENT

private static final int PLACE_INIT_SETTLEMENT
Place an initial settlement, or just hover at a port.

See Also:
SOCBoardPanel.BoardToolTip.hoverIsPort, Constant Field Values

PLACE_INIT_ROAD

private static final int PLACE_INIT_ROAD
Place an initial road or ship.

See Also:
Constant Field Values

CONSIDER_LM_SETTLEMENT

public static final int CONSIDER_LM_SETTLEMENT
See Also:
Constant Field Values

CONSIDER_LM_ROAD

public static final int CONSIDER_LM_ROAD
See Also:
Constant Field Values

CONSIDER_LM_CITY

public static final int CONSIDER_LM_CITY
See Also:
Constant Field Values

CONSIDER_LT_SETTLEMENT

public static final int CONSIDER_LT_SETTLEMENT
See Also:
Constant Field Values

CONSIDER_LT_ROAD

public static final int CONSIDER_LT_ROAD
See Also:
Constant Field Values

CONSIDER_LT_CITY

public static final int CONSIDER_LT_CITY
See Also:
Constant Field Values

PLACE_SHIP

private static final int PLACE_SHIP
Place a ship on the large sea board.

Since:
2.0.00
See Also:
Constant Field Values

PLACE_FREE_ROAD_OR_SHIP

private static final int PLACE_FREE_ROAD_OR_SHIP
Place a free road or ship on the large sea board. If not isLargeBoard, use PLACE_ROAD instead.

Since:
2.0.00
See Also:
Constant Field Values

MOVE_SHIP

private static final int MOVE_SHIP
Move a previously-placed ship on the large sea board. Also set moveShip_fromEdge and moveShip_isWarship.

Since:
2.0.00
See Also:
Constant Field Values

PLACE_PIRATE

private static final int PLACE_PIRATE
Move the pirate ship.

Since:
2.0.00
See Also:
PLACE_ROBBER, Constant Field Values

SC_FTRI_PLACE_PORT

private static final int SC_FTRI_PLACE_PORT
In scenario option _SC_FTRI game state SOCGame.PLACING_INV_ITEM, boardpanel mode to place a port next to player's coastal settlement/city.

Since:
2.0.00
See Also:
Constant Field Values

TURN_STARTING

private static final int TURN_STARTING
See Also:
Constant Field Values

GAME_FORMING

private static final int GAME_FORMING
See Also:
Constant Field Values

GAME_OVER

private static final int GAME_OVER
See Also:
Constant Field Values

HOVER_OFFSET_X_FOR_INIT_PLACE

public static final int HOVER_OFFSET_X_FOR_INIT_PLACE
During initial-piece placement, the tooltip is moved this far over to make room.

See Also:
Constant Field Values

HOVER_OFFSET_X_FOR_ROBBER

public static final int HOVER_OFFSET_X_FOR_ROBBER
During robber placement, the tooltip is moved this far over to make room.

See Also:
Constant Field Values

BUILD_REQUEST_MAX_DELAY_SEC

protected static int BUILD_REQUEST_MAX_DELAY_SEC
for popup-menu build request, network send maximum delay (seconds)


POPUP_MENU_IGNORE_MS

protected static int POPUP_MENU_IGNORE_MS
for popup-menu build request, length of time after popup to ignore further mouse-clicks. Avoids Windows accidental build by popup-click during game's initial piece placement. (150 ms)


SUPERTEXT_INSET

private static final int SUPERTEXT_INSET
Pixel spacing around superText1, superText2, superTextTop

Since:
1.1.07
See Also:
Constant Field Values

SUPERTEXT_PADDING_HORIZ

private static final int SUPERTEXT_PADDING_HORIZ
Pixel spacing around superText1, superText2, superTextTop

Since:
1.1.07
See Also:
Constant Field Values

HEXWIDTH

private static final int HEXWIDTH
hex size, in unscaled internal-pixels: 55 wide, 64 tall. The road polygon coordinate-arrays (downRoadX, etc) are plotted against a hex of this size.

See Also:
deltaX, deltaY, HALF_HEXHEIGHT, Constant Field Values

HEXHEIGHT

private static final int HEXHEIGHT
hex size, in unscaled internal-pixels: 55 wide, 64 tall. The road polygon coordinate-arrays (downRoadX, etc) are plotted against a hex of this size.

See Also:
deltaX, deltaY, HALF_HEXHEIGHT, Constant Field Values

HALF_HEXHEIGHT

private static final int HALF_HEXHEIGHT
Half of HEXHEIGHT, in unscaled internal pixels, for use with various board graphics. Also == halfdeltaY + 9.

Since:
2.0.00
See Also:
Constant Field Values

DICE_NUMBER_CIRCLE_DIAMETER

private static final int DICE_NUMBER_CIRCLE_DIAMETER
Diameter and font size (unscaled internal-pixels) for dice number circles on hexes.

Since:
1.1.08
See Also:
Constant Field Values

DICE_NUMBER_FONTPOINTS

private static final int DICE_NUMBER_FONTPOINTS
Diameter and font size (unscaled internal-pixels) for dice number circles on hexes.

Since:
1.1.08
See Also:
Constant Field Values

DICE_NUMBER_CIRCLE_COLORS

private static final java.awt.Color[] DICE_NUMBER_CIRCLE_COLORS
Dice number circle background colors on hexes.
 Index:  Dice:  Color:
   0     2, 12  yellow
   1     3, 11
   2     4, 10  orange
   3     5,  9
   4     6,  8  red 

Since:
1.1.08

minSize

private java.awt.Dimension minSize
Minimum required width and height, as determined by options and isRotated. Set in constructor based on PANELX, PANELY. Used by getMinimumSize().

Since:
1.1.08
See Also:
panelMinBW

hasCalledSetSize

private boolean hasCalledSetSize
Ensure that super.setSize is called at least once.

Since:
1.1.08

is6player

protected boolean is6player
The board is configured for 6-player layout (and is isRotated); set in constructor by checking SOCBoard.getBoardEncodingFormat() <= SOCBoard.BOARD_ENCODING_6PLAYER and SOCGame.maxPlayers > 4.

The entire coordinate system is land, except the rightmost hexes are unused (7D-DD-D7 row). The 6-player mode uses hexX_6pl instead of hexX_st for coordinates.

When isLargeBoard, this field is false even if the game has 5 or 6 players. The is6player flag is about the hex layout on the board, not the number of players.

Since:
1.1.08
See Also:
inactiveHexNums, isLargeBoard

isLargeBoard

protected final boolean isLargeBoard
The board is configured Large-Board Format (up to 127x127, oriented like 4-player not 6-player); set in constructor by checking SOCBoard.getBoardEncodingFormat(). The coordinate system is an arbitrary land/water mixture.

When isLargeBoard, isRotated() is false even if the game has 5 or 6 players.

Since:
2.0.00
See Also:
is6player

isRotated

protected boolean isRotated
The board is visually rotated 90 degrees clockwise (6-player: game opt PL > 4) compared to the internal coordinates.

Use this for rotation:

When the board is also scaled, go in this order: Rotate clockwise, then scale up; Scale down, then rotate counterclockwise.

When calculating position at which to draw an image or polygon, remember that rotation changes which corner is considered (0,0), and the image is offset from that corner. (For example, drawHex(Graphics, int) subtracts HEXHEIGHT from x, after rotation but before scaling.)

When isLargeBoard, isRotated is false even if the game has 5 or 6 players.

Since:
1.1.08
See Also:
isScaledOrRotated

isScaledOrRotated

protected boolean isScaledOrRotated
Convenience flag - The board is rotated and/or scaled up. Check both of those flags when transforming between screen coordinates and internal coordinates. Go in this order: Rotate clockwise, then scale up; Scale down, then rotate counterclockwise.

Since:
1.1.08

scaledPanelX

protected int scaledPanelX
actual size on-screen, not internal-pixels size (panelMinBW, panelMinBH)


scaledPanelY

protected int scaledPanelY
actual size on-screen, not internal-pixels size (panelMinBW, panelMinBH)


panelMinBW

protected final int panelMinBW
panelMinBW and panelMinBH are the minimum width and height, in board-internal coordinates (not rotated or scaled). Differs from static PANELX, PANELY for 6-player board and the large board. Differs from minSize because minSize takes isRotated into account, so minSize isn't suitable for use in rescaling formulas.

Since:
1.1.08

panelMinBH

protected final int panelMinBH
panelMinBW and panelMinBH are the minimum width and height, in board-internal coordinates (not rotated or scaled). Differs from static PANELX, PANELY for 6-player board and the large board. Differs from minSize because minSize takes isRotated into account, so minSize isn't suitable for use in rescaling formulas.

Since:
1.1.08

panelMarginX

protected int panelMarginX
Scaled (actual) panel margin on left, in pixels, for narrow boards, if board's unscaled width is less than panelMinBW. Used only when isLargeBoard and not isRotated, otherwise 0. Never less than 0.

Since:
2.0.00

isScaled

protected boolean isScaled
The board is currently scaled larger than panelMinBW x panelMinBH pixels. Use scaleToActualX(int), scaleFromActualX(int), etc to convert between internal and actual screen pixel coordinates.

When the board is also rotated, go in this order: Rotate clockwise, then scale up; Scale down, then rotate counterclockwise.

When this flag is set true, also sets scaledAt.

See Also:
isScaledOrRotated, scaledAt, rescaleBoard(int, int)

scaledAt

protected long scaledAt
Time of last request to resize and repaint, as returned by System.currentTimeMillis(). Used with scaledMissedImage.

See Also:
drawnEmptyAt

scaledMissedImage

protected boolean scaledMissedImage
Flag used while drawing a scaled board. If board size was recently changed, could be waiting for an image to resize. If it still hasn't appeared after 7 seconds, we'll give up and create a new one. (This can happen due to AWT bugs.) Set in drawHex(Graphics, int), checked in drawBoard(Graphics).

See Also:
scaledHexFail, scaledAt, drawnEmptyAt

drawnEmptyAt

private long drawnEmptyAt
Time of start of board repaint, as returned by System.currentTimeMillis(). Used in drawBoardEmpty(Graphics) with scaledMissedImage.

Since:
1.1.08
See Also:
scaledAt

debugShowCoordsTooltip

private boolean debugShowCoordsTooltip
Debugging flag where board item tooltip includes the item's coordinates. When set, the coordinates become part of the hoverText string. Set or cleared with setDebugShowCoordsFlag(boolean), from SOCPlayerInterface debug command =*= showcoords or =*= hidecoords.

Since:
2.0.00
See Also:
SOCBoardPanel.BoardToolTip.setHoverText(String, int)

debugShowPotentials

boolean[] debugShowPotentials
For debugging, flags to show player 0's potential/legal coordinate sets. Sets flagged as shown are drawn in drawBoardEmpty(Graphics). Currently implemented only for the sea board layout (SOCBoardLarge).

Stored in same order as piece types:

Changed via setDebugShowPotentialsFlag(int, boolean, boolean) with SOCPlayerInterface debug command =*= show: n or =*= hide: n, where n is an index shown above or all.

Has package-level visibility, for use by SOCPlayerInterface.updateAtPutPiece(int, int, int, boolean, int).

Since:
2.0.00

diceNumberCircleFont

private java.awt.Font diceNumberCircleFont
Font of dice-number circles appearing on hexes, and dice numbers on cloth villages.

Since:
1.1.08

diceNumberCircleFM

private java.awt.FontMetrics diceNumberCircleFM
FontMetrics of diceNumberCircleFont. Used in hex and village dice numbers.

Since:
1.1.08

hexIDtoNum

private int[] hexIDtoNum
Translate hex ID to hex number to get coords. Invalid (non-hex coordinate) IDs are 0. Null when isLargeBoard.


inactiveHexNums

private boolean[] inactiveHexNums
Hex numbers which aren't drawn, or null. For 6-player board, the rightmost line of hexes (7D-DD-D7) are skipped. Indicate this to drawBoard(Graphics).

Since:
1.1.08

hexX

private int[] hexX
hex coordinates for drawing pieces on the board. Upper-left corner of each hex, left-to-right in each row. Points to hexX_st or hexX_6pl, and hexY_st or hexY_6pl, depending on is6player flag.

Null when isLargeBoard, because of its simpler coordinate encoding. In that case, calculate (x,y) with:

Since:
1.1.08

hexY

private int[] hexY
hex coordinates for drawing pieces on the board. Upper-left corner of each hex, left-to-right in each row. Points to hexX_st or hexX_6pl, and hexY_st or hexY_6pl, depending on is6player flag.

Null when isLargeBoard, because of its simpler coordinate encoding. In that case, calculate (x,y) with:

Since:
1.1.08

hexes

private static java.awt.Image[] hexes
Hex images - shared unscaled original-resolution from IMAGEDIR's GIF files. Image references are copied to scaledHexes from here. Also contains hexBorder.gif, and miscPort.gif for drawing 3:1 ports' base image. For indexes, see loadHexesAndImages(Image[], String, MediaTracker, Toolkit, Class, boolean).

scaledPorts stores the 6 per-facing port overlays from renderPortImages().

See Also:
scaledHexes, rotatHexes

rotatHexes

private static java.awt.Image[] rotatHexes
Hex images - rotated board; from IMAGEDIR/rotat's GIF files. Images from here are copied and/or scaled to scaledHexes/scaledPorts.

Since:
1.1.08
See Also:
hexes

scaledHexes

private java.awt.Image[] scaledHexes
Hex images - private scaled copy, if isScaled. Otherwise points to static copies, either hexes or rotatHexes

See Also:
scaledHexFail

scaledPorts

private java.awt.Image[] scaledPorts
Port images - private copy, rotated and/or scaled if necessary. Contains the 6 per-facing port overlays built in renderPortImages(). miscPort.gif is in hexes along with the land hex images used for 2:1 ports.

See Also:
scaledPortFail

scaledHexFail

private boolean[] scaledHexFail
Hex/port images - Per-image flag to check if rescaling failed, if isScaled.

See Also:
scaledHexes, drawHex(Graphics, int)

scaledPortFail

private boolean[] scaledPortFail
Hex/port images - Per-image flag to check if rescaling failed, if isScaled.

See Also:
scaledHexes, drawHex(Graphics, int)

dice

private static java.awt.Image[] dice
Dice number pictures (for the arrow; the hex dice numbers use Graphics.drawString).

See Also:
DICE_SZ

DICE_SZ

private static final int DICE_SZ
Dice number graphic size in pixels; fits in a 25 x 25 square.

See Also:
dice, Constant Field Values

scaledVertRoadX

private int[] scaledVertRoadX
Coordinate arrays for drawing the playing pieces. Local copy if isScaled, otherwise points to static arrays.


scaledVertRoadY

private int[] scaledVertRoadY
Coordinate arrays for drawing the playing pieces. Local copy if isScaled, otherwise points to static arrays.


scaledUpRoadX

private int[] scaledUpRoadX
road looks like "/"


scaledUpRoadY

private int[] scaledUpRoadY
road looks like "/"


scaledDownRoadX

private int[] scaledDownRoadX
road looks like "\"


scaledDownRoadY

private int[] scaledDownRoadY
road looks like "\"


scaledSettlementX

private int[] scaledSettlementX
settlement


scaledSettlementY

private int[] scaledSettlementY
settlement


scaledCityX

private int[] scaledCityX
city


scaledCityY

private int[] scaledCityY
city


scaledShipX

private int[] scaledShipX
ship


scaledShipY

private int[] scaledShipY
ship


scaledFortressX

private int[] scaledFortressX
fortress (scenario _SC_PIRI)


scaledFortressY

private int[] scaledFortressY
fortress (scenario _SC_PIRI)


scaledVillageX

private int[] scaledVillageX
village (scenario _SC_CLVI)


scaledVillageY

private int[] scaledVillageY
village (scenario _SC_CLVI)


scaledWarshipX

private int[] scaledWarshipX
warship (scenario _SC_PIRI)


scaledWarshipY

private int[] scaledWarshipY
warship (scenario _SC_PIRI)


scaledRobberX

private int[] scaledRobberX
robber


scaledRobberY

private int[] scaledRobberY
robber


scaledPortArrowsX

private int[][] scaledPortArrowsX
For port hexes, the triangular arrowheads towards port settlement nodes.

Since:
1.1.20
See Also:
portArrowsX, rescaleCoordinateArrays()

scaledPortArrowsY

private int[][] scaledPortArrowsY
For port hexes, the triangular arrowheads towards port settlement nodes.

Since:
1.1.20
See Also:
portArrowsX, rescaleCoordinateArrays()

scaledArrowXL

private int[] scaledArrowXL
Current-player arrow, left-pointing and right-pointing.

Since:
1.1.00
See Also:
rescaleCoordinateArrays()

scaledArrowXR

private int[] scaledArrowXR
Current-player arrow, left-pointing and right-pointing.

Since:
1.1.00
See Also:
rescaleCoordinateArrays()

scaledArrowY

private int[] scaledArrowY
Current-player arrow, left-pointing and right-pointing.

Since:
1.1.00
See Also:
rescaleCoordinateArrays()

hexCornersX

private static final int[] hexCornersX
hex corners, clockwise from top-center, as located in waterHex.gif, hexBorder.gif, and other hex graphics: (27,0) (54,16) (54,46) (27,62) (0,46) (0,16). If rotated 90deg clockwise, clockwise from center-right, would be: (63,27) (47,54) (16,54) (0,27) (16,0) (47,0); swap x and y from these arrays and add hexCornersY_RotatedOffset[].

Since:
1.1.07
See Also:
hexCornersY

hexCornersY

private static final int[] hexCornersY
hex corners, clockwise from top-center.

Since:
1.1.07
See Also:
hexCornersX, hexCornersY_RotatedOffset, HEXY_OFF_SLOPE_HEIGHT

hexCornersY_RotatedOffset

private static final int[] hexCornersY_RotatedOffset
Offset to add to hexCornersY[] coordinates when used as (y,x) on rotated board.

Since:
1.1.20

scaledHexCornersX

private int[] scaledHexCornersX
hex corner coordinates, as scaled to current board size.

Since:
1.1.07
See Also:
hexCornersX, rescaleCoordinateArrays()

scaledHexCornersY

private int[] scaledHexCornersY
hex corner coordinates, as scaled to current board size.

Since:
1.1.07
See Also:
hexCornersX, rescaleCoordinateArrays()

ptrOldX

private int ptrOldX
Previous pointer coordinates for interface; the mouse was at this location when hilight was last determined in mouseMoved(MouseEvent).


ptrOldY

private int ptrOldY
Previous pointer coordinates for interface; the mouse was at this location when hilight was last determined in mouseMoved(MouseEvent).


hoverTip

private SOCBoardPanel.BoardToolTip hoverTip
(tooltip) Hover text for info on pieces/parts of the board. Its mode uses boardpanel mode constants. Also contains "hovering" road/settlement/city near mouse pointer.

See Also:
hilight

popupMenu

private SOCBoardPanel.BoardPopupMenu popupMenu
Context menu for build/cancel-build


popupMenuSystime

private long popupMenuSystime
Tracks last menu-popup time. Avoids misinterpretation of popup-click with placement-click during initial placement: On Windows, popup-click must be caught in mouseReleased, but mousePressed is called immediately afterwards.


buildReqTimerTask

protected SOCBoardPanel.BoardPanelSendBuildTask buildReqTimerTask
For right-click build menu; used for fallback part of client-server-client communication of a build request. Created whenever right-click build request sent. This is the fallback for the normal method:
  SOCBoardPanel.popupExpectingBuildRequest
  SOCPlayerInterface.updateAtGameState
  SOCBoardPanel.popupFireBuildingRequest
 


superText1

private java.lang.String superText1
Text to be displayed as 2 lines superimposed over center of the board graphic (during game setup). Either supertext2, or both, can be null to display nothing.

Since:
1.1.07
See Also:
setSuperimposedText(String, String)

superText2

private java.lang.String superText2
Text to be displayed as 2 lines superimposed over center of the board graphic (during game setup). Either supertext2, or both, can be null to display nothing.

Since:
1.1.07
See Also:
setSuperimposedText(String, String)

superText1_w

private int superText1_w
Width, height of superText1 and superText2 if known, or 0. Calculated in drawSuperText(Graphics).

Since:
1.1.07

superText_h

private int superText_h
Width, height of superText1 and superText2 if known, or 0. Calculated in drawSuperText(Graphics).

Since:
1.1.07

superText_des

private int superText_des
Width, height of superText1 and superText2 if known, or 0. Calculated in drawSuperText(Graphics).

Since:
1.1.07

superText2_w

private int superText2_w
Width, height of superText1 and superText2 if known, or 0. Calculated in drawSuperText(Graphics).

Since:
1.1.07

superTextBox_x

private int superTextBox_x
Width, height of superText1 and superText2 if known, or 0. Calculated in drawSuperText(Graphics).

Since:
1.1.07

superTextBox_y

private int superTextBox_y
Width, height of superText1 and superText2 if known, or 0. Calculated in drawSuperText(Graphics).

Since:
1.1.07

superTextBox_w

private int superTextBox_w
Width, height of superText1 and superText2 if known, or 0. Calculated in drawSuperText(Graphics).

Since:
1.1.07

superTextBox_h

private int superTextBox_h
Width, height of superText1 and superText2 if known, or 0. Calculated in drawSuperText(Graphics).

Since:
1.1.07

superTextTop

private java.lang.String superTextTop
Text to be displayed as 1 line superimposed over the top-center of the board graphic (during game play). Can be null to display nothing.

Since:
1.1.08
See Also:
setSuperimposedTopText(String)

superTextTop_w

private int superTextTop_w
Width, height of superTextTop if known, or 0. Calculated in drawSuperTextTop(Graphics). Y-position of top of this textbox is SUPERTEXT_INSET.

Since:
1.1.08

superTextTop_h

private int superTextTop_h
Width, height of superTextTop if known, or 0. Calculated in drawSuperTextTop(Graphics). Y-position of top of this textbox is SUPERTEXT_INSET.

Since:
1.1.08

superTextTopBox_x

private int superTextTopBox_x
Width, height of superTextTop if known, or 0. Calculated in drawSuperTextTop(Graphics). Y-position of top of this textbox is SUPERTEXT_INSET.

Since:
1.1.08

superTextTopBox_w

private int superTextTopBox_w
Width, height of superTextTop if known, or 0. Calculated in drawSuperTextTop(Graphics). Y-position of top of this textbox is SUPERTEXT_INSET.

Since:
1.1.08

superTextTopBox_h

private int superTextTopBox_h
Width, height of superTextTop if known, or 0. Calculated in drawSuperTextTop(Graphics). Y-position of top of this textbox is SUPERTEXT_INSET.

Since:
1.1.08

hilight

private int hilight
Edge or node being pointed to. When placing a road/settlement/city, used for coordinate of "ghost" piece under the mouse pointer. 0 when nothing is hilighted. -1 for a road at edge 0x00.

During PLACE_INIT_ROAD, this can be either a road or a ship. Along coastal edges it could be either one. Default to road: Check player.isPotentialRoad(hilight) first, then .isPotentialShip. Player can right-click to build an initial ship along a coastal edge.

Hilight is drawn in drawBoard(Graphics). Value updated in mouseMoved(MouseEvent). Cleared in clearModeAndHilight(int).

See Also:
hoverTip

hilightIsShip

private boolean hilightIsShip
If hilighting an edge, is the hilight a ship and not a road?

Since:
2.0.00

moveShip_fromEdge

private int moveShip_fromEdge
During MOVE_SHIP mode, the edge coordinate from which we're moving the ship. 0 otherwise. The hovering "move-to" location under the mouse pointer is hilight and then (at left-click to select destination, or right-click to show the menu) is moveShip_toEdge.

Since:
2.0.00
See Also:
moveShip_isWarship

moveShip_toEdge

private int moveShip_toEdge
During MOVE_SHIP mode, the edge coordinate to which we're moving the ship, 0 otherwise. While choosing a location to move to, the hovering ship under the mouse pointer is hilight, but when the menu appears (on Windows at least) hilight becomes 0.

Since:
2.0.00
See Also:
tryMoveShipToEdge(), moveShip_fromEdge

moveShip_isWarship

private boolean moveShip_isWarship
During MOVE_SHIP mode, true if the ship being moved is a warship in scenario option _SC_PIRI.

Since:
2.0.00
See Also:
moveShip_fromEdge

edgeMap

private int[] edgeMap
Map grid sectors (from unscaled on-screen coordinates) to hex edges. Invalid edges are 0. The grid has 15 columns (each being 1/2 of a hex wide) and 23 rows (each 1/3 hex tall). This maps graphical coordinates to the board coordinate system.

The edge coordinate number at grid (x,y) is in edgeMap[x + (y * 15)]. If edgeMap[x,y] == 0, it's not a valid edge coordinate.

On the 4-player board, row 0 is the top of the topmost row of water hexes. Here are the grid (x,y) values for the edges of the top-left land hex on the 4-player board, and to the right and down; its top is in y=3 of this grid:

             ^               ^
       (4,3)   (5,3)   (6,3)   (7,3)
     |               |
   (4,4)           (6,4)
   (4,5)           (6,5)
     |               |
(3,6)  (4,6)   (5,6)   (6,6)   (7,6)
             v               v
             |               |
           (5,7)           (7,7)
           (5,8)           (7,8) 

The 6-player board is similar to the 4-player layout, but its top-left land hex edges start at (3,0) instead of (4,3), and it is visually rotated 90 degrees on screen, but not rotated in this coordinate system, versus the 4-player board.

Note: For the 6-player board, edge 0x00 is a valid edge that can be built on. It is marked here as -1, since a value of 0 marks an invalid edge in this map.

In 6-player mode, there is an extra ring of water/port hexes on the outside, which isn't within the coordinate system. So this grid is shifted +1 column, +3 rows.

Not used when isLargeBoard.

See Also:
findEdge(int, int, boolean), initEdgeMapAux(int, int, int, int, int)

nodeMap

private int[] nodeMap
Map grid sectors (from unscaled on-screen coordinates) to hex nodes. Invalid nodes are 0. The grid has 15 columns and 23 rows. This maps graphical coordinates to the board coordinate system. Each row of hexes touches 3 columns and 5 rows here. For instance, hex 0x35 has its top-center point (node) in row y=6, and its bottom-center point in row y=10, of this grid. Its left edge is column x=3, and right is column x=5.

The node number at grid (x,y) is nodeMap[x + (y * 15)].

In 6-player mode, there is an extra ring of water/port hexes on the outside, which isn't within the coordinate system. So this grid appears shifted +1 column, +3 rows on screen, to account for the outside ring.

In 4-player mode, here are the nodeMap coordinates (x,y) for the left end of the topmost row of water hexes:

       (4,0)       (6,0)
     /       \   /      \
 (3,1)       (5,1)
 (3,2)       (5,2)
 (3,3)       (5,3)
 /   \       /   \      /
       (3,4)       (6,4)
Not used when isLargeBoard.

See Also:
findNode(int, int), initNodeMapAux(int, int, int, int, int)

hexMap

private int[] hexMap
Map grid sectors (from unscaled on-screen coordinates) to hexes. Invalid hexes are 0. The grid has 15 columns (each being 1/2 of a hex wide) and 23 rows (each 1/3 hex tall). This maps graphical coordinates to the board coordinate system. Not used when isLargeBoard.

See Also:
findHex(int, int)

game

private SOCGame game
The game which this board is a part of


board

private SOCBoard board
The board in the game


player

private SOCPlayer player
The player that is using this interface.

See Also:
playerNumber

playerNumber

private int playerNumber
player number of our player if in a game, or -1.

Since:
1.1.00

otherPlayer

private SOCPlayer otherPlayer
When in "consider" mode, this is the player we're talking to


buffer

private java.awt.Image buffer
offscreen buffer of everything (board, pieces, hovering pieces, tooltip), to prevent flicker.

See Also:
emptyBoardBuffer

emptyBoardBuffer

private java.awt.Image emptyBoardBuffer
offscreen buffer of board without any pieces placed, to prevent flicker. If the board layout changes (at start of game, for example), call flushBoardLayoutAndRepaint() to clear the buffered copy.

Since:
1.1.08
See Also:
buffer

mode

private int mode
Modes of interaction; for correlation to game state, see updateMode(). For tooltip's mode, see SOCBoardPanel.BoardToolTip.hoverMode.


initstlmt

private int initstlmt
This holds the coord of the last stlmt placed in the initial phase.


playerInterface

private SOCPlayerInterface playerInterface
the player interface that this board is a part of


robberGhostFill

protected java.awt.Color[] robberGhostFill
Cached colors, for use for robber's "ghost" (previous position) when moving the robber. Values are determined the first time the robber is ghosted on that type of tile. Index ranges from 0 to SOCBoard.MAX_ROBBER_HEX.

See Also:
ColorSquare, drawRobber(Graphics, int, boolean, boolean)

robberGhostOutline

protected java.awt.Color[] robberGhostOutline
Cached colors, for use for robber's "ghost" (previous position) when moving the robber. Values are determined the first time the robber is ghosted on that type of tile. Index ranges from 0 to SOCBoard.MAX_ROBBER_HEX.

See Also:
ColorSquare, drawRobber(Graphics, int, boolean, boolean)

ROW_START_HEXNUM

private static final int[] ROW_START_HEXNUM
Hex numbers of start of each row of hexes in the board coordinates. Does not apply to v3 encoding (SOCBoardLarge).

Since:
1.1.08
Constructor Detail

SOCBoardPanel

public SOCBoardPanel(SOCPlayerInterface pi)
create a new board panel in a game interface. The minimum size needed on-screen is based on the game options. After construction, call getMinimumSize() to read it.

Parameters:
pi - the player interface that spawned us
Method Detail

initCoordMappings

private void initCoordMappings()
During the constructor, initialize the board-coordinate to screen-coordinate mappings: edgeMap, nodeMap, hexMap, hexIDtoNum, hexX, hexY, inactiveHexNums.

Not used when isLargeBoard.

Since:
2.0.00

initEdgeMapAux

private final void initEdgeMapAux(int x1,
                                  int y1,
                                  int x2,
                                  int y2,
                                  int startHex)
Initialize edgeMap's valid edges across 1 row of hexes, for use by findEdge(int, int, boolean).

For details of edgeMap's layout and usage, see its javadoc. For more details of the initialization algorithm used in this method, see comments within initNodeMapAux(int, int, int, int, int).

Not applicable when isLargeBoard.

Parameters:
x1 - Leftmost x-value to init within edgeMap; the x-value of the row's leftmost vertical edge
y1 - Topmost y-value to init within edgeMap; the y-value of the upper angled edges of the hex (angled "/" and "\")
x2 - Rightmost x-value to init; the x-value of the row's rightmost vertical edge
y2 - Bottommost y-value to init; the y-value of the lower angled edges of the hex (angled "\" and "/"), should be y1 + 3.
startHex - Hex coordinate of row's first valid hex; this row's edgeMap[x,y] values will be set to edge coordinates offset from startHex.

initHexMapAux

private final void initHexMapAux(int x1,
                                 int y1,
                                 int x2,
                                 int y2,
                                 int startHex)

initNodeMapAux

private final void initNodeMapAux(int x1,
                                  int y1,
                                  int x2,
                                  int y2,
                                  int startHex)
Within nodeMap, set the node coordinates within a rectangular section from (x1,y1) to (x2,y2) covering all nodes of one horizontal row of hexes.

The grid maps graphical coordinates to the board coordinate system. Each row of hexes covers 5 rows here. For instance, hex 0x35 has its top-center point (node) in row 6, and its bottom-center point in row 10. All 6 nodes of each hex in range will be initialized within nodeMap.

For node coordinates, see RST dissertation figure A2. For hex coordinates, see figure A1.

initEdgeMapAux(int, int, int, int, int) uses a similar structure.

Not applicable when isLargeBoard.

Parameters:
x1 - Starting x-coordinate within nodeMap's index; should correspond to left edge of startHex
y1 - Starting y-coordinate within nodeMap's index; should correspond to top point of startHex
x2 - Ending x-coordinate; should correspond to right edge of the last hex in the row of hexes being initialized. Each hex is 2 units wide in the grid.
y2 - Ending y-coordinate; should correspond to bottom point of startHex, and thus should be y1 + 4.
startHex - Starting hex ID (0x-coordinate of first hex in this row), to use with nodeMap[x1, y1].

initHexIDtoNumAux

private final void initHexIDtoNumAux(int begin,
                                     int end,
                                     int num)

getPreferredSize

public java.awt.Dimension getPreferredSize()
DOCUMENT ME!

Overrides:
getPreferredSize in class java.awt.Component
Returns:
DOCUMENT ME!

getMinimumSize

public java.awt.Dimension getMinimumSize()
Minimum required width and height, as determined by options and isRotated().

Minimum size is set in the constructor. On the classic 4-player and 6-player boards, the size is based on PANELX and PANELY. When SOCGame.hasSeaBoard, the size is based on SOCBoard.getBoardWidth() and .getBoardHeight().

Overrides:
getMinimumSize in class java.awt.Component
Returns:
minimum size

setSize

public void setSize(int newW,
                    int newH)
             throws java.lang.IllegalArgumentException
Set the board to a new size, rescale graphics and repaint if needed.

Overrides:
setSize in class java.awt.Component
Parameters:
newW - New width in pixels, no less than getMinimumSize().width
newH - New height in pixels, no less than getMinimumSize().height
Throws:
java.lang.IllegalArgumentException - if newW or newH is too small but not 0. During initial layout, the layoutmanager may make calls to setSize(0,0); such a call is passed to super without scaling graphics.

setSize

public void setSize(java.awt.Dimension sz)
             throws java.lang.IllegalArgumentException
Set the board to a new size, rescale graphics and repaint if needed.

Overrides:
setSize in class java.awt.Component
Parameters:
sz - New size in pixels, no less than panelMinBW wide by panelMinBH tall
Throws:
java.lang.IllegalArgumentException - if sz is too small but not 0. During initial layout, the layoutmanager may make calls to setSize(0,0); such a call is passed to super without scaling graphics.

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
               throws java.lang.IllegalArgumentException
Set the board to a new location and size, rescale graphics and repaint if needed. Called from SOCPlayerInterface.doLayout().

Overrides:
setBounds in class java.awt.Component
Parameters:
x - New location's x-coordinate
y - new location's y-coordinate
w - New width in pixels, no less than PANELX (or if rotated, PANELY})
h - New height in pixels, no less than PANELY (or if rotated, PANELX)
Throws:
java.lang.IllegalArgumentException - if w or h is too small but not 0. During initial layout, the layoutmanager may make calls to setBounds(0,0,0,0); such a call is passed to super without scaling graphics.

pieceValueUpdated

public void pieceValueUpdated(SOCPlayingPiece piece)
A playing piece's value was updated: _SC_CLVI village cloth count, or _SC_PIRI pirate fortress strength. Repaint that piece (if needed) on the board.

Parameters:
piece - Piece that was updated, includes its new value
Since:
2.0.00

flushBoardLayoutAndRepaint

public void flushBoardLayoutAndRepaint()
Clear the board layout (as rendered in the empty-board buffer) and trigger a repaint.

Since:
1.1.08
See Also:
SOCPlayerInterface.updateAtNewBoard()

flushBoardLayoutAndRepaintIfDebugShowPotentials

public void flushBoardLayoutAndRepaintIfDebugShowPotentials()
Clear the board layout (as rendered in the empty-board buffer) and trigger a repaint, only if we're showing potential/legal settlements/roads/cities for debug purposes.

Since:
2.0.00

rescaleBoard

private void rescaleBoard(int newW,
                          int newH)
                   throws java.lang.IllegalArgumentException
Set the board fields to a new size, rescale graphics if needed. Does not call repaint. Does not call setSize. Will update isScaledOrRotated, scaledPanelX, and other fields. Calls renderBorderedHex(Image, Image, Color) and renderPortImages().

Parameters:
newW - New width in pixels, no less than PANELX (or if rotated, PANELY})
newH - New height in pixels, no less than PANELY (or if rotated, PANELX)
Throws:
java.lang.IllegalArgumentException - if newW or newH is too small but not 0. During initial layout, the layoutmanager may cause calls to rescaleBoard(0,0); such a call is ignored, no rescaling of graphics is done.

renderBorderedHex

private java.awt.Image renderBorderedHex(java.awt.Image hex,
                                         java.awt.Image hexBorder,
                                         java.awt.Color borderColor)
Render a border around the edge of this hex, returning a new image.

Parameters:
hex - Un-bordered hex image
hexBorder - Hex border pixel mask from hexBorder.gif, or null to draw vector border
borderColor - Color to paint the rendered border, from HEX_BORDER_COLORS or ROTAT_HEX_BORDER_COLORS
Returns:
a new Image for the bordered hex
Since:
1.1.20

renderPortImages

private void renderPortImages()
Based on the waterHex image, render the 6 port images (1 per "facing" rotation), each with arrows in its 2 settlement directions. Fills scaledPorts, starting from waterHex.gif previously loaded into scaledHexes[0].

Before calling this method, call rescaleCoordinateArrays().

Since:
1.1.20

rescaleCoordinateArrays

private void rescaleCoordinateArrays()
Scale coordinate arrays for drawing pieces (from internal coordinates to actual on-screen pixels), or (if not isScaled) point to static arrays. Called from constructor and rescaleBoard(int, int).


scaleCopyToActualX

public int[] scaleCopyToActualX(int[] xorig)
Rescale to actual screen coordinates - Create a copy of array, and scale the copy's elements as X coordinates.

Parameters:
xorig - Int array to be scaled; each member is an x-coordinate.
Returns:
Scaled copy of xorig
See Also:
scaleToActualX(int[]), rotateScaleCopyYToActualX(int[], int, boolean)

scaleCopyToActualY

public int[] scaleCopyToActualY(int[] yorig)
Rescale to actual screen coordinates - Create a copy of array, and scale the copy's elements as Y coordinates.

Parameters:
yorig - Int array to be scaled; each member is a y-coordinate.
Returns:
Scaled copy of yorig
See Also:
scaleToActualY(int[])

rotateScaleCopyYToActualX

public int[] rotateScaleCopyYToActualX(int[] yorig,
                                       int width,
                                       boolean rescale)
Copy and rotate this array of y-coordinates, optionally also rescaling. Rotates internal to actual (clockwise): P'=(width-y, x)

Parameters:
yorig - Array to copy and rotate, not null
width - Width to rotate against
rescale - Should we also rescale, same formula as scaleCopyToActualX(int[])?
Returns:
Rotated copy of yorig for use as x-coordinates
Since:
1.1.08

getScaledImageUp

public static final java.awt.image.BufferedImage getScaledImageUp(java.awt.Image src,
                                                                  int w,
                                                                  int h)
Scale up an image with decent quality. Convenience method to call instead of obsolete Image.getScaledInstance(int, int, int). Calls Graphics2D.drawImage (src, 0, 0, w, h, null) using RenderingHints.VALUE_INTERPOLATION_BICUBIC.

For more info see the Java2D team blog 2007 post "The Perils of Image.getScaledInstance()" by ChrisAdamson.

Parameters:
src - Source image to scale up; assumes is transparent, not opaque.
w - Scale up to this width
h - Scale up to this height
Returns:
the scaled image
Since:
1.1.20

setDebugShowCoordsFlag

void setDebugShowCoordsFlag(boolean setOn)
Set or clear the debug flag where the board item tooltip includes the item's coordinates. Takes effect the next time the mouse moves.

Parameters:
setOn -
Since:
2.0.00
See Also:
SOCBoardPanel.BoardToolTip.setHoverText(String, int)

setDebugShowPotentialsFlag

void setDebugShowPotentialsFlag(int pieceType,
                                boolean setPotential,
                                boolean setOn)
Set or clear a debug flag to show player 0's potential/legal coordinate sets. Currently implemented only for the sea board layout (SOCBoardLarge).

Parameters:
pieceType - Piece type; 0=road, 1=settle, 2=city, 3=ship; Use 8 for land hexes, 9 for nodes on board. Or, -1 for all. See debugShowPotentials javadoc for all values.
setPotential - If true, show/hide the potential set, not the legal set
setOn - If true, set the flag; if false, clear it
Since:
2.0.00

paint

public void paint(java.awt.Graphics g)
Redraw the board using double buffering. Don't call this directly, use Component.repaint() instead.

See drawBoard(Graphics) for related painting methods.

To protect against bugs, paint contains a try-catch that will print stack traces to the player chat print area.

Overrides:
paint in class java.awt.Canvas

update

public void update(java.awt.Graphics g)
Overriden so the peer isn't painted, which clears background. Don't call this directly, use Component.repaint() instead.

Overrides:
update in class java.awt.Canvas

drawHex

private final void drawHex(java.awt.Graphics g,
                           int hexNum)
Draw a board tile by its hex number (v1 or v2 board encoding). Hex type and port info (if any) are looked up from SOCBoard.getHexLayout() and hexNum.

Not used if isLargeBoard. When isLargeBoard, call drawHex(Graphics, int, int, int, int, int) instead.

Parameters:
g - graphics
hexNum - hex location number (0-36)

drawHex

private final void drawHex(java.awt.Graphics g,
                           int x,
                           int y,
                           int hexType,
                           int portFacing,
                           int hexNum)
Draw a land, water, or port hex tile at a given location. Use hexType to determine the hex graphic, and portFacing to determine a port overlay (if any). When hexNum is -1, no dice number is drawn. Otherwise, also draw the dice number for this hex (if any).

Parameters:
g - graphics
x - board-graphics x-coordinate to draw at; upper-left corner of hex
y - board-graphics y-coordinate to draw at; upper-left corner of hex
hexType - hex type, as in SOCBoard.getHexTypeFromCoord(int); also the index into hexes. If drawing a port (portFacing != -1), hexType is SOCBoard.getPortTypeFromNodeCoord(int), such as SOCBoard.SHEEP_PORT or SOCBoard.MISC_PORT.
portFacing - port facing (1-6), or -1 for no port: the edge of the port's hex touching land, which contains 2 nodes where player can build a port settlement/city. Valid range is SOCBoard.FACING_NE to SOCBoard.FACING_NW.
hexNum - hex location number (0-36) to look up its dice number, or -1 if this isn't a valid hex number or if the dice number shouldn't be drawn. When isLargeBoard, pass in the hex coordinate as hexNum.
Since:
1.1.08

drawRobber

private final void drawRobber(java.awt.Graphics g,
                              int hexID,
                              boolean fullNotGhost,
                              boolean fillNotOutline)
Draw the robber.

The pirate ship (if any) is drawn via drawRoadOrShip(Graphics, int, int, boolean, boolean, boolean).

Parameters:
g - Graphics context
hexID - Board hex encoded position
fullNotGhost - Draw with normal colors, not faded-out "ghost" (as during PLACE_ROBBER movement)
fillNotOutline - Fill the robber, not just outline (as for previous robber position)

drawRoadOrShip

private final void drawRoadOrShip(java.awt.Graphics g,
                                  int edgeNum,
                                  int pn,
                                  boolean isHilight,
                                  boolean isRoadNotShip,
                                  boolean isWarship)
draw a road or ship along an edge. Or, draw the pirate ship in the center of a hex.

Parameters:
g - graphics
edgeNum - Edge number of this road or ship; accepts -1 for edgeNum 0x00. For the pirate ship in the middle of a hex, edgeNum can be a hex coordinate, and pn must be -2 or -3.
pn - Player number, or -1 for a white outline or fill color (depending on isHilight) or -2 for the black pirate ship, -3 for the previous-pirate outline.
isHilight - Is this the hilight for showing a potential placement?
isRoadNotShip - True to draw a road; false to draw a ship if isLargeBoard
isWarship - True to draw a war ship (not normal ship) if isLargeBoard, for scenario _SC_PIRI

drawSettlement

private final void drawSettlement(java.awt.Graphics g,
                                  int nodeNum,
                                  int pn,
                                  boolean isHilight,
                                  boolean outlineOnly)
draw a settlement


drawCity

private final void drawCity(java.awt.Graphics g,
                            int nodeNum,
                            int pn,
                            boolean isHilight)
draw a city


drawSettlementOrCity

private final void drawSettlementOrCity(java.awt.Graphics g,
                                        int nodeNum,
                                        int pn,
                                        boolean isHilight,
                                        boolean outlineOnly,
                                        boolean isCity)
draw a settlement or city; they have the same logic for determining (x,y) from nodeNum.

Parameters:
outlineOnly - If set for settlement, draw only the outline, not the filled polygon. Ignored when isCity.
Since:
1.1.08

drawSeaEdgeLines

private void drawSeaEdgeLines(java.awt.Graphics g,
                              java.awt.Color co,
                              java.util.Collection<java.lang.Integer> lse)
Draw a dotted line with some thickness at each of these sea edge coordinates. Unless a color is specified, client must have an active player. Calls drawSeaEdgeLine(Graphics, int).

Parameters:
g - Graphics
co - Color for lines, or null to use SOCPlayerInterface.getPlayerColor(int); if null, client must have an active playerNumber.
lse - Set of edge coordinates, or null
Since:
2.0.00

drawSeaEdgeLine

private final void drawSeaEdgeLine(java.awt.Graphics g,
                                   int edge)
For drawing the player's permitted sea edges for ships, draw a line covering the middle 60% of this edge on the board (leaves out 20% on each end). For efficiency, the player color and line stroke must be set before calling this method.

Parameters:
edge - Edge coordinate
Since:
2.0.00

drawFortress

private final void drawFortress(java.awt.Graphics g,
                                SOCFortress fo,
                                int pn,
                                boolean isHilight)
Draw a pirate fortress, for scenario SC_PIRI.

Parameters:
fo - Fortress
pn - Player number, for fortress color
isHilight - Use hilight/ghosted player color?
Since:
2.0.00

drawVillage

private void drawVillage(java.awt.Graphics g,
                         SOCVillage v)
Draw a cloth trade village (used in some scenarios in the large sea board). Villages are drawn yellow unless v.getCloth() is depleted to 0, those are light gray to show how close the game is to an end-game condition.

Same logic for determining (x,y) from v.getCoordinates() node as drawSettlementOrCity(Graphics, int, int, boolean, boolean, boolean).

Parameters:
v - Village
Since:
2.0.00

drawMarker

private final void drawMarker(java.awt.Graphics g,
                              int x,
                              int y,
                              java.awt.Color color,
                              int val)
Draw a marker (village symbol) centered at a final (x,y) coordinate.

Parameters:
x - Marker center x, must be already scaled and/or rotated
y - Marker center x, must be already scaled and/or rotated
color - Color to fill the marker
val - Value to show on the marker, or -1 for none
Since:
2.0.00

drawArrow

private final void drawArrow(java.awt.Graphics g,
                             int pnum,
                             int diceResult)
draw the arrow that shows whose turn it is.

Parameters:
g - Graphics
pnum - Current player number. Player positions are clockwise from top-left:
For the standard 4-player board:
0 for top-left, 1 for top-right, 2 for bottom-right, 3 for bottom-left
For the 6-player board:
0 for top-left, 1 for top-right, 2 for middle-right, 3 for bottom-right, 4 for bottom-left, 5 for middle-left.
diceResult - Roll result to show, if rolled. To show, diceResult must be at least 2, and gamestate not SOCGame.PLAY.

drawPortsRing

private final void drawPortsRing(java.awt.Graphics g)
for the 6-player board (if is6player), draw the ring of surrounding water/ports. This is outside the coordinate system, and doesn't have hex numbers, and so can't be drawn in the standard drawHex loop.

Since:
1.1.08
See Also:
drawPorts_LargeBoard(Graphics)

drawPorts_LargeBoard

private final void drawPorts_LargeBoard(java.awt.Graphics g)
Draw the ports for the large board. These can occur anywhere on the board.

Since:
2.0.00
See Also:
drawPortsRing(Graphics)

drawBoard

private void drawBoard(java.awt.Graphics g)
Draw the whole board, including pieces and tooltip (hilight, hoverTip) if applicable. The basic board without pieces is drawn just once, then buffered. If the board layout changes (at start of game, for example), call flushBoardLayoutAndRepaint() to clear the buffered copy.

See Also:
drawBoardEmpty(Graphics)

drawBoard_SC_FTRI_placePort

private final void drawBoard_SC_FTRI_placePort(java.awt.Graphics g)
Scenario game option _SC_FTRI: In board mode SC_FTRI_PLACE_PORT, draw the possible coastal edges where the port can be placed, and if the hilight cursor is at such an edge, draw the port semi-transparently and a solid hilight line at the edge.

Since:
2.0.00

drawBoardEmpty

private void drawBoardEmpty(java.awt.Graphics g)
Draw the whole board (water, hexes, ports, numbers) but no placed pieces. This is drawn once, then stored. If the board layout changes (at start of game or fog hex reveal, for example), call flushBoardLayoutAndRepaint() to clear the buffered copy.

For scenario option _SC_CLVI, drawBoardEmpty draws the board's SOCVillages.

If panelMarginX != 0, do not translate g before calling. This method will internally translate.

Parameters:
g - Graphics, typically from emptyBoardBuffer
Since:
1.1.08
See Also:
SOCPlayerInterface.updateAtNewBoard()

drawBoardEmpty_drawPiratePath

private final void drawBoardEmpty_drawPiratePath(java.awt.Graphics g,
                                                 int[] ppath)
For the _SC_PIRI game scenario on SOCBoardLarge, draw the path that the pirate fleet takes around the board.

Parameters:
ppath - Path of hex coordinates

drawBoardEmpty_specialEdges

private final void drawBoardEmpty_specialEdges(java.awt.Graphics g)
For the _SC_FTRI game scenario on SOCBoardLarge, draw markers at all Special Edges for the players to reach and be rewarded.

Each marker's color will be determined by its edge's type, such as SOCBoardLarge.SPECIAL_EDGE_DEV_CARD. Unknown types will be drawn gray.

Since:
2.0.00

drawBoardEmpty_specialNodes

private final void drawBoardEmpty_specialNodes(java.awt.Graphics g,
                                               java.lang.String partKey,
                                               java.awt.Color color)
For a game scenario on SOCBoardLarge, draw markers at a set of Special Nodes for the players to reach and be rewarded, retrieved with SOCBoardLarge.getAddedLayoutPart(String).

Parameters:
partKey - Key string for the added layout part, for SOCBoardLarge.getAddedLayoutPart(String)
color - Color to fill the markers
Since:
2.0.00

drawBoardEmpty_drawDebugShowPotentials

private void drawBoardEmpty_drawDebugShowPotentials(java.awt.Graphics g)
                                             throws java.lang.IllegalStateException
If any bit in debugShowPotentials[] is set, besides 8, draw it on the board. Shows potential/legal placement locations for player 0. (debugShowPotentials[8] is drawn in the per-hex loop of drawBoardEmpty(Graphics)).

Note: Currently implemented only for isLargeBoard only for now (TODO).

Throws:
java.lang.IllegalStateException - if ! isLargeBoard; temporary restriction
Since:
2.0.00

drawBoardEmpty_drawDebugShowPotentialRoad

private final void drawBoardEmpty_drawDebugShowPotentialRoad(java.awt.Graphics g,
                                                             int x,
                                                             int y,
                                                             int r,
                                                             int c,
                                                             boolean isVert,
                                                             java.awt.Color co,
                                                             int offset)
Draw around one potential/legal road edge, for drawBoardEmpty_drawDebugShowPotentials(Graphics). (x,y) is the center of the edge.

For large board only for now (TODO).

Parameters:
g - Graphics
x - Pixel x-coordinate of center of this edge
y - Pixel y-coordinate of center of this edge
r - Board row coordinate of this edge
c - Board column coordinate of this edge
isVert - Is this edge vertical (running north-south), not diagonal?
co - Color to draw the edge
offset - Approx pixel offset, outwards parallel to road

drawSuperText

private void drawSuperText(java.awt.Graphics g)
Draw superText1, superText2; if necessary, calculate superText1_w and other fields.

Since:
1.1.07

drawSuperTextTop

private void drawSuperTextTop(java.awt.Graphics g)
Draw superTextTop; if necessary, calculate superTextTop_w and other fields.

Since:
1.1.08

nodeToXY

private final int[] nodeToXY(int nodeNum)
Calculate the on-screen coordinates of a node.

Parameters:
nodeNum - Node coordinate
Returns:
Array with screen {x, y} for this node, already scaled and/or rotated
Since:
2.0.00

scaleToActualX

public void scaleToActualX(int[] xa)
Scale x-array from internal to actual screen-pixel coordinates. If not isScaled, do nothing.

This method only scales; does not translate to right by panelMarginX.

Parameters:
xa - Int array to be scaled; each member is an x-coordinate.
See Also:
scaleToActualX(int), scaleCopyToActualX(int[])

scaleToActualY

public void scaleToActualY(int[] ya)
Scale y-array from internal to actual screen-pixel coordinates. If not isScaled, do nothing.

Parameters:
ya - Int array to be scaled; each member is an y-coordinate.
See Also:
scaleToActualY(int), scaleCopyToActualY(int[])

scaleToActualX

public final int scaleToActualX(int x)
Scale x-coordinate from internal to actual screen-pixel coordinates. If not isScaled, return input.

This method only scales; does not translate to right by panelMarginX.

Parameters:
x - x-coordinate to be scaled
See Also:
scaleToActualY(int), scaleFromActualX(int)

scaleToActualY

public final int scaleToActualY(int y)
Scale y-coordinate from internal to actual screen-pixel coordinates. If not isScaled, return input.

Parameters:
y - y-coordinate to be scaled
See Also:
scaleToActualX(int), scaleFromActualY(int)

scaleFromActualX

public final int scaleFromActualX(int x)
Convert an x-coordinate from actual-scaled to internal-scaled coordinates. If not isScaled, return input.

This method only scales; does not translate to left by panelMarginX.

Parameters:
x - x-coordinate to be scaled

scaleFromActualY

public final int scaleFromActualY(int y)
Convert a y-coordinate from actual-scaled to internal-scaled coordinates. If not isScaled, return input.

Parameters:
y - y-coordinate to be scaled

isScaled

public boolean isScaled()
Is the board currently scaled larger than PANELX x PANELY pixels? If so, use scaleToActualX(int), scaleFromActualY(int), etc to convert between internal and actual screen pixel coordinates.

Returns:
Is the board scaled larger than default size?
See Also:
isRotated()

isRotated

public boolean isRotated()
Is the board currently rotated 90 degrees clockwise? If so, the minimum size swaps PANELX and PANELY.

Returns:
Is the board rotated?
Since:
1.1.08
See Also:
isScaled()

updateMode

public void updateMode()
update the type of interaction mode, and trigger a repaint. Also calls updateHoverTipToMode() and (for 6-player board's Special Building Phase) updates top-center text. For Game Option "N7", updates the top-center countdown of rounds. For the Free Placement debug mode, indicates that in the top center.


updateHoverTipToMode

protected void updateHoverTipToMode()
Update hoverTip based on mode when it changes; called from updateMode(). Might or might not repaint board: Calls SOCBoardPanel.BoardToolTip.setOffsetX(int) or SOCBoardPanel.BoardToolTip.setHoverText(String, int).


clearModeAndHilight

protected void clearModeAndHilight(int ptype)
Set board mode to NONE, no hilight, usually from a piece-placement mode. Calls updateHoverTipToMode() and repaints the board.

Parameters:
ptype - Piece type to clear, like SOCPlayingPiece.ROAD, or -1 for robber. Used to avoid race condition during initial placement, where server has already replied with mode for another piece type, and board has already set mode to place that piece type. If ptype doesn't match the board's current mode/piece type, board's mode is not changed to NONE.

setPlayer

public void setPlayer()
set the player that is using this board panel to be the client's player in this game.


setPlayer

void setPlayer(SOCPlayer pl)
Temporarily change the player that is using this board panel. Used during SOCGame.debugFreePlacement mode.

Parameters:
pl - Player to set, or null to change back to the client player
Since:
1.1.12
See Also:
getPlayerNumber()

getPlayerNumber

int getPlayerNumber()
Get our player number. Almost always the client's player number. During SOCGame.debugFreePlacement, the temporary player set by setPlayer(SOCPlayer).

Since:
1.1.12

setOtherPlayer

public void setOtherPlayer(SOCPlayer op)
set the other player

Parameters:
op - the other player

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Handle Events

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
DOCUMENT ME!

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - DOCUMENT ME!

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
DOCUMENT ME!

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - DOCUMENT ME!

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
DOCUMENT ME!

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e - DOCUMENT ME!

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Mouse has left the panel; hide tooltip and any hovering piece.

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e - MouseEvent

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Based on the board's current mode, update the hovering 'hilight' piece (hilight}. Trigger a Component.repaint() if the mouse moved or the hilight changes.

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent evt)
DOCUMENT ME!

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
evt - DOCUMENT ME!

doBoardMenuPopup

protected void doBoardMenuPopup(int x,
                                int y)
Bring up the popup menu; called from mousePressed.

Parameters:
x - x-coordinate of click, actual screen pixels (not unscaled internal)
y - y-coordinate of click, actual screen pixels (not unscaled internal)

popupExpectingBuildRequest

public boolean popupExpectingBuildRequest()
If the client has used the board popup menu to request building a piece, this method is used in client network-receive message treatment.


popupSetBuildRequest

public void popupSetBuildRequest(int coord,
                                 int ptype)

popupClearBuildRequest

public void popupClearBuildRequest()
player decided to not build something, so cancel the TimerTask that's waiting to tell the server what they wanted to build.

Since:
1.1.00

popupFireBuildingRequest

public void popupFireBuildingRequest()
Have received gamestate placing message; send the building request in reply.


tryMoveShipToEdge

private final void tryMoveShipToEdge()
Check and move ship from moveShip_fromEdge to moveShip_toEdge. Also sets moveShip_fromEdge = 0, moveShip_toEdge = 0, calls clearModeAndHilight(SOCPlayingPiece.SHIP). Called from mouse click or popup menu.

Note that if moveShip_toEdge != 0, then SOCGame.canMoveShip (playerNumber, moveShip_fromEdge, moveShip_toEdge) has probably already been called.

In scenario _SC_FTRI, checks if a gift port would be claimed by placing a ship there. If so, confirms with the user first with SOCBoardPanel.ConfirmPlaceShipDialog.

Since:
2.0.00
See Also:
SOCBoardPanel.BoardPopupMenu.tryMoveShipFromHere()

setSuperimposedText

public void setSuperimposedText(java.lang.String text1,
                                java.lang.String text2)
                         throws java.lang.IllegalArgumentException
Text to be displayed as 2 lines superimposed over the center of the board graphic (during game setup). Either text2, or both, can be null to display nothing. Keep the text short, because boardPanel may not be very wide (PANELX pixels). Will trigger a repaint.

Parameters:
text1 - Line 1 (or only line) of text, or null
text2 - Line 2 of text, or null; must be null if text1 is null
Throws:
java.lang.IllegalArgumentException - if text1 null, text2 non-null
Since:
1.1.07
See Also:
setSuperimposedTopText(String)

setSuperimposedTopText

public void setSuperimposedTopText(java.lang.String text)
Text to be displayed as 1 lines superimposed over the top center of the board graphic (during game play). text can be null to display nothing. Keep the text short, because boardPanel may not be very wide (PANELX pixels). Will trigger a repaint.

Parameters:
text - Line of text, or null
Since:
1.1.08
See Also:
setSuperimposedText(String, String)

findEdge

private final int findEdge(int x,
                           int y,
                           boolean checkCoastal)
given a pixel on the board, find the edge that contains it

Note: For the 6-player board, edge 0x00 is a valid edge that can be built on. It is found here as -1, since a value of 0 marks an invalid edge.

Note: For SOCBoardLarge, the 'sea' side of a coastal edge is returned as the negative value of its edge coordinate, if checkCoastal is set.

Parameters:
x - x coordinate, in unscaled board, not actual pixels; use scaleFromActualX(int) to convert
y - y coordinate, in unscaled board, not actual pixels
checkCoastal - If true, check for coastal edges for ship placement: Mouse could be over the land half or the sea half of the edge's graphical area. Return positive edge coordinate for land, negative edge for sea. Ignored unless isLargeBoard. Returns positive edge for non-coastal sea edges.
Returns:
the coordinates of the edge, or 0 if none; -1 for the 6-player board's valid edge 0x00; -edge for the sea side of a coastal edge on the large board if checkCoastal.

findNode

private final int findNode(int x,
                           int y)
given a pixel on the board, find the node that contains it

Parameters:
x - x coordinate, in unscaled board, not actual pixels; use scaleFromActualX(int) to convert
y - y coordinate, in unscaled board, not actual pixels
Returns:
the coordinates of the node, or 0 if none

findHex

private final int findHex(int x,
                          int y)
given a pixel on the board, find the hex that contains it

Parameters:
x - x coordinate, in unscaled board, not actual pixels; use scaleFromActualX(int) to convert
y - y coordinate, in unscaled board, not actual pixels
Returns:
the coordinates of the hex, or 0 if none

setMode

public void setMode(int m)
Set the interaction mode, for debugging purposes.

Parameters:
m - mode, such as CONSIDER_LM_SETTLEMENT or CONSIDER_LT_CITY
See Also:
updateMode(), setModeMoveShip(int), SOCPlayerInterface.doLocalCommand(String)

setModeMoveShip

public void setModeMoveShip(int edge)
Set the interaction mode to "move ship"; the player must now click where they want the ship to be moved. Repaints the board immediately.

Parameters:
edge - Edge coordinate of our player's ship we're moving. Not checked for validity.
Since:
2.0.00
See Also:
tryMoveShipToEdge()

loadImages

private static void loadImages(java.awt.Component c,
                               boolean wantsRotated)
Load the images for the board: hexes, rotatHexes, and dice. Loads all hex types, up through SOCBoardLarge.FOG_HEX, because hexes is static for all boards and all game options.

Parameters:
c - Our component, to load image resource files with getToolkit and getResource
wantsRotated - True for the 6-player non-sea board (v2 encoding SOCBoard.BOARD_ENCODING_6PLAYER), false otherwise. The large board (v3 encoding)'s fog-hex and gold-hex images have no rotated version, because that board layout is never rotated.

loadHexesAndImages

private static final void loadHexesAndImages(java.awt.Image[] newHexes,
                                             java.lang.String imageDir,
                                             java.awt.MediaTracker tracker,
                                             java.awt.Toolkit tk,
                                             java.lang.Class<?> clazz,
                                             boolean wantsRotated)
Load hex and other related images from either normal, or rotated, resource location.

Before v1.1.20, this method was called loadHexesPortsImages(..).

Parameters:
newHexes - Array to store hex images and 3:1 port image into; hexes or rotatHexes
imageDir - Location for Class.getResource(String): normal or rotated IMAGEDIR
tracker - Track image loading progress here
tk - Toolkit to load image from resource
clazz - Class for getResource
wantsRotated - True for rotated, false otherwise; some hex types (goldHex, fogHex) aren't available in rotated versions, because their board layout is never rotated. This parameter isn't about whether the current board is rotated, but about whether this image directory's contents are rotated.
Since:
1.1.08
See Also:
renderPortImages()

hexColor

public final java.awt.Color hexColor(int hexType)
Hex color for a hex resource type

Parameters:
hexType - hexType value, as in SOCBoard.DESERT_HEX, SOCBoard.WOOD_HEX, SOCBoard.WATER_HEX. Same value and meaning as those in SOCBoard.getHexTypeFromCoord(int)
Returns:
The corresponding color from ColorSquare, or ColorSquare.WATER if hexType not recognized.
Since:
1.1.07