Class BuildQueuePanel

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

    public class BuildQueuePanel
    extends FreeColPanel
    implements java.awt.event.ItemListener
    The panel used to display a colony build queue.

    Panel Layout:

    | ----------------------------------------------------- | | header | | --------------- | ----------------- | --------------- | | bqpUnits | bpqBuildQueue | bqpBuildings | | --------------- | ----------------- | --------------- | | unitList | constructionPanel | buildingList | | | ----------------- | | | | buildQueueList | | | | | | | ----------------------------------------------------- | | [buyBuildable] []compactBox []showAllBox [okButton] | | ----------------------------------------------------- |

    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  BuildQueuePanel.BuildQueueMouseAdapter  
      private class  BuildQueuePanel.BuildQueueTransferHandler
      This class implements a transfer handler able to transfer BuildQueueItems between the build queue list, the unit list and the building list.
      private class  BuildQueuePanel.DefaultBuildQueueCellRenderer
      The cell renderer to use for the build queue.
      private static class  BuildQueuePanel.IndexedBuildable
      This class represents a buildable, that is dragged/dropped accompanied by its index in the source list where it is dragged from.
      • 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 Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent ae)
      private boolean checkAbilities​(BuildableType bt, java.util.List<java.lang.String> lockReason)  
      private javax.swing.JList<? extends BuildableType> convertJComp​(javax.swing.JComponent comp)
      Convert a component to an actual part of this panel, recovering its list type.
      private java.util.List<BuildableType> getBuildableTypes​(javax.swing.JList<? extends BuildableType> list)  
      Colony getColony()
      Get the colony for this build queue.
      private int getMaximumIndex​(BuildableType buildableType)  
      private int getMinimumIndex​(BuildableType buildableType)  
      private boolean hasBuildingType​(BuildingType buildingType)
      Checks whether a specified BuildingType exists within a colony
      void itemStateChanged​(java.awt.event.ItemEvent event)
      Override ItemListener for this panel's use.
      private void removeBuildable​(java.lang.Object type)  
      private void setBuyLabel​(BuildableType buildable)  
      private void updateAllLists()
      Update all the lists and buttons, using updateBuildingList() and updateUnitList()
      private void updateBuildingList()
      Update the list of available buildings to build This method will verify whether a building can be built by checking against the following criteria: * Does the Colony meet the population limit to build? * Does the new building require a special circumstance, such as a prerequisite unit or building?
      private static void updateCompact​(boolean selected)  
      private void updateDetailView()
      Set the correct cell renderer in the buildables lists.
      private static void updateLists​(boolean selected)  
      private void updateUnitList()
      Update the list of available units (ships, wagon, artillery) to build This method will verify whether a unit can be built by checking against the following criteria: * Does the Colony meet the population limit to build? * Does the new building require a special circumstance, such as a prerequisite unit or building?
      • 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, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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
      • BUILD_LIST_FLAVOR

        private static final java.awt.datatransfer.DataFlavor BUILD_LIST_FLAVOR
      • defaultCompact

        private static boolean defaultCompact
        Default setting for the compact box.
      • defaultShowAll

        private static boolean defaultShowAll
        Default setting for the showAll box.
      • colony

        private final Colony colony
        The enclosing colony.
      • featureContainer

        private final FeatureContainer featureContainer
        A feature container for potential features from queued buildables.
      • unitList

        private final javax.swing.JList<UnitType> unitList
        The list of buildable unit types.
      • constructionPanel

        private final ConstructionPanel constructionPanel
        The panel showing the current buildable.
      • buildQueueList

        private final javax.swing.JList<BuildableType> buildQueueList
        The build queue.
      • buildingList

        private final javax.swing.JList<BuildingType> buildingList
        The list of buildable building types.
      • buyBuildable

        private final javax.swing.JButton buyBuildable
        A button to buy the current buildable.
      • compactBox

        private final javax.swing.JCheckBox compactBox
        The check box to enable compact mode.
      • showAllBox

        private final javax.swing.JCheckBox showAllBox
        The check box to enable showing all buildables.
      • lockReasons

        private final java.util.Map<BuildableType,​java.lang.String> lockReasons
    • Constructor Detail

      • BuildQueuePanel

        public BuildQueuePanel​(FreeColClient freeColClient,
                               Colony colony)
        Create a new build queue panel.
        Parameters:
        freeColClient - The FreeColClient for the game.
        colony - The enclosing Colony.
    • Method Detail

      • getColony

        public Colony getColony()
        Get the colony for this build queue.
        Returns:
        The Colony.
      • convertJComp

        private javax.swing.JList<? extends BuildableType> convertJComp​(javax.swing.JComponent comp)
        Convert a component to an actual part of this panel, recovering its list type.
        Parameters:
        comp - The JComponent to convert.
        Returns:
        The actual panel component JList, or null on error.
      • removeBuildable

        private void removeBuildable​(java.lang.Object type)
      • checkAbilities

        private boolean checkAbilities​(BuildableType bt,
                                       java.util.List<java.lang.String> lockReason)
      • updateBuildingList

        private void updateBuildingList()
        Update the list of available buildings to build This method will verify whether a building can be built by checking against the following criteria: * Does the Colony meet the population limit to build? * Does the new building require a special circumstance, such as a prerequisite unit or building?
      • updateUnitList

        private void updateUnitList()
        Update the list of available units (ships, wagon, artillery) to build This method will verify whether a unit can be built by checking against the following criteria: * Does the Colony meet the population limit to build? * Does the new building require a special circumstance, such as a prerequisite unit or building?
      • setBuyLabel

        private void setBuyLabel​(BuildableType buildable)
      • hasBuildingType

        private boolean hasBuildingType​(BuildingType buildingType)
        Checks whether a specified BuildingType exists within a colony
        Parameters:
        buildingType - The BuildingType to check
        Returns:
        boolean
      • getBuildableTypes

        private java.util.List<BuildableType> getBuildableTypes​(javax.swing.JList<? extends BuildableType> list)
      • getMinimumIndex

        private int getMinimumIndex​(BuildableType buildableType)
      • getMaximumIndex

        private int getMaximumIndex​(BuildableType buildableType)
      • updateDetailView

        private void updateDetailView()
        Set the correct cell renderer in the buildables lists.
      • updateCompact

        private static void updateCompact​(boolean selected)
      • updateLists

        private static void updateLists​(boolean selected)
      • actionPerformed

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

        public void itemStateChanged​(java.awt.event.ItemEvent event)
        Override ItemListener for this panel's use. This function evaluates whether a the user has clicked the compactBox or the showAllBox has been checked.
        Specified by:
        itemStateChanged in interface java.awt.event.ItemListener