soc.client
Class SOCBuildingPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by soc.client.SOCBuildingPanel
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class SOCBuildingPanel
extends java.awt.Panel
implements java.awt.event.ActionListener, java.awt.event.WindowListener

This class is a panel that shows how much it costs to build things, and it allows the player to build. Sits within a game's SOCPlayerInterface frame.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
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
(package private) static java.lang.String CARD
           
(package private)  java.awt.Button cardBut
           
(package private)  java.awt.Label cardC
           
(package private)  ColorSquare cardCount
           
(package private)  java.awt.Label cardCountLab
           
(package private)  ColorSquare cardOre
           
(package private)  ColorSquare cardSheep
           
(package private)  java.awt.Label cardT
           
(package private)  ColorSquare cardWheat
           
(package private) static java.lang.String CITY
           
(package private)  java.awt.Button cityBut
           
(package private)  java.awt.Label cityC
           
(package private)  ColorSquare cityOre
           
(package private)  java.awt.Label cityT
           
(package private)  ColorSquare cityWheat
           
private  ColorSquare cloth
          For game scenario _SC_CLVI, the amount of cloth left in the board's "general supply".
private  java.awt.Label clothLab
           
(package private)  java.awt.Button gameInfoBut
           
static int MINHEIGHT
          Minimum required size of this panel, as laid out in doLayout().
private  NewGameOptionsFrame ngof
          "Game Info" window, from gameInfoBut click, or null.
(package private)  SOCPlayerInterface pi
          Our parent window
private  int pieceButtonsState
          Piece-purchase button status; either all "Buy", or when placing a piece, 1 type "Cancel" and the rest disabled.
(package private)  SOCPlayer player
          Client's player data.
(package private) static java.lang.String ROAD
           
(package private)  java.awt.Button roadBut
           
(package private)  java.awt.Label roadC
           
(package private)  ColorSquare roadClay
           
(package private)  java.awt.Label roadT
           
(package private)  ColorSquare roadWood
           
private  java.awt.Button sbBut
           
private  boolean sbIsHilight
           
private  java.awt.Label sbLab
          "Special Building Phase" label.
private static java.lang.String SBP
           
private  java.awt.Panel sbPanel
          For 6-player board: request Special Building Phase.
(package private)  java.awt.Button settlementBut
           
(package private)  java.awt.Label settlementC
           
(package private)  ColorSquare settlementClay
           
(package private)  ColorSquare settlementSheep
           
(package private)  java.awt.Label settlementT
           
(package private)  ColorSquare settlementWheat
           
(package private)  ColorSquare settlementWood
           
(package private) static java.lang.String SHIP
           
private  java.awt.Button shipBut
          For large sea board (SOCGame.hasSeaBoard), button to buy a ship.
private  java.awt.Label shipC
           
private  ColorSquare shipSheep
           
private  java.awt.Label shipT
           
private  ColorSquare shipWood
           
(package private)  java.awt.Button statsBut
           
(package private)  javax.swing.JFrame statsFrame
           
(package private) static java.lang.String STLMT
           
private static SOCStringManager strings
          i18n text strings
(package private)  java.awt.Label title
           
private  ColorSquare vpToWin
           
private  java.awt.Label vpToWinLab
           
private  java.awt.Button wondersBut
          For game scenario _SC_WOND, the "Wonders" button that brings up a dialog with info and Build buttons.
 
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
SOCBuildingPanel(SOCPlayerInterface pi)
          make a new building panel
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Handle button clicks in this panel.
 void clickBuildingButton(SOCGame game, java.lang.String target, boolean doNotClearPopup)
          Handle a click (Buy or Cancel) on a building-panel button.
 void doLayout()
          custom layout for this panel.
 void gameWindowClosed()
          React to our parent game window being closed.
 void setPlayer()
          Set our game and player data based on client's nickname, via game.getPlayer(client.getNickname()).
 void updateButtonStatus()
          Update the status of the buttons.
 void updateClothCount()
          The board's general supply of cloth remaining has changed.
 void updateDevCardCount()
          The game's count of development cards remaining has changed.
 void windowActivated(java.awt.event.WindowEvent e)
          Required stub for WindowListener
 void windowClosed(java.awt.event.WindowEvent e)
          If our "Game Info" window (NewGameOptionsFrame) is closed, drop our reference to it so it can be gc'd.
 void windowClosing(java.awt.event.WindowEvent e)
          Required stub for WindowListener
 void windowDeactivated(java.awt.event.WindowEvent e)
          Required stub for WindowListener
 void windowDeiconified(java.awt.event.WindowEvent e)
          Required stub for WindowListener
 void windowIconified(java.awt.event.WindowEvent e)
          Required stub for WindowListener
 void windowOpened(java.awt.event.WindowEvent e)
          Required stub for WindowListener
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
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


ROAD

static final java.lang.String ROAD
See Also:
Constant Field Values

STLMT

static final java.lang.String STLMT
See Also:
Constant Field Values

CITY

static final java.lang.String CITY
See Also:
Constant Field Values

CARD

static final java.lang.String CARD
See Also:
Constant Field Values

SHIP

static final java.lang.String SHIP
See Also:
Constant Field Values

SBP

private static final java.lang.String SBP
See Also:
Constant Field Values

title

java.awt.Label title

roadBut

java.awt.Button roadBut

settlementBut

java.awt.Button settlementBut

cityBut

java.awt.Button cityBut

cardBut

java.awt.Button cardBut

gameInfoBut

java.awt.Button gameInfoBut

statsBut

java.awt.Button statsBut

statsFrame

javax.swing.JFrame statsFrame

roadT

java.awt.Label roadT

roadC

java.awt.Label roadC

roadWood

ColorSquare roadWood

roadClay

ColorSquare roadClay

settlementT

java.awt.Label settlementT

settlementC

java.awt.Label settlementC

settlementWood

ColorSquare settlementWood

settlementClay

ColorSquare settlementClay

settlementWheat

ColorSquare settlementWheat

settlementSheep

ColorSquare settlementSheep

cityT

java.awt.Label cityT

cityC

java.awt.Label cityC

cityWheat

ColorSquare cityWheat

cityOre

ColorSquare cityOre

cardT

java.awt.Label cardT

cardC

java.awt.Label cardC

cardCountLab

java.awt.Label cardCountLab

vpToWinLab

private java.awt.Label vpToWinLab

cardWheat

ColorSquare cardWheat

cardSheep

ColorSquare cardSheep

cardOre

ColorSquare cardOre

cardCount

ColorSquare cardCount

vpToWin

private ColorSquare vpToWin

cloth

private ColorSquare cloth
For game scenario _SC_CLVI, the amount of cloth left in the board's "general supply". Null otherwise.

Since:
2.0.00

clothLab

private java.awt.Label clothLab

wondersBut

private java.awt.Button wondersBut
For game scenario _SC_WOND, the "Wonders" button that brings up a dialog with info and Build buttons. Null otherwise.

Since:
2.0.00

shipT

private java.awt.Label shipT

shipC

private java.awt.Label shipC

shipWood

private ColorSquare shipWood

shipSheep

private ColorSquare shipSheep

shipBut

private java.awt.Button shipBut
For large sea board (SOCGame.hasSeaBoard), button to buy a ship. Null if this game doesn't have that board.

Since:
2.0.00

sbPanel

private java.awt.Panel sbPanel
For 6-player board: request Special Building Phase. Given variable custom layout in v2.0.00 for i18n. Contains sbLab and sbBut centered on 1 line or 2 lines based on their text widths.

Since:
1.1.08

sbBut

private java.awt.Button sbBut

sbLab

private java.awt.Label sbLab
"Special Building Phase" label. Not used on Large Board due to space constraints.


sbIsHilight

private boolean sbIsHilight

pieceButtonsState

private int pieceButtonsState
Piece-purchase button status; either all "Buy", or when placing a piece, 1 type "Cancel" and the rest disabled. When placing the second free road or free ship, this placement can be canceled, and the Road and Ship buttons both say "Cancel".

Updated in updateButtonStatus(). Value is 0 for "Buy", or when placing a piece, a borrowed SOCGameState constant with the piece type: PLACING_ROAD, PLACING_SETTLEMENT, PLACING_CITY, or PLACING_SHIP. When placing the second free road or ship, PLACING_FREE_ROAD2.

Before v2.0.00 and i18n, button state was checked by comparing the button text to "Buy" or "Cancel".

Since:
2.0.00

ngof

private NewGameOptionsFrame ngof
"Game Info" window, from gameInfoBut click, or null. Tracked to prevent showing more than 1 at a time.

Since:
1.1.18

pi

SOCPlayerInterface pi
Our parent window


MINHEIGHT

public static final int MINHEIGHT
Minimum required size of this panel, as laid out in doLayout().

Since:
1.1.08
See Also:
Constant Field Values

player

SOCPlayer player
Client's player data. Initially null; call setPlayer once seat is chosen.

See Also:
setPlayer()
Constructor Detail

SOCBuildingPanel

public SOCBuildingPanel(SOCPlayerInterface pi)
make a new building panel

Parameters:
pi - the player interface that this panel is in
Method Detail

doLayout

public void doLayout()
custom layout for this panel. Layout line height is based on ColorSquare.HEIGHT. If you change the line spacing or total height laid out here, please update MINHEIGHT.

For 6-player games, sbPanel is 2 "layout lines" tall here on the standard board, 1 line tall on the large board, and has its own custom doLayout() based on whether its label and button will fit on the same line or must be wrapped to 2 lines.

Overrides:
doLayout in class java.awt.Container

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Handle button clicks in this panel.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - button click event

gameWindowClosed

public void gameWindowClosed()
React to our parent game window being closed. If the GameStatisticsFrame is showing, dispose it.

Since:
2.0.00

clickBuildingButton

public void clickBuildingButton(SOCGame game,
                                java.lang.String target,
                                boolean doNotClearPopup)
Handle a click (Buy or Cancel) on a building-panel button. Assumes client is currently allowed to build, and sends request to server. SOCBoardPanel.BoardPopupMenu also calls this method.

Parameters:
game - The game, for status
target - Button clicked, as returned by ActionEvent.getActionCommand
doNotClearPopup - Do not call SOCBoardPanel.popupClearBuildRequest()

updateButtonStatus

public void updateButtonStatus()
Update the status of the buttons. Each piece type's button is labeled "Buy" or disabled ("---") depending on game state and resources available, unless we're currently placing a bought piece. In that case the bought piece type's button is labeled "Cancel", and the others are disabled with their current labels until placement is complete.


updateDevCardCount

public void updateDevCardCount()
The game's count of development cards remaining has changed. Update the display.


updateClothCount

public void updateClothCount()
The board's general supply of cloth remaining has changed. Update the display. Used for scenario SOCGameOption.K_SC_CLVI.

Since:
2.0.00

setPlayer

public void setPlayer()
               throws java.lang.IllegalStateException
Set our game and player data based on client's nickname, via game.getPlayer(client.getNickname()).

Throws:
java.lang.IllegalStateException - If the player data has already been set, and this isn't a new game (a board reset).

windowClosed

public void windowClosed(java.awt.event.WindowEvent e)
If our "Game Info" window (NewGameOptionsFrame) is closed, drop our reference to it so it can be gc'd.

Specified by:
windowClosed in interface java.awt.event.WindowListener
Since:
1.1.18

windowClosing

public void windowClosing(java.awt.event.WindowEvent e)
Required stub for WindowListener

Specified by:
windowClosing in interface java.awt.event.WindowListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent e)
Required stub for WindowListener

Specified by:
windowOpened in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent e)
Required stub for WindowListener

Specified by:
windowIconified in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent e)
Required stub for WindowListener

Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent e)
Required stub for WindowListener

Specified by:
windowActivated in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent e)
Required stub for WindowListener

Specified by:
windowDeactivated in interface java.awt.event.WindowListener