public class DomesticTradeOverlay extends OverlayView implements IDomesticTradeOverlay
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
private int |
BORDER_WIDTH |
private int |
BUTTON_TEXT_SIZE |
private javax.swing.JButton |
cancelButton |
private javax.swing.JLabel |
label |
private int |
LABEL_TEXT_SIZE |
private java.util.ArrayList<javax.swing.JToggleButton> |
playerButtons |
private PlayerInfo[] |
players |
private java.awt.event.ActionListener |
playerSelectActionListener |
private javax.swing.JPanel |
playerSelectionPanel |
private int |
RESOURCE_IMAGE_WIDTH |
private java.util.Map<ResourceType,java.util.ArrayList<javax.swing.JButton>> |
resourceButtonsMap |
private java.util.Map<ResourceType,javax.swing.JLabel> |
resourceCounts |
private java.util.ArrayList<javax.swing.JPanel> |
resourceSelectionPanels |
private javax.swing.ButtonGroup |
toggleButtonGroup |
private javax.swing.JButton |
tradeButton |
private java.util.Map<ResourceType,javax.swing.JPanel> |
upDownPanelByResourceType |
private java.util.ArrayList<javax.swing.JPanel> |
upDownPanels |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
DomesticTradeOverlay() |
Modifier and Type | Method and Description |
---|---|
private void |
buildView() |
IDomesticTradeController |
getController()
Controller getter
|
private PlayerInfo |
getPlayerByName(java.lang.String name) |
private java.awt.image.BufferedImage |
getScaledImage(java.awt.image.BufferedImage src,
int w,
int h)
Resizes an image using a Graphics2D object backed by a BufferedImage.
|
void |
reset()
Resets the view to its initial state.
|
void |
setCancelEnabled(boolean enabled)
Enables or disables the cancel button.
|
void |
setPlayers(PlayerInfo[] value)
Sets the opponents the local player may trade with.
|
void |
setPlayerSelectionEnabled(boolean enable)
Enables or disables the ability to select a player to trade with.
|
void |
setResourceAmount(ResourceType resource,
java.lang.String amount)
Sets the amount displayed for a resource.
|
void |
setResourceAmountChangeEnabled(ResourceType resource,
boolean canIncrease,
boolean canDecrease)
Enables or disables the ability to increase and decrease a resource's
amount.
|
void |
setResourceSelectionEnabled(boolean enable)
Enables or disables the ability to select resources to trade.
|
void |
setStateMessage(java.lang.String message)
Sets the message on the button indicating the state of the trade.
|
void |
setTradeEnabled(boolean enable)
Enables or disables the trade button.
|
private javax.swing.JPanel |
setupResourceTile(java.lang.String imageFilePath,
ResourceType resourceType) |
private javax.swing.JPanel |
setupResourceTradePanel() |
private javax.swing.JPanel |
setupUpDownButtonsPanel(ResourceType resourceType) |
private javax.swing.JPanel |
setupUserSelectPanel() |
private javax.swing.JPanel |
setupUsersList() |
closeModal, isModalShowing, setWindow, showModal
setController
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
closeModal, isModalShowing, showModal
setController
private final int LABEL_TEXT_SIZE
private final int BUTTON_TEXT_SIZE
private final int BORDER_WIDTH
private final int RESOURCE_IMAGE_WIDTH
private javax.swing.JLabel label
private javax.swing.JButton tradeButton
private javax.swing.JButton cancelButton
private javax.swing.JPanel playerSelectionPanel
private java.util.ArrayList<javax.swing.JPanel> resourceSelectionPanels
private java.util.ArrayList<javax.swing.JToggleButton> playerButtons
private java.util.ArrayList<javax.swing.JPanel> upDownPanels
private java.util.Map<ResourceType,javax.swing.JPanel> upDownPanelByResourceType
private PlayerInfo[] players
private javax.swing.ButtonGroup toggleButtonGroup
private java.util.Map<ResourceType,javax.swing.JLabel> resourceCounts
private java.util.Map<ResourceType,java.util.ArrayList<javax.swing.JButton>> resourceButtonsMap
private java.awt.event.ActionListener playerSelectActionListener
private void buildView()
private javax.swing.JPanel setupResourceTradePanel()
private javax.swing.JPanel setupUserSelectPanel()
private javax.swing.JPanel setupUsersList()
private PlayerInfo getPlayerByName(java.lang.String name)
private javax.swing.JPanel setupResourceTile(java.lang.String imageFilePath, ResourceType resourceType)
private javax.swing.JPanel setupUpDownButtonsPanel(ResourceType resourceType)
private java.awt.image.BufferedImage getScaledImage(java.awt.image.BufferedImage src, int w, int h)
srcImg
- - source image to scalew
- - desired widthh
- - desired heightpublic IDomesticTradeController getController()
IView
getController
in interface IView
getController
in class PanelView
public void reset()
IDomesticTradeOverlay
reset
in interface IDomesticTradeOverlay
public void setPlayers(PlayerInfo[] value)
IDomesticTradeOverlay
setPlayers
in interface IDomesticTradeOverlay
value
- Information about the players that can be traded withpublic void setPlayerSelectionEnabled(boolean enable)
IDomesticTradeOverlay
setPlayerSelectionEnabled
in interface IDomesticTradeOverlay
enable
- Whether or not player selection is currently allowedpublic void setResourceAmount(ResourceType resource, java.lang.String amount)
IDomesticTradeOverlay
setResourceAmount
in interface IDomesticTradeOverlay
resource
- The resource for which the amount is being setamount
- The string to be displayed as the resource's amount (can be
empty)public void setResourceAmountChangeEnabled(ResourceType resource, boolean canIncrease, boolean canDecrease)
IDomesticTradeOverlay
setResourceAmountChangeEnabled
in interface IDomesticTradeOverlay
resource
- The resource for which amount changing is being enabled or
disabledcanIncrease
- Whether or not the resource's amount may be increasedcanDecrease
- Whether or not the resource's amount may be decreasedpublic void setResourceSelectionEnabled(boolean enable)
IDomesticTradeOverlay
setResourceSelectionEnabled
in interface IDomesticTradeOverlay
enable
- Whether or not the user can select resources to tradepublic void setStateMessage(java.lang.String message)
IDomesticTradeOverlay
setStateMessage
in interface IDomesticTradeOverlay
message
- The new state messagepublic void setTradeEnabled(boolean enable)
IDomesticTradeOverlay
setTradeEnabled
in interface IDomesticTradeOverlay
enable
- Whether or not the user may currently execute the tradepublic void setCancelEnabled(boolean enabled)
IDomesticTradeOverlay
setCancelEnabled
in interface IDomesticTradeOverlay
enabled
- Whether or not the user may cancel the trade operation