|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object soc.client.SOCBoardPanel.BoardToolTip
protected class SOCBoardPanel.BoardToolTip
(tooltip) Hover text for info on pieces/parts of the board.
Its mode uses boardpanel mode constants: Will be NONE, PLACE_ROAD,
PLACE_SETTLEMENT, PLACE_ROBBER for hex, or PLACE_INIT_SETTLEMENT for port.
Also contains "hovering" road/settlement/city near mouse pointer,
distinct from SOCBoardPanel.hilight
.
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" of coord as returned by findNode , findEdge, findHex |
(package private) boolean |
hoverIsPort
Is hover a port at coordinate hoverID? |
private boolean |
hoverIsShipMovable
Is hover a ship owned by our player, movable from its current position? If true, hoverShipID is also set. |
private boolean |
hoverIsWarship
Is hover a warship owned by our player, for scenario option _SC_PIRI ?
If true, hoverShipID is also set. |
private int |
hoverMode
Uses board mode constants: Will be NONE ,
PLACE_ROAD , PLACE_SHIP, 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. |
(package private) int |
hoverShipID
hover ship 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 of tooltip box (used for robber placement) |
private int |
PADDING_HORIZ
|
private boolean |
setHoverText_modeChangedOrMouseMoved
Flag to tell setHoverText(String, int) to repaint, even if text hasn't changed. |
private int |
TEXT_INSET
|
Constructor Summary | |
---|---|
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()
Is the hoverText tip non-null, or is any hover ID non-zero? (hoverRoadID, etc) |
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,
int coord)
Set the hover text (tooltip) based on where the mouse is now, and repaint the board. |
void |
setHoverText(java.lang.String t,
int coord,
int x,
int y)
Set tooltip text (or hide tooltip if text is null) and show tooltip at appropriate location when mouse is at (x,y) relative to the board. |
void |
setOffsetX(int ofsX)
Set the hover tip (tooltip) x-position, but don't repaint the board. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final SOCBoardPanel bpanel
private java.lang.String hoverText
private int hoverMode
NONE
,
PLACE_ROAD
, PLACE_SHIP, PLACE_SETTLEMENT,
PLACE_ROBBER for hex, or PLACE_INIT_SETTLEMENT for port.
Updated in handleHover(int, int)
.
private int hoverID
findNode
, findEdge, findHex
private SOCPlayingPiece hoverPiece
int hoverRoadID
paint(Graphics)
.
value is -1 for a road at edge 0x00.
If both hoverRoadID and hoverShipID
are non-zero, they must be the same coordinate,
never different non-zero values.
int hoverSettlementID
paint(Graphics)
.
int hoverCityID
paint(Graphics)
.
int hoverShipID
paint(Graphics)
.
If both hoverRoadID
and hoverShipID are non-zero, they must be the same coordinate,
never different non-zero values.
When setting this field, also set or clear hoverIsWarship
.
boolean hoverIsPort
SOCBoardPanel.PLACE_INIT_SETTLEMENT
private boolean hoverIsShipMovable
hoverShipID
is also set.
private boolean hoverIsWarship
_SC_PIRI
?
If true, hoverShipID
is also set.
private int mouseX
private int mouseY
private boolean setHoverText_modeChangedOrMouseMoved
setHoverText(String, int)
to repaint, even if text hasn't changed.
private int boxX
private int boxY
private int offsetX
private int boxW
private int boxH
private final int TEXT_INSET
private final int PADDING_HORIZ
Constructor Detail |
---|
SOCBoardPanel.BoardToolTip(SOCBoardPanel ourBoardPanel)
Method Detail |
---|
public java.lang.String getHoverText()
public boolean isVisible()
public void positionToMouse(int x, int y)
x
- x-coordinate of mouse, actual screen pixels (not unscaled internal)y
- y-coordinate of mouse, actual screen pixels (not unscaled internal)setHoverText(String, int)
,
setHoverText(String, int, int, int)
public void setOffsetX(int ofsX)
ofsX
- New offsetpublic void setHoverText(java.lang.String t, int coord)
Calls positionToMouse(mouseX,mouseY)
.
t
- Hover text contents, or null to clear that text (but
not hovering pieces) and repaint. Do nothing if text is
already equal to t, or if both are null.coord
- Cursor's board coordinates shown when "show coordinates" debug flag is set, or -1.
Ignored if t
is null
. To show only the coordinate, use "" for t
.setHoverText(String, int, int, int)
,
hideHoverAndPieces()
,
SOCBoardPanel.setDebugShowCoordsFlag(boolean)
public void setHoverText(java.lang.String t, int coord, int x, int y)
Convenience method, calls positionToMouse(int, int)
and setHoverText(String, int)
.
t
- Hover text contents, or null to clear that text (but
not hovering pieces) and repaint. Do nothing if text is
already equal to t
, or if both are null.coord
- Cursor's board coordinates shown when "show coordinates" debug flag is set, or -1.
Ignored if t
is null
. To show only the coordinate, use "" for t
.x
- x-coordinate of mouse, actual screen pixels (not unscaled internal)y
- y-coordinate of mouse, actual screen pixels (not unscaled internal)public void hideHoverAndPieces()
handleHover(int, int)
will set up the
hovering pieces/text for the current mode.
public void paint(java.awt.Graphics g)
private void handleHover(int x, int y)
If the board mode doesn't allow hovering pieces (ghost pieces), will clear hoverRoadID, hoverSettlementID, and hoverCityID to 0. Otherwise, these are set when the mouse is at a location where the player can build or upgrade, and they have resources to build.
Priority when hovering over a point on the board:
"PP"
),
and members of Special Node lists ("N1" - "N3"
).
x
- Cursor x, from upper-left of board: actual coordinates, not board-internal coordinatesy
- Cursor y, from upper-left of board: actual coordinates, not board-internal coordinatespublic java.lang.String portDescAtNode(int id)
id
- Node coordinate ID for potential port
StringManager.get(String)
,
or null
if no port at that node id.
Text format of string key's value is "3:1 Port" or "2:1 Wood port".
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |