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 classColonyPanel.BuildingsPanelThis panel is a list of the colony's buildings.classColonyPanel.ColonyCargoPanelThis panel shows the content of a carrier in the colonyclassColonyPanel.ColonyInPortPanelA panel that holds UnitLabels that represent naval Units that are waiting in the port of the colony.classColonyPanel.OutsideColonyPanelA panel that holds UnitLabels that represent Units that are standing in front of a colony.classColonyPanel.PopulationPanelThe panel to display the population breakdown for this colony.classColonyPanel.TilesPanelA panel that displays the tiles in the immediate area around the colony.classColonyPanel.WarehousePanelA 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.BuildingsPanelbuildingsPanelprivate javax.swing.JScrollPanebuildingsScrollprivate javax.swing.JButtonbuildQueueButtonprivate java.awt.event.ActionListenerbuildQueueCmdprivate javax.swing.JScrollPanecargoScrollprivate ColonycolonyTheColonythis panel is displaying.private javax.swing.JButtoncolonyUnitsButtonprivate java.awt.event.ActionListenercolonyUnitsCmdprivate ConstructionPanelconstructionPanelprivate javax.swing.JButtonfillButtonprivate java.awt.event.ActionListenerfillCmdprivate javax.swing.JScrollPaneinPortScrollprivate static java.util.logging.Loggerloggerprivate javax.swing.JComboBox<Colony>nameBoxprivate javax.swing.JPanelnetProductionPanelprivate java.awt.event.ActionListeneroccupationCmdprivate ColonyPanel.OutsideColonyPaneloutsideColonyPanelprivate javax.swing.JScrollPaneoutsideColonyScrollprivate ColonyPanel.PopulationPanelpopulationPanelprivate java.awt.event.MouseListenerreleaseListenerstatic intSCROLL_AREA_HEIGHTThe height of the area in which autoscrolling should happen.static intSCROLL_SPEEDThe speed of the scrolling.private javax.swing.JButtonsetGoodsButtonprivate java.awt.event.ActionListenersetGoodsCmdprivate ColonyPanel.TilesPaneltilesPanelprivate javax.swing.JScrollPanetilesScrollprivate javax.swing.JButtontraceWorkButtonprivate javax.swing.JButtonunloadButtonprivate java.awt.event.ActionListenerunloadCmdprivate javax.swing.JButtonwarehouseButtonprivate java.awt.event.ActionListenerwarehouseCmdprivate ColonyPanel.WarehousePanelwarehousePanelprivate javax.swing.JScrollPanewarehouseScroll-
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 voidactionPerformed(java.awt.event.ActionEvent ae)private voidaddMouseListeners()private voidaddPropertyChangeListeners()Add property change listeners needed by this ColonyPanel.private voidcleanup()Clean up this colony panel.voidcloseColonyPanel()Close thisColonyPanel.private voidgenerateColonyUnitsMenu()Generates a menu containing the units currently accessible from the Colony Panel allowing keyboard access to said units.ColonygetColony()Gets theColonyin use.ColonyPanel.TilesPanelgetTilesPanel()Gets theTilesPanel-object in use.private java.awt.DimensiongetTilesScrollGuiScaledDimension()java.util.List<Unit>getUnitList()Gets the list of units on the colony tile.ColonyPanel.WarehousePanelgetWarehousePanel()Gets theWarehousePanel-object in use.private voidinitialize(Colony colony)Initialize the entire panel.voidpropertyChange(java.beans.PropertyChangeEvent event)private voidremoveMouseListeners()voidremoveNotify()private voidremovePropertyChangeListeners()Remove the property change listeners of ColonyPanel.private voidsetColony(Colony colony)Set the current colony.booleansetSelectedUnit(Unit unit)Select a given unit.voidsetSelectedUnitLabel(UnitLabel unitLabel)Set the selected unit label.private voidsetTransferHandlers(boolean enable)private booleantryWork(Unit unit, WorkLocation wl)Try to assign a unit to work in a colony work location.voidupdate()Update the entire colony panel.private voidupdateBuildingsPanel()private voidupdateCarrierButtons()Enables the unload and fill buttons if the currently selected unit is a carrier with some cargo.private voidupdateConstructionPanel()private voidupdateInPortPanel()private voidupdateNetProductionPanel()private voidupdateOutsideColonyPanel()private voidupdatePopulationPanel()private voidupdateProduction()Update all the production-related panels.private voidupdateTilesPanel()private voidupdateWarehousePanel()-
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
TheColonythis 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- TheFreeColClientfor the game.colony- TheColonyto 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- TheColonyto 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- TheUnitthat is to work.wl- TheWorkLocationto work in.- Returns:
- True if the unit is now in the work location.
-
getColony
public final Colony getColony()
Gets theColonyin 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:
setSelectedUnitLabelin classPortPanel- Parameters:
unitLabel- The unit label to select.
-
setSelectedUnit
public boolean setSelectedUnit(Unit unit)
Select a given unit.- Overrides:
setSelectedUnitin classPortPanel- Parameters:
unit- TheUnitto 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:
getUnitListin classPortPanel- Returns:
- A sorted list of units on the colony tile.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent ae)
- Specified by:
actionPerformedin interfacejava.awt.event.ActionListener- Overrides:
actionPerformedin classFreeColPanel
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent event)
- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener
-
removeNotify
public void removeNotify()
- Overrides:
removeNotifyin classPortPanel
-
-