net.sf.freecol.client.gui
Class Canvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLayeredPane
                  extended by javax.swing.JDesktopPane
                      extended by net.sf.freecol.client.gui.Canvas
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public final class Canvas
extends javax.swing.JDesktopPane

The main container for the other GUI components in FreeCol. This container is where the panels, dialogs and menus are added. In addition, this is the component in which the map graphics are displayed.
Displaying panels and a dialogs

Canvas contains methods to display various panels and dialogs. Most of these methods use i18n to get localized text. Here is an example:


 if (canvas.showConfirmDialog("choice.text", "choice.yes", "choice.no")) { //
 DO SOMETHING. }

 

where "choice.text", "choice.yes" and "choice.no" are keys for a localized message. See i18n for more information.
The difference between a panel and a dialog

When displaying a dialog, using a showXXXDialog, the calling thread will wait until that dialog is dismissed before returning. In contrast, a showXXXPanel-method returns immediately.

See Also:
Serialized Form

Nested Class Summary
static class Canvas.BoycottAction
           
static class Canvas.BuyAction
           
static class Canvas.ClaimAction
           
static class Canvas.EventType
           
(package private)  class Canvas.FrameMotionListener
          Handles the moving of internal frames.
static class Canvas.MissionaryAction
           
static class Canvas.PopupPosition
           
static class Canvas.ScoutColonyAction
           
static class Canvas.ScoutIndianSettlementAction
           
static class Canvas.SellAction
           
(package private)  class Canvas.ToolBoxFrame
          A class for frames being used as tool boxes.
static class Canvas.TradeAction
           
 
Nested classes/interfaces inherited from class javax.swing.JDesktopPane
javax.swing.JDesktopPane.AccessibleJDesktopPane
 
Nested classes/interfaces inherited from class javax.swing.JLayeredPane
javax.swing.JLayeredPane.AccessibleJLayeredPane
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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
private  ChatPanel chatPanel
           
private  ClientOptionsDialog clientOptionsDialog
           
private  boolean clientOptionsDialogShowing
           
private  GUI colonyTileGUI
          This is the GUI instance used to paint the colony tiles in the ColonyPanel and other panels.
private  FreeColDialog<java.lang.Integer> europeOpenDialog
          To save the most recently open dialog in Europe (RecruitDialog, PurchaseDialog, TrainDialog)
private  EuropePanel europePanel
           
private  FreeColClient freeColClient
           
private  GUI gui
           
private  java.awt.Dimension initialSize
           
private  LoadingSavegameDialog loadingSavegameDialog
           
private static java.util.logging.Logger logger
           
private static java.lang.Integer MAIN_LAYER
           
private  MainPanel mainPanel
           
private  MapControls mapControls
           
private  java.awt.Dimension oldSize
          Variable used for detecting resizing.
private  ServerListPanel serverListPanel
           
private  StartGamePanel startGamePanel
           
private static java.lang.Integer STATUS_LAYER
           
private  StatusPanel statusPanel
           
 
Fields inherited from class javax.swing.JDesktopPane
LIVE_DRAG_MODE, OUTLINE_DRAG_MODE
 
Fields inherited from class javax.swing.JLayeredPane
DEFAULT_LAYER, DRAG_LAYER, FRAME_CONTENT_LAYER, LAYER_PROPERTY, MODAL_LAYER, PALETTE_LAYER, POPUP_LAYER
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
Canvas(FreeColClient client, java.awt.Dimension size, GUI gui)
          The constructor to use.
 
Method Summary
 java.awt.Component add(java.awt.Component comp)
          Adds a component to this Canvas.
 void add(java.awt.Component comp, java.lang.Integer i)
          Adds a component to this Canvas.
 void add(java.awt.Component comp, java.lang.Integer i, boolean update)
          Adds a component to this Canvas.
 javax.swing.JInternalFrame addAsFrame(javax.swing.JComponent comp)
          Adds a component centered on this Canvas inside a frame.
private  javax.swing.JInternalFrame addAsFrame(javax.swing.JComponent comp, boolean toolBox)
          Adds a component centered on this Canvas inside a frame.
private  javax.swing.JInternalFrame addAsFrame(javax.swing.JComponent comp, boolean toolBox, Canvas.PopupPosition popupPosition)
          Adds a component on this Canvas inside a frame.
 javax.swing.JInternalFrame addAsSimpleFrame(javax.swing.JComponent comp)
          Adds a component centered on this Canvas inside a frame.
 javax.swing.JInternalFrame addAsToolBox(javax.swing.JComponent comp)
          Adds a component centered on this Canvas inside a frame.
 java.awt.Component addCentered(java.awt.Component comp)
          Adds a component centered on this Canvas.
 void addCentered(java.awt.Component comp, java.lang.Integer i)
          Adds a component centered on this Canvas.
 void askToQuit()
          Quits the application.
 void closeMainPanel()
          Closes the MainPanel.
 void closeMenus()
          Closes all the menus that are currently open.
 void closeStatusPanel()
          Closes the StatusPanel.
 boolean containsInGameComponents()
          Checks if this Canvas contains any ingame components.
private  void createKeyBindings()
          Create key bindings for all actions.
 void debugForeignColony(Settlement settlement)
          Detailed view of a foreign colony when in debug mode.
 void displayChat(java.lang.String senderNme, java.lang.String message, boolean privateChat)
           
 void displayChatMessage(Player sender, java.lang.String message, boolean privateChat)
          Tells the map controls that a chat message was received.
 void displayChatMessage(java.lang.String message)
          Displays a chat message originating from this client.
 void errorMessage(java.lang.String messageID)
          Displays an error message.
 void errorMessage(java.lang.String messageID, java.lang.String message)
          Displays an error message.
private  java.util.List<ModelMessage> filterEventPanels(ModelMessage[] messages)
          Filters out and displays the EventPanel messages.
 ColonyPanel getColonyPanel(Colony colony)
          Gets any currently displayed colony panel for the specified colony.
 GUI getColonyTileGUI()
           
 FreeColClient getFreeColClient()
          Returns the freeColClient.
 GUI getGUI()
          Returns this Canvas's GUI.
 javax.swing.ImageIcon getImageIcon(java.lang.Object display, boolean small)
          Returns the appropriate ImageIcon for Object.
 ImageLibrary getImageLibrary()
           
private  javax.swing.JInternalFrame getInternalFrame(java.awt.Component c)
          Gets the internal frame for the given component.
 LoadingSavegameDialog getLoadingSavegameDialog()
          Gets the LoadingSavegameDialog.
 MapControls getMapControls()
          Returns the MapControls of this Canvas.
 java.awt.Dimension getMinimumSize()
           
private  Canvas.PopupPosition getPopupPosition(Tile tile)
          Given a tile to be made visible, determine a position to popup a panel.
 java.awt.Dimension getPreferredSize()
           
 java.awt.Component getShowingSubPanel()
          The any panel this Canvas is displaying.
 Specification getSpecification()
          Describe getSpecification method here.
 boolean isClientOptionsDialogShowing()
          Checks if the ClientOptionsDialog is visible.
 boolean isMapboardActionsEnabled()
          Checks if mapboard actions should be enabled.
 boolean isShowingSubPanel()
          Checks if this Canvas displaying another panel.
 void newGame()
          Displays a quit dialog and, if desired, logs out of the current game and shows the new game panel.
 void paintComponent(java.awt.Graphics g)
          Paints this component.
 void refresh()
          Refreshes this Canvas visually.
 void refreshPlayersTable()
           
 void refreshTile(Tile t)
          Refreshes the screen at the specified Tile.
 void remove(java.awt.Component comp)
          Removes the given component from this Container.
 void remove(java.awt.Component comp, boolean update)
          Removes the given component from this Container.
 void removeInGameComponents()
          Removes components that is only used when in game.
 void retire()
          Quits the application.
 void returnToTitle()
          Closes all panels, changes the background and shows the main menu.
 Canvas.ScoutIndianSettlementAction showArmedUnitIndianSettlementDialog(IndianSettlement settlement)
          Displays a dialog that asks the user what he wants to do with his armed unit in a native settlement.
 Canvas.BoycottAction showBoycottedGoodsDialog(Goods goods, Europe europe)
          Displays a dialog that asks the user whether to pay arrears for boycotted goods or to dump them instead.
 Canvas.BuyAction showBuyDialog(Unit unit, Settlement settlement, Goods goods, int gold, boolean canBuy)
          Displays the panel for negotiating a purchase from a settlement.
 java.util.List<Goods> showCaptureGoodsDialog(Unit winner, java.util.List<Goods> loot)
          Displays the LootCargoDialog.
 void showChatPanel()
          Displays the ChatPanel.
<T> T
showChoiceDialog(Tile tile, java.lang.String text, java.lang.String cancelText, java.util.List<ChoiceItem<T>> choices)
          Displays a dialog with a text and a cancel-button, in addition to buttons for each of the objects returned for the given list.
<T> T
showChoiceDialog(Tile tile, StringTemplate template, java.lang.String cancelKey, java.util.List<ChoiceItem<T>> choices)
           
 Canvas.ClaimAction showClaimDialog(Tile tile, Player player, int price, Player owner, boolean canAccept)
          Display the panel for claiming land.
 OptionGroup showClientOptionsDialog()
          Displays a dialog for setting client options.
 ColonyPanel showColonyPanel(Colony colony)
          Displays the colony panel of the given Colony.
 void showColonyPanel(Tile t)
          Describe showColonyPanel method here.
 java.util.List<java.lang.String> showConfirmDeclarationDialog()
          Display a dialog to confirm a declaration of independence.
 boolean showConfirmDialog(java.lang.String text, java.lang.String okText, java.lang.String cancelText)
          Displays a dialog with a text and a ok/cancel option.
 boolean showConfirmDialog(Tile tile, ModelMessage[] messages, java.lang.String okText, java.lang.String cancelText)
          Displays a dialog with a text and a ok/cancel option.
 boolean showConfirmDialog(Tile tile, StringTemplate text, java.lang.String okText, java.lang.String cancelText)
          Displays a dialog with a text and a ok/cancel option.
 void showDeclarationDialog()
          Display a dialog following declaration of independence.
 java.util.List<Goods> showDumpCargoDialog(Unit unit)
          Displays the DumpCargoDialog.
 int showEmigrationPanel(boolean fountainOfYouth)
          Shows the panel that allows the user to choose which unit will emigrate from Europe.
 int showEuropeDialog(EuropePanel.EuropeAction europeAction)
          Displays one of the Europe Dialogs for Recruit, Purchase, Train.
 void showEuropePanel()
          Displays the EuropePanel.
 void showEventPanel(Canvas.EventType type)
          Display an event panel.
 void showEventPanel(Tile tile, Canvas.EventType type)
          Display an event panel.
<T> T
showFreeColDialog(FreeColDialog<T> freeColDialog)
          Displays the given dialog.
<T> T
showFreeColDialog(FreeColDialog<T> freeColDialog, Tile tile)
          Displays the given dialog, making sure a tile is visible.
 void showFreeColPanel(FreeColPanel panel)
          Displays the given panel.
 void showFreeColPanel(FreeColPanel panel, Tile tile)
          Displays the given panel, making sure a tile is visible.
 void showHighScoresPanel(java.lang.String messageId)
          Displays the high scores panel.
 void showIndianSettlementPanel(IndianSettlement indianSettlement)
          Displays the panel of the given native settlement.
 Canvas.TradeAction showIndianSettlementTradeDialog(Settlement settlement, boolean canBuy, boolean canSell, boolean canGift)
          Displays the panel for trading with an IndianSettlement.
 void showInformationMessage(FreeColObject displayObject, java.lang.String messageId)
          Shows a message with some information and an "OK"-button.
 void showInformationMessage(FreeColObject displayObject, StringTemplate template)
          Shows a message with some information and an "OK"-button.
 void showInformationMessage(ModelMessage message)
           
 void showInformationMessage(java.lang.String messageId)
          Shows a message with some information and an "OK"-button.
 void showInformationMessage(StringTemplate template)
          Shows a message with some information and an "OK"-button.
 java.lang.String showInputDialog(Tile tile, StringTemplate text, java.lang.String defaultValue, java.lang.String okText, java.lang.String cancelText, boolean rejectEmptyString)
          Displays a dialog with a text field and a ok/cancel option.
 java.io.File showLoadDialog(java.io.File directory)
          Displays a dialog where the user may choose a file.
 java.io.File showLoadDialog(java.io.File directory, javax.swing.filechooser.FileFilter[] fileFilters)
          Displays a dialog where the user may choose a file.
 boolean showLoadingSavegameDialog(boolean publicServer, boolean singleplayer)
          Displays a dialog for setting options when loading a savegame.
 void showMainPanel()
          Shows the MainPanel.
 void showModelMessages(ModelMessage... modelMessages)
          Displays a number of ModelMessages.
 DiplomaticTrade showNegotiationDialog(Unit unit, Settlement settlement, DiplomaticTrade agreement)
          Displays the NegotiationDialog.
 void showOpenGamePanel()
          Shows the OpenGamePanel.
 void showOpeningVideoPanel()
          Shows the VideoPanel.
 void showPanel(FreeColPanel panel)
          Displays a FreeColPanel.
 void showPanel(FreeColPanel panel, boolean centered)
          Displays a FreeColPanel.
 void showPopup(javax.swing.JPopupMenu popup, int x, int y)
          Shows the given popup at the given position on the screen.
 boolean showPreCombatDialog(FreeColGameObject attacker, FreeColGameObject defender, Tile tile)
          Display a dialog to confirm a combat.
 void showReportTurnPanel(ModelMessage... messages)
          Show the new turn report.
 java.io.File showSaveDialog(java.io.File directory, java.lang.String defaultName)
          Displays a dialog where the user may choose a filename.
 java.io.File showSaveDialog(java.io.File directory, java.lang.String standardName, javax.swing.filechooser.FileFilter[] fileFilters, java.lang.String defaultName)
          Displays a dialog where the user may choose a filename.
 Canvas.ScoutColonyAction showScoutForeignColonyDialog(Colony colony, Unit unit, boolean canNegotiate)
          Displays a dialog that asks the user what he wants to do with his scout in the foreign colony.
 Canvas.ScoutIndianSettlementAction showScoutIndianSettlementDialog(IndianSettlement settlement, java.lang.String number)
          Displays a dialog that asks the user what he wants to do with his scout in a native settlement.
 Location showSelectDestinationDialog(Unit unit)
          Display a dialog allowing the user to select a destination for a given unit.
 Canvas.SellAction showSellDialog(Unit unit, Settlement settlement, Goods goods, int gold)
          Displays the panel for negotiating a sale to a settlement.
 void showServerListPanel(java.lang.String username, java.util.ArrayList<ServerInfo> serverList)
          Displays the ServerListPanel.
 void showSettlement(Settlement s)
           
<T> T
showSimpleChoiceDialog(Tile tile, java.lang.String text, java.lang.String cancelText, java.util.List<T> objects)
          Displays a dialog with a text and a cancel-button, in addition to buttons for each of the objects in the list.
 void showStartGamePanel(Game game, Player player, boolean singlePlayerMode)
          Displays the StartGamePanel.
 void showStatusPanel(java.lang.String message)
          Shows a status message that cannot be dismissed.
 void showSubPanel(FreeColPanel panel)
          Displays a FreeColPanel.
 void showSubPanel(FreeColPanel panel, Canvas.PopupPosition popupPosition)
          Displays a FreeColPanel at a generalized position.
 void showTilePopup(Tile tile, int x, int y)
          Shows a tile popup.
 TradeRoute showTradeRouteDialog(Unit unit)
          Display a dialog to select a trade route for a unit.
 Canvas.MissionaryAction showUseMissionaryDialog(Unit unit, IndianSettlement settlement, boolean canEstablish, boolean canDenounce)
          Displays a dialog that asks the user what he wants to do with his missionary in the indian settlement.
private  void takeFocus()
          Makes sure that this Canvas takes the focus.
 void updateGameOptions()
           
 void updateGoldLabel()
          Updates the label displaying the current amount of gold.
 void updateMapGeneratorOptions()
           
 void updateSizes()
          Updates the sizes of the components on this Canvas.
 
Methods inherited from class javax.swing.JDesktopPane
addImpl, getAccessibleContext, getAllFrames, getAllFramesInLayer, getDesktopManager, getDragMode, getSelectedFrame, getUI, getUIClassID, paramString, remove, removeAll, selectFrame, setComponentZOrder, setDesktopManager, setDragMode, setSelectedFrame, setUI, updateUI
 
Methods inherited from class javax.swing.JLayeredPane
getComponentCountInLayer, getComponentsInLayer, getComponentToLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getObjectForLayer, getPosition, highestLayer, insertIndexForLayer, isOptimizedDrawingEnabled, lowestLayer, moveToBack, moveToFront, paint, putLayer, setLayer, setLayer, setPosition
 
Methods inherited from class javax.swing.JComponent
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, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, 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
 
Methods inherited from class java.awt.Container
add, add, add, add, addContainerListener, 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, removeContainerListener, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, 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, 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, hide, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

private static final java.util.logging.Logger logger

MAIN_LAYER

private static final java.lang.Integer MAIN_LAYER

STATUS_LAYER

private static final java.lang.Integer STATUS_LAYER

europeOpenDialog

private FreeColDialog<java.lang.Integer> europeOpenDialog
To save the most recently open dialog in Europe (RecruitDialog, PurchaseDialog, TrainDialog)


freeColClient

private final FreeColClient freeColClient

mainPanel

private MainPanel mainPanel

startGamePanel

private final StartGamePanel startGamePanel

europePanel

private final EuropePanel europePanel

statusPanel

private final StatusPanel statusPanel

chatPanel

private final ChatPanel chatPanel

gui

private final GUI gui

serverListPanel

private final ServerListPanel serverListPanel

clientOptionsDialog

private final ClientOptionsDialog clientOptionsDialog

loadingSavegameDialog

private final LoadingSavegameDialog loadingSavegameDialog

colonyTileGUI

private final GUI colonyTileGUI
This is the GUI instance used to paint the colony tiles in the ColonyPanel and other panels. It should not be scaled along with the default GUI.


clientOptionsDialogShowing

private boolean clientOptionsDialogShowing

mapControls

private MapControls mapControls

oldSize

private java.awt.Dimension oldSize
Variable used for detecting resizing.


initialSize

private java.awt.Dimension initialSize
Constructor Detail

Canvas

public Canvas(FreeColClient client,
              java.awt.Dimension size,
              GUI gui)
The constructor to use.

Parameters:
client - main control class.
size - The bounds of this Canvas.
gui - The object responsible of drawing the map onto this component.
Method Detail

add

public java.awt.Component add(java.awt.Component comp)
Adds a component to this Canvas.

Overrides:
add in class java.awt.Container
Parameters:
comp - The component to add
Returns:
The component argument.

add

public void add(java.awt.Component comp,
                java.lang.Integer i)
Adds a component to this Canvas. Removes the statuspanel if visible (and comp != statusPanel).

Parameters:
comp - The component to add to this ToEuropePanel.
i - The layer to add the component to (see JLayeredPane).

add

public void add(java.awt.Component comp,
                java.lang.Integer i,
                boolean update)
Adds a component to this Canvas. Removes the statuspanel if visible (and comp != statusPanel).

Parameters:
comp - The component to add to this ToEuropePanel.
i - The layer to add the component to (see JLayeredPane).

addAsFrame

public javax.swing.JInternalFrame addAsFrame(javax.swing.JComponent comp)
Adds a component centered on this Canvas inside a frame. Removes the statuspanel if visible (and comp != statusPanel).

Parameters:
comp - The component to add to this JInternalFrame.
Returns:
The JInternalFrame that was created and added.

addAsSimpleFrame

public javax.swing.JInternalFrame addAsSimpleFrame(javax.swing.JComponent comp)
Adds a component centered on this Canvas inside a frame. Removes the statuspanel if visible (and comp != statusPanel). The frame cannot be moved or resized.

Parameters:
comp - The component to add to this ToEuropePanel.
Returns:
The JInternalFrame that was created and added.

addAsToolBox

public javax.swing.JInternalFrame addAsToolBox(javax.swing.JComponent comp)
Adds a component centered on this Canvas inside a frame. The frame is considered as a tool box (not counted as a frame by the methods deciding if a panel is being displayed).

Removes the statuspanel if visible (and comp != statusPanel).

Parameters:
comp - The component to add to this JInternalFrame.
Returns:
The JInternalFrame that was created and added.

addCentered

public java.awt.Component addCentered(java.awt.Component comp)
Adds a component centered on this Canvas. Removes the statuspanel if visible (and comp != statusPanel).

Parameters:
comp - The component to add
Returns:
The component argument.

addCentered

public void addCentered(java.awt.Component comp,
                        java.lang.Integer i)
Adds a component centered on this Canvas. Removes the statuspanel if visible (and comp != statusPanel).

Parameters:
comp - The component to add to this ToEuropePanel.
i - The layer to add the component to (see JLayeredPane).

closeMainPanel

public void closeMainPanel()
Closes the MainPanel.


closeMenus

public void closeMenus()
Closes all the menus that are currently open.


closeStatusPanel

public void closeStatusPanel()
Closes the StatusPanel.

See Also:
showStatusPanel(java.lang.String)

containsInGameComponents

public boolean containsInGameComponents()
Checks if this Canvas contains any ingame components.

Returns:
true if there is a single ingame component.

debugForeignColony

public void debugForeignColony(Settlement settlement)
Detailed view of a foreign colony when in debug mode.

Parameters:
settlement - The Settlement with the colony

displayChat

public void displayChat(java.lang.String senderNme,
                        java.lang.String message,
                        boolean privateChat)

displayChatMessage

public void displayChatMessage(Player sender,
                               java.lang.String message,
                               boolean privateChat)
Tells the map controls that a chat message was received.

Parameters:
sender - The player who sent the chat message to the server.
message - The chat message.
privateChat - 'true' if the message is a private one, 'false' otherwise.
See Also:
GUIMessage

displayChatMessage

public void displayChatMessage(java.lang.String message)
Displays a chat message originating from this client.

Parameters:
message - The chat message.

errorMessage

public void errorMessage(java.lang.String messageID)
Displays an error message.

Parameters:
messageID - The i18n-keyname of the error message to display.

errorMessage

public void errorMessage(java.lang.String messageID,
                         java.lang.String message)
Displays an error message.

Parameters:
messageID - The i18n-keyname of the error message to display.
message - An alternative message to display if the resource specified by messageID is unavailable.

getFreeColClient

public FreeColClient getFreeColClient()
Returns the freeColClient.

Returns:
The freeColClient associated with this Canvas.

getColonyTileGUI

public GUI getColonyTileGUI()

getGUI

public GUI getGUI()
Returns this Canvas's GUI.

Returns:
The GUI.

getImageIcon

public javax.swing.ImageIcon getImageIcon(java.lang.Object display,
                                          boolean small)
Returns the appropriate ImageIcon for Object.

Parameters:
display - The Object to display.
Returns:
The appropriate ImageIcon.

getImageLibrary

public ImageLibrary getImageLibrary()

getLoadingSavegameDialog

public LoadingSavegameDialog getLoadingSavegameDialog()
Gets the LoadingSavegameDialog.

Returns:
The LoadingSavegameDialog.

getMapControls

public MapControls getMapControls()
Returns the MapControls of this Canvas.

Returns:
a MapControls value

getMinimumSize

public java.awt.Dimension getMinimumSize()
Overrides:
getMinimumSize in class javax.swing.JComponent

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent

getShowingSubPanel

public java.awt.Component getShowingSubPanel()
The any panel this Canvas is displaying.

Returns:
A Component the Canvas is displaying, or null if none found.

getSpecification

public Specification getSpecification()
Describe getSpecification method here.

Returns:
a Specification value

isClientOptionsDialogShowing

public boolean isClientOptionsDialogShowing()
Checks if the ClientOptionsDialog is visible.

Returns:
true if no internal frames are open.

isMapboardActionsEnabled

public boolean isMapboardActionsEnabled()
Checks if mapboard actions should be enabled.

Returns:
true if no internal frames are open.

isShowingSubPanel

public boolean isShowingSubPanel()
Checks if this Canvas displaying another panel.

Note that the previous implementation could throw exceptions in some cases, thus the change.

Returns:
true if the Canvas is displaying an internal frame.

newGame

public void newGame()
Displays a quit dialog and, if desired, logs out of the current game and shows the new game panel.


paintComponent

public void paintComponent(java.awt.Graphics g)
Paints this component. This method will use GUI.display(java.awt.Graphics2D) to draw the map/background on this component.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - The Graphics context in which to draw this component.
See Also:
GUI.display(java.awt.Graphics2D)

askToQuit

public void askToQuit()
Quits the application. This method uses showConfirmDialog(java.lang.String, java.lang.String, java.lang.String) in order to get a "Are you sure"-confirmation from the user.


refresh

public void refresh()
Refreshes this Canvas visually.


refreshPlayersTable

public void refreshPlayersTable()

refreshTile

public void refreshTile(Tile t)
Refreshes the screen at the specified Tile.

Parameters:
t - The tile to refresh.

remove

public void remove(java.awt.Component comp)
Removes the given component from this Container.

Overrides:
remove in class java.awt.Container
Parameters:
comp - The component to remove from this Container.

remove

public void remove(java.awt.Component comp,
                   boolean update)
Removes the given component from this Container.

Parameters:
comp - The component to remove from this Container.
update - The Canvas will be enabled, the graphics repainted and both the menubar and the actions will be updated if this parameter is true.

removeInGameComponents

public void removeInGameComponents()
Removes components that is only used when in game.


retire

public void retire()
Quits the application. This method uses showConfirmDialog(java.lang.String, java.lang.String, java.lang.String) in order to get a "Are you sure"-confirmation from the user.


showHighScoresPanel

public void showHighScoresPanel(java.lang.String messageId)
Displays the high scores panel.

Parameters:
messageId - An optional message to add to the high scores panel.

returnToTitle

public void returnToTitle()
Closes all panels, changes the background and shows the main menu.


showArmedUnitIndianSettlementDialog

public Canvas.ScoutIndianSettlementAction showArmedUnitIndianSettlementDialog(IndianSettlement settlement)
Displays a dialog that asks the user what he wants to do with his armed unit in a native settlement.

Parameters:
settlement - The IndianSettlement to consider.
Returns:
The chosen action, tribute, attack or cancel.

showBoycottedGoodsDialog

public Canvas.BoycottAction showBoycottedGoodsDialog(Goods goods,
                                                     Europe europe)
Displays a dialog that asks the user whether to pay arrears for boycotted goods or to dump them instead.

Parameters:
goods - a Goods value
europe - an Europe value
Returns:
a boolean value

showCaptureGoodsDialog

public java.util.List<Goods> showCaptureGoodsDialog(Unit winner,
                                                    java.util.List<Goods> loot)
Displays the LootCargoDialog.

Parameters:
winner - The Unit that is looting.
loot - list of Goods to select from
Returns:
list of Goods to loot

showChatPanel

public void showChatPanel()
Displays the ChatPanel.

See Also:
ChatPanel

showChoiceDialog

public <T> T showChoiceDialog(Tile tile,
                              java.lang.String text,
                              java.lang.String cancelText,
                              java.util.List<ChoiceItem<T>> choices)
Displays a dialog with a text and a cancel-button, in addition to buttons for each of the objects returned for the given list.

Parameters:
tile - An optional tile to make visible (not under the dialog).
text - The text that explains the choice for the user.
cancelText - The text displayed on the "cancel"-button.
choices - The List containing the ChoiceItems to create buttons for.
Returns:
The chosen object, or null for the cancel-button.

showChoiceDialog

public <T> T showChoiceDialog(Tile tile,
                              StringTemplate template,
                              java.lang.String cancelKey,
                              java.util.List<ChoiceItem<T>> choices)

showClaimDialog

public Canvas.ClaimAction showClaimDialog(Tile tile,
                                          Player player,
                                          int price,
                                          Player owner,
                                          boolean canAccept)
Display the panel for claiming land.

Parameters:
tile - The Tile to claim.
player - The Player that is claiming.
price - An asking price, if any.
owner - The Player that owns the land.
canAccept - True if accept is a valid option.
Returns:
The chosen action, accept, steal or cancel.

showClientOptionsDialog

public OptionGroup showClientOptionsDialog()
Displays a dialog for setting client options.

Returns:
true if the client options have been modified, and false otherwise.

getColonyPanel

public ColonyPanel getColonyPanel(Colony colony)
Gets any currently displayed colony panel for the specified colony.

Parameters:
colony - The Colony to check.
Returns:
A currently displayed colony panel, or null if not found.

showColonyPanel

public ColonyPanel showColonyPanel(Colony colony)
Displays the colony panel of the given Colony. Defends against duplicates as this can duplicate messages generated by multiple property change listeners registered against the same colony.

Parameters:
colony - The colony whose panel needs to be displayed.
Returns:
The colony panel being displayed.
See Also:
ColonyPanel

showColonyPanel

public void showColonyPanel(Tile t)
Describe showColonyPanel method here.

Parameters:
t - a Tile value

showConfirmDeclarationDialog

public java.util.List<java.lang.String> showConfirmDeclarationDialog()
Display a dialog to confirm a declaration of independence.

Returns:
A list of names for a new nation.

showConfirmDialog

public boolean showConfirmDialog(java.lang.String text,
                                 java.lang.String okText,
                                 java.lang.String cancelText)
Displays a dialog with a text and a ok/cancel option.

Parameters:
text - The text that explains the choice for the user.
okText - The text displayed on the "ok"-button.
cancelText - The text displayed on the "cancel"-button.
Returns:
true if the user clicked the "ok"-button and false otherwise.
See Also:
FreeColDialog

showConfirmDialog

public boolean showConfirmDialog(Tile tile,
                                 ModelMessage[] messages,
                                 java.lang.String okText,
                                 java.lang.String cancelText)
Displays a dialog with a text and a ok/cancel option.

Parameters:
tile - An optional Tile to make visible (not under the dialog!)
messages - The messages that explains the choice for the user.
okText - The text displayed on the "ok"-button.
cancelText - The text displayed on the "cancel"-button.
Returns:
true if the user clicked the "ok"-button and false otherwise.
See Also:
FreeColDialog

showConfirmDialog

public boolean showConfirmDialog(Tile tile,
                                 StringTemplate text,
                                 java.lang.String okText,
                                 java.lang.String cancelText)
Displays a dialog with a text and a ok/cancel option.

Parameters:
tile - A Tile to make visible (not under the dialog!)
text - The text that explains the choice for the user.
okText - The text displayed on the "ok"-button.
cancelText - The text displayed on the "cancel"-button.
Returns:
true if the user clicked the "ok"-button and false otherwise.
See Also:
FreeColDialog

showDeclarationDialog

public void showDeclarationDialog()
Display a dialog following declaration of independence.


showDumpCargoDialog

public java.util.List<Goods> showDumpCargoDialog(Unit unit)
Displays the DumpCargoDialog.

Parameters:
unit - The Unit that is dumping.
Returns:
A list of Goods to dump.

showEmigrationPanel

public int showEmigrationPanel(boolean fountainOfYouth)
Shows the panel that allows the user to choose which unit will emigrate from Europe. This method may only be called if the user has William Brewster in congress.

Parameters:
fountainOfYouth - a boolean value
Returns:
The emigrant that was chosen by the user.

showEuropeDialog

public int showEuropeDialog(EuropePanel.EuropeAction europeAction)
Displays one of the Europe Dialogs for Recruit, Purchase, Train. Closes any currently open Dialogs. Does not return from this method before the panel is closed.

Parameters:
europeAction - the type of panel to display
Returns:
FreeColDialog.getResponseInt.

showEuropePanel

public void showEuropePanel()
Displays the EuropePanel.

See Also:
EuropePanel

showEventPanel

public void showEventPanel(Canvas.EventType type)
Display an event panel.

Parameters:
type - The EventType.

showEventPanel

public void showEventPanel(Tile tile,
                           Canvas.EventType type)
Display an event panel.

Parameters:
tile - An optional Tile to make visible.
type - The EventType.

showFreeColPanel

public void showFreeColPanel(FreeColPanel panel)
Displays the given panel.

Parameters:
panel - The panel to be displayed

showFreeColPanel

public void showFreeColPanel(FreeColPanel panel,
                             Tile tile)
Displays the given panel, making sure a tile is visible.

Parameters:
panel - The panel to be displayed
tile - A Tile to make visible (not under the panel!)

showFreeColDialog

public <T> T showFreeColDialog(FreeColDialog<T> freeColDialog)
Displays the given dialog.

Parameters:
freeColDialog - The dialog to be displayed
Returns:
The reponse returned by the dialog.

showFreeColDialog

public <T> T showFreeColDialog(FreeColDialog<T> freeColDialog,
                               Tile tile)
Displays the given dialog, making sure a tile is visible.

Parameters:
freeColDialog - The dialog to be displayed
tile - A Tile to make visible (not under the dialog!)
Returns:
The reponse returned by the dialog.

showIndianSettlementPanel

public void showIndianSettlementPanel(IndianSettlement indianSettlement)
Displays the panel of the given native settlement.

Parameters:
indianSettlement - The IndianSettlement to display.

showIndianSettlementTradeDialog

public Canvas.TradeAction showIndianSettlementTradeDialog(Settlement settlement,
                                                          boolean canBuy,
                                                          boolean canSell,
                                                          boolean canGift)
Displays the panel for trading with an IndianSettlement.

Parameters:
settlement - The native settlement to trade with.
canBuy - Show a "buy" option.
canSell - Show a "sell" option.
canGift - Show a "gift" option.
Returns:
The chosen action, buy, sell, gift or cancel.

showInformationMessage

public void showInformationMessage(FreeColObject displayObject,
                                   java.lang.String messageId)
Shows a message with some information and an "OK"-button.

Parameters:
displayObject - Optional object for displaying an icon
messageId - The messageId of the message to display.

showInformationMessage

public void showInformationMessage(FreeColObject displayObject,
                                   StringTemplate template)
Shows a message with some information and an "OK"-button.

Parameters:
displayObject - Optional object for displaying an icon
template - the StringTemplate to display

showInformationMessage

public void showInformationMessage(ModelMessage message)

showInformationMessage

public void showInformationMessage(java.lang.String messageId)
Shows a message with some information and an "OK"-button.

Parameters:
messageId - The messageId of the message to display.

showInformationMessage

public void showInformationMessage(StringTemplate template)
Shows a message with some information and an "OK"-button.

Parameters:
template - the StringTemplate to display

showInputDialog

public java.lang.String showInputDialog(Tile tile,
                                        StringTemplate text,
                                        java.lang.String defaultValue,
                                        java.lang.String okText,
                                        java.lang.String cancelText,
                                        boolean rejectEmptyString)
Displays a dialog with a text field and a ok/cancel option.

Parameters:
tile - An optional tile to make visible (not under the dialog).
text - The text that explains the action to the user.
defaultValue - The default value appearing in the text field.
okText - The text displayed on the "ok"-button.
cancelText - The text displayed on the "cancel"-button. Use null to disable the cancel-option.
rejectEmptyString - a boolean value
Returns:
The text the user have entered or null if the user chose to cancel the action.
See Also:
FreeColDialog

showLoadDialog

public java.io.File showLoadDialog(java.io.File directory)
Displays a dialog where the user may choose a file. This is the same as calling:

showLoadDialog(directory, new FileFilter[] {FreeColDialog.getFSGFileFilter()});

Parameters:
directory - The directory containing the files.
Returns:
The File.
See Also:
FreeColDialog

showLoadDialog

public java.io.File showLoadDialog(java.io.File directory,
                                   javax.swing.filechooser.FileFilter[] fileFilters)
Displays a dialog where the user may choose a file.

Parameters:
directory - The directory containing the files.
fileFilters - The file filters which the user can select in the dialog.
Returns:
The File.
See Also:
FreeColDialog

showLoadingSavegameDialog

public boolean showLoadingSavegameDialog(boolean publicServer,
                                         boolean singleplayer)
Displays a dialog for setting options when loading a savegame. The settings can be retrieved directly from LoadingSavegameDialog after calling this method.

Parameters:
publicServer - Default value.
singleplayer - Default value.
Returns:
true if the "ok"-button was pressed and false otherwise.

showMainPanel

public void showMainPanel()
Shows the MainPanel.

See Also:
MainPanel

filterEventPanels

private java.util.List<ModelMessage> filterEventPanels(ModelMessage[] messages)
Filters out and displays the EventPanel messages.

Parameters:
messages - The list of ModelMessage to filter.
Returns:
The list of messages without any EventPanel messages.

showModelMessages

public void showModelMessages(ModelMessage... modelMessages)
Displays a number of ModelMessages.

Parameters:
modelMessages -

showNegotiationDialog

public DiplomaticTrade showNegotiationDialog(Unit unit,
                                             Settlement settlement,
                                             DiplomaticTrade agreement)
Displays the NegotiationDialog.

Parameters:
unit - The Unit that is negotiating.
settlement - A Settlement that is negotiating.
agreement - The current DiplomaticTrade agreement.
Returns:
An updated agreement.
See Also:
NegotiationDialog

showOpenGamePanel

public void showOpenGamePanel()
Shows the OpenGamePanel.


showOpeningVideoPanel

public void showOpeningVideoPanel()
Shows the VideoPanel.


showPanel

public void showPanel(FreeColPanel panel)
Displays a FreeColPanel.

Parameters:
panel - a FreeColPanel value

showPanel

public void showPanel(FreeColPanel panel,
                      boolean centered)
Displays a FreeColPanel.

Parameters:
panel - a FreeColPanel value
centered - a boolean value

showPopup

public void showPopup(javax.swing.JPopupMenu popup,
                      int x,
                      int y)
Shows the given popup at the given position on the screen.

Parameters:
popup - The JPopupMenu to show.
x - The x-coordinate at which to show the popup.
y - The y-coordinate at which to show the popup.

showPreCombatDialog

public boolean showPreCombatDialog(FreeColGameObject attacker,
                                   FreeColGameObject defender,
                                   Tile tile)
Display a dialog to confirm a combat.

Parameters:
attacker - The attacker.
defender - The defender.
tile - A Tile to make visible.
Returns:
True if the combat is to proceed.

showReportTurnPanel

public void showReportTurnPanel(ModelMessage... messages)
Show the new turn report.

Parameters:
messages - The ModelMessages to show.

showSaveDialog

public java.io.File showSaveDialog(java.io.File directory,
                                   java.lang.String defaultName)
Displays a dialog where the user may choose a filename. This is the same as calling:

showSaveDialog(directory, new FileFilter[] {FreeColDialog.getFSGFileFilter()}, defaultName);

Parameters:
directory - The directory containing the files in which the user may overwrite.
defaultName - Default filename for the savegame.
Returns:
The File.
See Also:
FreeColDialog

showSaveDialog

public java.io.File showSaveDialog(java.io.File directory,
                                   java.lang.String standardName,
                                   javax.swing.filechooser.FileFilter[] fileFilters,
                                   java.lang.String defaultName)
Displays a dialog where the user may choose a filename.

Parameters:
directory - The directory containing the files in which the user may overwrite.
standardName - This extension will be added to the specified filename (if not added by the user).
fileFilters - The available file filters in the dialog.
defaultName - Default filename for the savegame.
Returns:
The File.
See Also:
FreeColDialog

showScoutForeignColonyDialog

public Canvas.ScoutColonyAction showScoutForeignColonyDialog(Colony colony,
                                                             Unit unit,
                                                             boolean canNegotiate)
Displays a dialog that asks the user what he wants to do with his scout in the foreign colony.

Parameters:
colony - The Colony to be scouted.
unit - The Unit that is scouting.
canNegotiate - True if negotation is a valid choice.
Returns:
The selected action, either negotiate, spy, attack or cancel.

showScoutIndianSettlementDialog

public Canvas.ScoutIndianSettlementAction showScoutIndianSettlementDialog(IndianSettlement settlement,
                                                                          java.lang.String number)
Displays a dialog that asks the user what he wants to do with his scout in a native settlement.

Parameters:
settlement - The IndianSettlement to be scouted.
number - The number of settlements in the settlement owner nation.
Returns:
The chosen action, speak, tribute, attack or cancel.

showSelectDestinationDialog

public Location showSelectDestinationDialog(Unit unit)
Display a dialog allowing the user to select a destination for a given unit.

Parameters:
unit - The Unit to select a destination for.
Returns:
A destination for the unit, or null.

showBuyDialog

public Canvas.BuyAction showBuyDialog(Unit unit,
                                      Settlement settlement,
                                      Goods goods,
                                      int gold,
                                      boolean canBuy)
Displays the panel for negotiating a purchase from a settlement.

Parameters:
unit - The Unit that is buying.
settlement - The Settlement to buy from.
goods - The Goods to buy.
gold - The current negotiated price.
canBuy - True if buy is a valid option.
Returns:
The chosen action, buy, haggle, or cancel.

showSellDialog

public Canvas.SellAction showSellDialog(Unit unit,
                                        Settlement settlement,
                                        Goods goods,
                                        int gold)
Displays the panel for negotiating a sale to a settlement.

Parameters:
unit - The Unit that is selling.
settlement - The Settlement to sell to.
goods - The Goods to sell.
gold - The current negotiated price.
Returns:
The chosen action, sell, gift or haggle, or null.

showServerListPanel

public void showServerListPanel(java.lang.String username,
                                java.util.ArrayList<ServerInfo> serverList)
Displays the ServerListPanel.

Parameters:
username - The username that should be used when connecting to one of the servers on the list.
serverList - The list containing the servers retrieved from the metaserver.
See Also:
ServerListPanel

showSimpleChoiceDialog

public <T> T showSimpleChoiceDialog(Tile tile,
                                    java.lang.String text,
                                    java.lang.String cancelText,
                                    java.util.List<T> objects)
Displays a dialog with a text and a cancel-button, in addition to buttons for each of the objects in the list.

Parameters:
tile - An optional tile to make visible (not under the dialog).
text - The text that explains the choice for the user.
cancelText - The text displayed on the "cancel"-button.
objects - The List containing the objects to create buttons for.
Returns:
The chosen object, or null for the cancel-button.

showStartGamePanel

public void showStartGamePanel(Game game,
                               Player player,
                               boolean singlePlayerMode)
Displays the StartGamePanel.

Parameters:
game - The Game that is about to start.
player - The Player using this client.
singlePlayerMode - 'true' if the user wants to start a single player game, 'false' otherwise.
See Also:
StartGamePanel

showStatusPanel

public void showStatusPanel(java.lang.String message)
Shows a status message that cannot be dismissed. The panel will be removed when another component is added to this Canvas. This includes all the showXXX-methods. In addition, closeStatusPanel() also removes this panel.

Parameters:
message - The text message to display on the status panel.
See Also:
StatusPanel

showSubPanel

public void showSubPanel(FreeColPanel panel)
Displays a FreeColPanel.

Parameters:
panel - FreeColPanel, panel to show

showSubPanel

public void showSubPanel(FreeColPanel panel,
                         Canvas.PopupPosition popupPosition)
Displays a FreeColPanel at a generalized position.

Parameters:
panel - FreeColPanel, panel to show
popupPosition - PopupPosition The generalized position to place the panel.

showTilePopup

public void showTilePopup(Tile tile,
                          int x,
                          int y)
Shows a tile popup.

Parameters:
tile - The Tile where the popup occurred.
x - The x-coordinate on the screen where the popup needs to be placed.
y - The y-coordinate on the screen where the popup needs to be placed.
See Also:
TilePopup

showTradeRouteDialog

public TradeRoute showTradeRouteDialog(Unit unit)
Display a dialog to select a trade route for a unit.

Parameters:
unit - The Unit to select a trade route for.
Returns:
A trade route, or null.

showUseMissionaryDialog

public Canvas.MissionaryAction showUseMissionaryDialog(Unit unit,
                                                       IndianSettlement settlement,
                                                       boolean canEstablish,
                                                       boolean canDenounce)
Displays a dialog that asks the user what he wants to do with his missionary in the indian settlement.

Parameters:
unit - The Unit speaking to the settlement.
settlement - The IndianSettlement being visited.
canEstablish - Is establish a valid option.
canDenounce - Is denounce a valid option.
Returns:
The chosen action, establish mission, denounce, incite or cancel.

updateGameOptions

public void updateGameOptions()

updateGoldLabel

public void updateGoldLabel()
Updates the label displaying the current amount of gold.


updateMapGeneratorOptions

public void updateMapGeneratorOptions()

updateSizes

public void updateSizes()
Updates the sizes of the components on this Canvas.


addAsFrame

private javax.swing.JInternalFrame addAsFrame(javax.swing.JComponent comp,
                                              boolean toolBox)
Adds a component centered on this Canvas inside a frame. Removes the statuspanel if visible (and comp != statusPanel).

Parameters:
comp - The component to add to this ToEuropePanel.
toolBox - Should be set to true if the resulting frame is used as a toolbox (that is: it should not be counted as a frame).
Returns:
The JInternalFrame that was created and added.

addAsFrame

private javax.swing.JInternalFrame addAsFrame(javax.swing.JComponent comp,
                                              boolean toolBox,
                                              Canvas.PopupPosition popupPosition)
Adds a component on this Canvas inside a frame. Removes the statuspanel if visible (and comp != statusPanel).

Parameters:
comp - The component to add to this ToEuropePanel.
toolBox - Should be set to true if the resulting frame is used as a toolbox (that is: it should not be counted as a frame).
popupPosition - a PopupPosition value
Returns:
The JInternalFrame that was created and added.

createKeyBindings

private void createKeyBindings()
Create key bindings for all actions.


getInternalFrame

private javax.swing.JInternalFrame getInternalFrame(java.awt.Component c)
Gets the internal frame for the given component.

Parameters:
c - The component.
Returns:
The given component if this is an internal frame or the first parent that is an internal frame. Returns null if no internal frame is found.

getPopupPosition

private Canvas.PopupPosition getPopupPosition(Tile tile)
Given a tile to be made visible, determine a position to popup a panel.

Parameters:
tile - A Tile to be made visible.
Returns:
A PopupPosition for a panel to be displayed.

takeFocus

private void takeFocus()
Makes sure that this Canvas takes the focus. It will keep on trying for a while even its request doesn't get granted immediately.


showSettlement

public void showSettlement(Settlement s)