Package net.sf.freecol.client.gui.panel
Class BuildQueuePanel
- 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.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 transferBuildQueueItem
s 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
-
-
Field Summary
Fields Modifier and Type Field Description private static java.awt.datatransfer.DataFlavor
BUILD_LIST_FLAVOR
private javax.swing.JList<BuildingType>
buildingList
The list of buildable building types.private BuildQueuePanel.BuildQueueTransferHandler
buildQueueHandler
A transfer handler for the build queue lists.private javax.swing.JList<BuildableType>
buildQueueList
The build queue.private static java.lang.String
BUY
private javax.swing.JButton
buyBuildable
A button to buy the current buildable.private Colony
colony
The enclosing colony.private javax.swing.JCheckBox
compactBox
The check box to enable compact mode.private ConstructionPanel
constructionPanel
The panel showing the current buildable.private static boolean
defaultCompact
Default setting for the compact box.private static boolean
defaultShowAll
Default setting for the showAll box.private static java.lang.String
FAIL
private FeatureContainer
featureContainer
A feature container for potential features from queued buildables.private java.util.Map<BuildableType,java.lang.String>
lockReasons
private static java.util.logging.Logger
logger
private javax.swing.JCheckBox
showAllBox
The check box to enable showing all buildables.private static int
UNABLE_TO_BUILD
private javax.swing.JList<UnitType>
unitList
The list of buildable unit types.-
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 BuildQueuePanel(FreeColClient freeColClient, Colony colony)
Create a new build queue panel.
-
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 specifiedBuildingType
exists within a colonyvoid
itemStateChanged(java.awt.event.ItemEvent event)
OverrideItemListener
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, usingupdateBuildingList()
andupdateUnitList()
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 net.sf.freecol.client.gui.panel.FreeColPanel
addClosingCallback, createColonyButton, getClientOptions, getFreeColClient, getGame, getGUI, getImageLibrary, getMap, getMyPlayer, getSmallAbstractUnitImage, getSpecification, igc, isEditable, removeNotify, 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, 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
-
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
BUILD_LIST_FLAVOR
private static final java.awt.datatransfer.DataFlavor BUILD_LIST_FLAVOR
-
FAIL
private static final java.lang.String FAIL
- See Also:
- Constant Field Values
-
BUY
private static final java.lang.String BUY
- See Also:
- Constant Field Values
-
UNABLE_TO_BUILD
private static final int UNABLE_TO_BUILD
- See Also:
- Constant Field Values
-
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.
-
buildQueueHandler
private final BuildQueuePanel.BuildQueueTransferHandler buildQueueHandler
A transfer handler for the build queue lists.
-
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
- TheFreeColClient
for the game.colony
- The enclosingColony
.
-
-
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
- TheJComponent
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?
-
updateAllLists
private final void updateAllLists()
Update all the lists and buttons, usingupdateBuildingList()
andupdateUnitList()
-
setBuyLabel
private void setBuyLabel(BuildableType buildable)
-
hasBuildingType
private boolean hasBuildingType(BuildingType buildingType)
Checks whether a specifiedBuildingType
exists within a colony- Parameters:
buildingType
- TheBuildingType
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 interfacejava.awt.event.ActionListener
- Overrides:
actionPerformed
in classFreeColPanel
-
itemStateChanged
public void itemStateChanged(java.awt.event.ItemEvent event)
OverrideItemListener
for this panel's use. This function evaluates whether a the user has clicked thecompactBox
or theshowAllBox
has been checked.- Specified by:
itemStateChanged
in interfacejava.awt.event.ItemListener
-
-