Class ColonyPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- net.sf.freecol.client.gui.panel.MigPanel
-
- net.sf.freecol.client.gui.panel.FreeColPanel
-
- net.sf.freecol.client.gui.panel.PortPanel
-
- net.sf.freecol.client.gui.panel.ColonyPanel
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.beans.PropertyChangeListener
,java.io.Serializable
,java.util.EventListener
,javax.accessibility.Accessible
public final class ColonyPanel extends PortPanel implements java.beans.PropertyChangeListener
This is a panel for the Colony display. It shows the units that are working in the colony, the buildings and much more.Beware that in debug mode, this might be a server-side version of the colony which is why we need to call getColony().getSpecification() to get the spec that corresponds to the good types in this colony.
Panel Layout:
|--------------------------------------------------------| | nameBox | netProductionPanel | |--------------------------------------------------------| | tilesPanel | buildingsPanel | |-------------------| | | populationPanel | | |-------------------| | | constructionPanel | | |--------------------------------------------------------| | inPortPanel | cargoPanel | outsideColonyPanel | |--------------------------------------------------------| | warehousePanel | |--------------------------------------------------------|
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ColonyPanel.BuildingsPanel
This panel is a list of the colony's buildings.class
ColonyPanel.ColonyCargoPanel
This panel shows the content of a carrier in the colonyclass
ColonyPanel.ColonyInPortPanel
A panel that holds UnitLabels that represent naval Units that are waiting in the port of the colony.class
ColonyPanel.OutsideColonyPanel
A panel that holds UnitLabels that represent Units that are standing in front of a colony.class
ColonyPanel.PopulationPanel
The panel to display the population breakdown for this colony.class
ColonyPanel.TilesPanel
A panel that displays the tiles in the immediate area around the colony.class
ColonyPanel.WarehousePanel
A panel that holds goods that represent cargo that is inside the Colony.-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description private ColonyPanel.BuildingsPanel
buildingsPanel
private javax.swing.JScrollPane
buildingsScroll
private javax.swing.JButton
buildQueueButton
private java.awt.event.ActionListener
buildQueueCmd
private javax.swing.JScrollPane
cargoScroll
private Colony
colony
TheColony
this panel is displaying.private javax.swing.JButton
colonyUnitsButton
private java.awt.event.ActionListener
colonyUnitsCmd
private ConstructionPanel
constructionPanel
private javax.swing.JButton
fillButton
private java.awt.event.ActionListener
fillCmd
private javax.swing.JScrollPane
inPortScroll
private static java.util.logging.Logger
logger
private javax.swing.JComboBox<Colony>
nameBox
private javax.swing.JPanel
netProductionPanel
private java.awt.event.ActionListener
occupationCmd
private ColonyPanel.OutsideColonyPanel
outsideColonyPanel
private javax.swing.JScrollPane
outsideColonyScroll
private ColonyPanel.PopulationPanel
populationPanel
private java.awt.event.MouseListener
releaseListener
static int
SCROLL_AREA_HEIGHT
The height of the area in which autoscrolling should happen.static int
SCROLL_SPEED
The speed of the scrolling.private javax.swing.JButton
setGoodsButton
private java.awt.event.ActionListener
setGoodsCmd
private ColonyPanel.TilesPanel
tilesPanel
private javax.swing.JScrollPane
tilesScroll
private javax.swing.JButton
traceWorkButton
private javax.swing.JButton
unloadButton
private java.awt.event.ActionListener
unloadCmd
private javax.swing.JButton
warehouseButton
private java.awt.event.ActionListener
warehouseCmd
private ColonyPanel.WarehousePanel
warehousePanel
private javax.swing.JScrollPane
warehouseScroll
-
Fields inherited from class net.sf.freecol.client.gui.panel.PortPanel
cargoPanel, defaultTransferHandler, inPortPanel, pressListener, selectedUnitLabel
-
Fields inherited from class net.sf.freecol.client.gui.panel.FreeColPanel
CANCEL, editable, HELP, MARGIN, NL_SPAN_SPLIT_2, OK, okButton, SPAN_SPLIT_2
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description ColonyPanel(FreeColClient freeColClient, Colony colony)
The constructor for the panel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent ae)
private void
addMouseListeners()
private void
addPropertyChangeListeners()
Add property change listeners needed by this ColonyPanel.private void
cleanup()
Clean up this colony panel.void
closeColonyPanel()
Close thisColonyPanel
.private void
generateColonyUnitsMenu()
Generates a menu containing the units currently accessible from the Colony Panel allowing keyboard access to said units.Colony
getColony()
Gets theColony
in use.ColonyPanel.TilesPanel
getTilesPanel()
Gets theTilesPanel
-object in use.private java.awt.Dimension
getTilesScrollGuiScaledDimension()
java.util.List<Unit>
getUnitList()
Gets the list of units on the colony tile.ColonyPanel.WarehousePanel
getWarehousePanel()
Gets theWarehousePanel
-object in use.private void
initialize(Colony colony)
Initialize the entire panel.void
propertyChange(java.beans.PropertyChangeEvent event)
private void
removeMouseListeners()
void
removeNotify()
private void
removePropertyChangeListeners()
Remove the property change listeners of ColonyPanel.private void
setColony(Colony colony)
Set the current colony.boolean
setSelectedUnit(Unit unit)
Select a given unit.void
setSelectedUnitLabel(UnitLabel unitLabel)
Set the selected unit label.private void
setTransferHandlers(boolean enable)
private boolean
tryWork(Unit unit, WorkLocation wl)
Try to assign a unit to work in a colony work location.void
update()
Update the entire colony panel.private void
updateBuildingsPanel()
private void
updateCarrierButtons()
Enables the unload and fill buttons if the currently selected unit is a carrier with some cargo.private void
updateConstructionPanel()
private void
updateInPortPanel()
private void
updateNetProductionPanel()
private void
updateOutsideColonyPanel()
private void
updatePopulationPanel()
private void
updateProduction()
Update all the production-related panels.private void
updateTilesPanel()
private void
updateWarehousePanel()
-
Methods inherited from class net.sf.freecol.client.gui.panel.PortPanel
getCargoPanel, getPressListener, getSelectedUnit, getSelectedUnitLabel, getTransferHandler
-
Methods inherited from class net.sf.freecol.client.gui.panel.FreeColPanel
addClosingCallback, createColonyButton, getClientOptions, getFreeColClient, getGame, getGUI, getImageLibrary, getMap, getMyPlayer, getSmallAbstractUnitImage, getSpecification, igc, isEditable, requestFocus, setCancelComponent
-
Methods inherited from class net.sf.freecol.client.gui.panel.MigPanel
getMigLayout, getUIClassID
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, paramString, setUI, updateUI
-
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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, 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, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, 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, 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
-
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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
SCROLL_AREA_HEIGHT
public static final int SCROLL_AREA_HEIGHT
The height of the area in which autoscrolling should happen.- See Also:
- Constant Field Values
-
SCROLL_SPEED
public static final int SCROLL_SPEED
The speed of the scrolling.- See Also:
- Constant Field Values
-
unloadButton
private javax.swing.JButton unloadButton
-
fillButton
private javax.swing.JButton fillButton
-
warehouseButton
private javax.swing.JButton warehouseButton
-
buildQueueButton
private javax.swing.JButton buildQueueButton
-
colonyUnitsButton
private javax.swing.JButton colonyUnitsButton
-
setGoodsButton
private javax.swing.JButton setGoodsButton
-
traceWorkButton
private javax.swing.JButton traceWorkButton
-
colony
private Colony colony
TheColony
this panel is displaying.
-
releaseListener
private transient java.awt.event.MouseListener releaseListener
-
nameBox
private final javax.swing.JComboBox<Colony> nameBox
-
netProductionPanel
private javax.swing.JPanel netProductionPanel
-
buildingsScroll
private javax.swing.JScrollPane buildingsScroll
-
buildingsPanel
private ColonyPanel.BuildingsPanel buildingsPanel
-
cargoScroll
private javax.swing.JScrollPane cargoScroll
-
constructionPanel
private ConstructionPanel constructionPanel
-
inPortScroll
private javax.swing.JScrollPane inPortScroll
-
outsideColonyScroll
private javax.swing.JScrollPane outsideColonyScroll
-
outsideColonyPanel
private ColonyPanel.OutsideColonyPanel outsideColonyPanel
-
populationPanel
private ColonyPanel.PopulationPanel populationPanel
-
tilesScroll
private javax.swing.JScrollPane tilesScroll
-
tilesPanel
private ColonyPanel.TilesPanel tilesPanel
-
warehouseScroll
private javax.swing.JScrollPane warehouseScroll
-
warehousePanel
private ColonyPanel.WarehousePanel warehousePanel
-
unloadCmd
private final java.awt.event.ActionListener unloadCmd
-
warehouseCmd
private final java.awt.event.ActionListener warehouseCmd
-
buildQueueCmd
private final java.awt.event.ActionListener buildQueueCmd
-
fillCmd
private final java.awt.event.ActionListener fillCmd
-
colonyUnitsCmd
private final java.awt.event.ActionListener colonyUnitsCmd
-
setGoodsCmd
private final java.awt.event.ActionListener setGoodsCmd
-
occupationCmd
private final java.awt.event.ActionListener occupationCmd
-
-
Constructor Detail
-
ColonyPanel
public ColonyPanel(FreeColClient freeColClient, Colony colony)
The constructor for the panel.- Parameters:
freeColClient
- TheFreeColClient
for the game.colony
- TheColony
to display in this panel.
-
-
Method Detail
-
setColony
private void setColony(Colony colony)
Set the current colony.- Parameters:
colony
- The new colony value.
-
getTilesScrollGuiScaledDimension
private java.awt.Dimension getTilesScrollGuiScaledDimension()
-
initialize
private void initialize(Colony colony)
Initialize the entire panel. We can arrive here normally when a colony panel is created, or when an existing colony panel is changed via the colony name menu in the nameBox.- Parameters:
colony
- TheColony
to be displayed.
-
cleanup
private void cleanup()
Clean up this colony panel.
-
addMouseListeners
private void addMouseListeners()
-
removeMouseListeners
private void removeMouseListeners()
-
setTransferHandlers
private void setTransferHandlers(boolean enable)
-
addPropertyChangeListeners
private void addPropertyChangeListeners()
Add property change listeners needed by this ColonyPanel.
-
removePropertyChangeListeners
private void removePropertyChangeListeners()
Remove the property change listeners of ColonyPanel.
-
updateProduction
private void updateProduction()
Update all the production-related panels. This has to be very broad as a change at one work location can have a secondary effect on another, and especially if the population hits a bonus boundary. A simple example is that adding extra lumber production may improve the production of the lumber mill. These changes can then flow on to production and construction displays.
-
update
public void update()
Update the entire colony panel.
-
updateCarrierButtons
private void updateCarrierButtons()
Enables the unload and fill buttons if the currently selected unit is a carrier with some cargo.
-
generateColonyUnitsMenu
private void generateColonyUnitsMenu()
Generates a menu containing the units currently accessible from the Colony Panel allowing keyboard access to said units.
-
tryWork
private boolean tryWork(Unit unit, WorkLocation wl)
Try to assign a unit to work in a colony work location.- Parameters:
unit
- TheUnit
that is to work.wl
- TheWorkLocation
to work in.- Returns:
- True if the unit is now in the work location.
-
getColony
public final Colony getColony()
Gets theColony
in use. Try to use this at the top of all the routines that need the colony, to get a stable value. There have been nasty races when the colony changes out from underneath us, and more may be lurking.- Returns:
- The
Colony
.
-
getTilesPanel
public final ColonyPanel.TilesPanel getTilesPanel()
Gets theTilesPanel
-object in use.- Returns:
- The
TilesPanel
.
-
getWarehousePanel
public final ColonyPanel.WarehousePanel getWarehousePanel()
Gets theWarehousePanel
-object in use.- Returns:
- The
WarehousePanel
.
-
setSelectedUnitLabel
public void setSelectedUnitLabel(UnitLabel unitLabel)
Set the selected unit label.- Overrides:
setSelectedUnitLabel
in classPortPanel
- Parameters:
unitLabel
- The unit label to select.
-
setSelectedUnit
public boolean setSelectedUnit(Unit unit)
Select a given unit.- Overrides:
setSelectedUnit
in classPortPanel
- Parameters:
unit
- TheUnit
to select.- Returns:
- True if the selection succeeds.
-
updateBuildingsPanel
private void updateBuildingsPanel()
-
updateConstructionPanel
private void updateConstructionPanel()
-
updateInPortPanel
private void updateInPortPanel()
-
updateNetProductionPanel
private void updateNetProductionPanel()
-
updateOutsideColonyPanel
private void updateOutsideColonyPanel()
-
updatePopulationPanel
private void updatePopulationPanel()
-
updateTilesPanel
private void updateTilesPanel()
-
updateWarehousePanel
private void updateWarehousePanel()
-
closeColonyPanel
public void closeColonyPanel()
Close thisColonyPanel
.
-
getUnitList
public java.util.List<Unit> getUnitList()
Gets the list of units on the colony tile. Note, does not include the units *inside* the colony.- Specified by:
getUnitList
in classPortPanel
- Returns:
- A sorted list of units on the colony tile.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent ae)
- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
- Overrides:
actionPerformed
in classFreeColPanel
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent event)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
removeNotify
public void removeNotify()
- Overrides:
removeNotify
in classPortPanel
-
-