|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container java.awt.Panel soc.client.TradeOfferPanel
public class TradeOfferPanel
Two-mode panel to display either a short status message, or a resource trade offer (and counter-offer) from another player.
The status message mode is used for tasks such as:
To use message mode, call setMessage(String)
.
To use trade offer mode, show setOffer(SOCTradeOffer)
.
To show or hide the panel in either mode, call Component.setVisible(boolean)
.
To set this panel's position or size, please use setBounds(int, int, int, int)
,
because it is overridden to also update a "compact mode" flag for counter-offer layout.
Nested Class Summary | |
---|---|
private class |
TradeOfferPanel.MessagePanel
Panel to show when in MESSAGE_MODE ,
not OFFER_MODE . |
private class |
TradeOfferPanel.OfferPanel
Panel to show a trade offer when in OFFER_MODE ,
not MESSAGE_MODE . |
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 |
ACCEPT
|
(package private) static java.lang.String |
CANCEL
|
(package private) java.awt.CardLayout |
cardLayout
Layout which shows either messagePanel or offerPanel . |
(package private) static java.lang.String |
CLEAR
|
private boolean |
counterCompactMode
If true, display counter-offer in a "compact mode" layout because the panel's height is too short for the normal arrangement. |
private boolean |
counterHidesBalloonPoint
If true, hide the original offer's balloon point (see SpeechBalloon.setBalloonPoint(boolean) )
when the counter-offer is visible. |
(package private) int |
from
|
(package private) SOCHandPanel |
hp
|
(package private) static java.awt.Color |
insideBGColor
|
static java.lang.String |
MESSAGE_MODE
Mode to show a message, not a trade offer. |
(package private) TradeOfferPanel.MessagePanel |
messagePanel
|
(package private) java.lang.String |
mode
Current mode: MESSAGE_MODE to show messagePanel ,
or OFFER_MODE to show offerPanel . |
(package private) static java.lang.String |
OFFER
|
static int |
OFFER_BUTTONS_HEIGHT
Additional height of offer (part of OFFER_HEIGHT )
when the "offer"/"accept"/"reject" buttons are showing. |
static int |
OFFER_COUNTER_HEIGHT
Typical height of counter-offer panel, when visible. |
static int |
OFFER_HEIGHT
Typical height of offer panel, when visible. |
static java.lang.String |
OFFER_MODE
Mode to show a trade offer, not a message. |
(package private) TradeOfferPanel.OfferPanel |
offerPanel
|
(package private) SOCPlayerInterface |
pi
|
(package private) static java.lang.String |
REJECT
|
(package private) static java.lang.String |
SEND
|
private static SOCStringManager |
strings
i18n text strings; will use same locale as SOCPlayerClient's string manager. |
protected static int[] |
zero
|
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 | |
---|---|
TradeOfferPanel(SOCHandPanel hp,
int from)
Creates a new TradeOfferPanel object. |
Method Summary | |
---|---|
void |
clearOffer()
Set the offer and counter-offer contents to zero. |
boolean |
doesCounterHideBalloonPoint()
If true, hide the original offer's balloon point (see SpeechBalloon.setBalloonPoint(boolean) )
when the counter-offer is visible. |
java.lang.String |
getMode()
Returns current mode of OFFER_MODE , or MESSAGE_MODE ,
which has been set by using
setOffer(soc.game.SOCTradeOffer) or setMessage(java.lang.String) |
boolean |
isCounterOfferMode()
Is this offerpanel in counteroffer mode, with a trade offer and counter-offer showing? |
void |
setBounds(int x,
int y,
int width,
int height)
Move and/or resize this panel. |
void |
setCounterHidesBalloonPoint(boolean hide)
If true, hide the original offer's balloon point (see SpeechBalloon.setBalloonPoint(boolean) )
when the counter-offer is visible. |
void |
setMessage(java.lang.String message)
Switch to the Message from another player, or clear its most recent contents. |
void |
setOffer(SOCTradeOffer currentOffer)
Update to view the of an offer from another player. |
void |
updateOfferButtons()
If an offer is currently showing, show or hide Accept button based on the client player's current resources. |
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, doLayout, 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, 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 |
---|
private static final SOCStringManager strings
public static final java.lang.String OFFER_MODE
setOffer(SOCTradeOffer)
.
MESSAGE_MODE
,
Constant Field Valuespublic static final java.lang.String MESSAGE_MODE
setMessage(String)
.
OFFER_MODE
,
Constant Field Valuespublic static final int OFFER_HEIGHT
OFFER_BUTTONS_HEIGHT
, but not OFFER_COUNTER_HEIGHT
.)
For convenience of other classes' layout calculations.
Actual height (buttons' y-positions + height) is set dynamically in OfferPanel.doLayout.
public static final int OFFER_BUTTONS_HEIGHT
OFFER_HEIGHT
)
when the "offer"/"accept"/"reject" buttons are showing.
That is, when not in counter-offer mode.
For convenience of other classes' layout calculations.
Based on calculations within OfferPanel.doLayout.
public static final int OFFER_COUNTER_HEIGHT
protected static final int[] zero
static final java.lang.String OFFER
static final java.lang.String ACCEPT
static final java.lang.String REJECT
static final java.lang.String SEND
static final java.lang.String CLEAR
static final java.lang.String CANCEL
static final java.awt.Color insideBGColor
int from
SOCHandPanel hp
SOCPlayerInterface pi
java.lang.String mode
MESSAGE_MODE
to show messagePanel
,
or OFFER_MODE
to show offerPanel
.
java.awt.CardLayout cardLayout
messagePanel
or offerPanel
.
TradeOfferPanel.MessagePanel messagePanel
TradeOfferPanel.OfferPanel offerPanel
private boolean counterCompactMode
OFFER_HEIGHT
+ OFFER_COUNTER_HEIGHT
- OFFER_BUTTONS_HEIGHT
.
private boolean counterHidesBalloonPoint
SpeechBalloon.setBalloonPoint(boolean)
)
when the counter-offer is visible.
Constructor Detail |
---|
public TradeOfferPanel(SOCHandPanel hp, int from)
Method Detail |
---|
public void setMessage(java.lang.String message)
setOffer(SOCTradeOffer)
to
show them again.
message
- the message message to show, or null.
Null does not show or hide the panel, only clears the label text.
Message can be 1 line, or 2 lines with '\n';
will not automatically wrap based on message length.public void setOffer(SOCTradeOffer currentOffer)
To update buttons after setOffer
if the client player's
resources change, call updateOfferButtons()
.
To clear values to zero, and hide the counter-offer box,
call clearOffer()
.
currentOffer
- the trade being proposedsetMessage(String)
public void updateOfferButtons()
public void clearOffer()
public boolean isCounterOfferMode()
public java.lang.String getMode()
OFFER_MODE
, or MESSAGE_MODE
,
which has been set by using
setOffer(soc.game.SOCTradeOffer)
or setMessage(java.lang.String)
public boolean doesCounterHideBalloonPoint()
SpeechBalloon.setBalloonPoint(boolean)
)
when the counter-offer is visible.
public void setCounterHidesBalloonPoint(boolean hide)
SpeechBalloon.setBalloonPoint(boolean)
)
when the counter-offer is visible.
hide
- Hide it during counter-offer?public void setBounds(int x, int y, int width, int height)
setBounds
in class java.awt.Component
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |