soc.client
Class SOCBoardPanel.BoardToolTip

java.lang.Object
  extended bysoc.client.SOCBoardPanel.BoardToolTip
Enclosing class:
SOCBoardPanel

protected class SOCBoardPanel.BoardToolTip
extends java.lang.Object


Field Summary
private  int boxH
          Our size
private  int boxW
          Our size
private  int boxX
          Our position (upper-left of tooltip box)
private  int boxY
          Our position (upper-left of tooltip box)
private  SOCBoardPanel bpanel
           
(package private)  int hoverCityID
          hover settlement or city node ID, or 0.
private  int hoverID
          "ID" coord as returned by findNode, findEdge, findHex
(package private)  boolean hoverIsPort
          is hover a port at coordinate hoverID?
private  int hoverMode
          Uses board mode constants: Will be NONE, PLACE_ROAD, PLACE_SETTLEMENT, PLACE_ROBBER for hex, or PLACE_INIT_SETTLEMENT for port.
private  SOCPlayingPiece hoverPiece
          Object last pointed at; null for hexes and ports
(package private)  int hoverRoadID
          hover road ID, or 0.
(package private)  int hoverSettlementID
          hover settlement or city node ID, or 0.
private  java.lang.String hoverText
          Text to hover-display, or null if nothing to show
private  int mouseX
          Mouse position
private  int mouseY
          Mouse position
private  int offsetX
          Requested X-offset from mouse pointer (used for robber placement)
private  int PADDING_HORIZ
           
private  int TEXT_INSET
           
 
Constructor Summary
(package private) SOCBoardPanel.BoardToolTip(SOCBoardPanel ourBoardPanel)
           
 
Method Summary
 java.lang.String getHoverText()
          Currently displayed text.
private  void handleHover(int x, int y)
          Mouse is hovering during normal play; look for info for tooltip text.
 void hideHoverAndPieces()
          Clear hover text, and cancel any hovering roads/settlements/cities
 boolean isVisible()
           
 void paint(java.awt.Graphics g)
          Draw; Graphics should be the boardpanel's gc, as seen in its paint method.
 java.lang.String portDescAtNode(int id)
          Check at this node coordinate for a port, and return its descriptive text.
 void positionToMouse(int x, int y)
          Show tooltip at appropriate location when mouse is at (x,y) relative to the board.
 void setHoverText(java.lang.String t)
           
 void setOffsetX(int ofsX)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bpanel

private SOCBoardPanel bpanel

hoverText

private java.lang.String hoverText
Text to hover-display, or null if nothing to show


hoverMode

private int hoverMode
Uses board mode constants: Will be NONE, PLACE_ROAD, PLACE_SETTLEMENT, PLACE_ROBBER for hex, or PLACE_INIT_SETTLEMENT for port.


hoverID

private int hoverID
"ID" coord as returned by findNode, findEdge, findHex


hoverPiece

private SOCPlayingPiece hoverPiece
Object last pointed at; null for hexes and ports


hoverRoadID

int hoverRoadID
hover road ID, or 0. Readonly please from outside this inner class


hoverSettlementID

int hoverSettlementID
hover settlement or city node ID, or 0. Readonly please from outside this inner class


hoverCityID

int hoverCityID
hover settlement or city node ID, or 0. Readonly please from outside this inner class


hoverIsPort

boolean hoverIsPort
is hover a port at coordinate hoverID?


mouseX

private int mouseX
Mouse position


mouseY

private int mouseY
Mouse position


boxX

private int boxX
Our position (upper-left of tooltip box)


boxY

private int boxY
Our position (upper-left of tooltip box)


offsetX

private int offsetX
Requested X-offset from mouse pointer (used for robber placement)


boxW

private int boxW
Our size


boxH

private int boxH
Our size


TEXT_INSET

private final int TEXT_INSET
See Also:
Constant Field Values

PADDING_HORIZ

private final int PADDING_HORIZ
See Also:
Constant Field Values
Constructor Detail

SOCBoardPanel.BoardToolTip

SOCBoardPanel.BoardToolTip(SOCBoardPanel ourBoardPanel)
Method Detail

getHoverText

public java.lang.String getHoverText()
Currently displayed text.

Returns:
Tooltip text, or null if nothing.

isVisible

public boolean isVisible()

positionToMouse

public void positionToMouse(int x,
                            int y)
Show tooltip at appropriate location when mouse is at (x,y) relative to the board.

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

setOffsetX

public void setOffsetX(int ofsX)

setHoverText

public void setHoverText(java.lang.String t)

hideHoverAndPieces

public void hideHoverAndPieces()
Clear hover text, and cancel any hovering roads/settlements/cities


paint

public void paint(java.awt.Graphics g)
Draw; Graphics should be the boardpanel's gc, as seen in its paint method.


handleHover

private void handleHover(int x,
                         int y)
Mouse is hovering during normal play; look for info for tooltip text. Assumes x or y has changed since last call. Does not affect the "hilight" variable used by SOCBoardPanel during initial placement, and during placement from clicking "Buy" buttons.

Parameters:
x - Cursor x, from upper-left of board: actual coordinates, not board-internal coordinates
y - Cursor y, from upper-left of board: actual coordinates, not board-internal coordinates

portDescAtNode

public java.lang.String portDescAtNode(int id)
Check at this node coordinate for a port, and return its descriptive text. Does not check for players' settlements or cities, only for the port.

Parameters:
id - Node coordinate ID for potential port
Returns:
Port text description, or null if no port at that node id. Text format is "3:1 Port" or "2:1 Wood port".