Class 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 colony
      class  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
      • 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
    • 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 this ColonyPanel.
      private void generateColonyUnitsMenu()
      Generates a menu containing the units currently accessible from the Colony Panel allowing keyboard access to said units.
      Colony getColony()
      Gets the Colony in use.
      ColonyPanel.TilesPanel getTilesPanel()
      Gets the TilesPanel-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 the WarehousePanel-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 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
      • 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
      • 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
        The Colony 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
      • cargoScroll

        private javax.swing.JScrollPane cargoScroll
      • inPortScroll

        private javax.swing.JScrollPane inPortScroll
      • outsideColonyScroll

        private javax.swing.JScrollPane outsideColonyScroll
      • tilesScroll

        private javax.swing.JScrollPane tilesScroll
      • warehouseScroll

        private javax.swing.JScrollPane warehouseScroll
      • 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 - The FreeColClient for the game.
        colony - The Colony 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 - The Colony 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 - The Unit that is to work.
        wl - The WorkLocation to work in.
        Returns:
        True if the unit is now in the work location.
      • getColony

        public final Colony getColony()
        Gets the Colony 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 the TilesPanel-object in use.
        Returns:
        The TilesPanel.
      • getWarehousePanel

        public final ColonyPanel.WarehousePanel getWarehousePanel()
        Gets the WarehousePanel-object in use.
        Returns:
        The WarehousePanel.
      • setSelectedUnitLabel

        public void setSelectedUnitLabel​(UnitLabel unitLabel)
        Set the selected unit label.
        Overrides:
        setSelectedUnitLabel in class PortPanel
        Parameters:
        unitLabel - The unit label to select.
      • setSelectedUnit

        public boolean setSelectedUnit​(Unit unit)
        Select a given unit.
        Overrides:
        setSelectedUnit in class PortPanel
        Parameters:
        unit - The Unit 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 this ColonyPanel.
      • 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 class PortPanel
        Returns:
        A sorted list of units on the colony tile.
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent ae)
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
        Overrides:
        actionPerformed in class FreeColPanel
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent event)
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener