public final class UnitLabel extends javax.swing.JLabel implements java.awt.event.ActionListener, Draggable
Modifier and Type | Class and Description |
---|---|
static class |
UnitLabel.UnitAction |
javax.swing.JLabel.AccessibleJLabel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
private FreeColClient |
freeColClient |
private SwingGUI |
gui |
private boolean |
ignoreLocation |
private boolean |
isSmall |
private static java.util.logging.Logger |
logger |
private boolean |
selected |
private Unit |
unit |
private boolean |
useTileImageLibrary |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Constructor and Description |
---|
UnitLabel(FreeColClient freeColClient,
Unit unit)
Creates a JLabel to display a unit.
|
UnitLabel(FreeColClient freeColClient,
Unit unit,
boolean isSmall)
Creates a JLabel to display a unit.
|
UnitLabel(FreeColClient freeColClient,
Unit unit,
boolean isSmall,
boolean ignoreLocation)
Creates a JLabel to display a unit.
|
UnitLabel(FreeColClient freeColClient,
Unit unit,
boolean isSmall,
boolean ignoreLocation,
boolean useTileImageLibrary)
Creates a JLabel to display a unit.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent ae) |
boolean |
canUnitBeEquippedWith(javax.swing.JLabel data)
Can a unit be equipped with a particular label.
|
java.lang.String |
getDescriptionLabel()
Gets the description label.
|
Unit |
getUnit()
Returns this UnitLabel's unit data.
|
static java.lang.String |
getWorkLabel(WorkLocation wl)
Gets a string corresponding to the UnitAction to work at a work
location.
|
boolean |
isOnCarrier()
Is this object on a carrier?
|
void |
paintComponent(java.awt.Graphics g)
Paints this UnitLabel.
|
void |
setDescriptionLabel(java.lang.String label)
Sets the description label.
|
void |
setIgnoreLocation(boolean b)
Sets whether or not this unit label should include production and state
information.
|
void |
setSelected(boolean b)
Sets whether or not this unit should be selected.
|
void |
setSmall(boolean isSmall)
Makes a smaller version.
|
void |
updateIcon()
Update the icon for this unit label.
|
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
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, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, 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
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
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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
private static final java.util.logging.Logger logger
private final FreeColClient freeColClient
private final SwingGUI gui
private final Unit unit
private boolean selected
private boolean isSmall
private boolean ignoreLocation
private boolean useTileImageLibrary
public UnitLabel(FreeColClient freeColClient, Unit unit)
freeColClient
- The FreeColClient
for the game.unit
- The Unit
to display.public UnitLabel(FreeColClient freeColClient, Unit unit, boolean isSmall)
freeColClient
- The FreeColClient
for the game.unit
- The Unit
to display.isSmall
- The image will be smaller if set to true
.public UnitLabel(FreeColClient freeColClient, Unit unit, boolean isSmall, boolean ignoreLocation)
freeColClient
- The FreeColClient
for the game.unit
- The Unit
to display.isSmall
- The image will be smaller if set to true
.ignoreLocation
- The image will not include production or state
information if set to true
.public UnitLabel(FreeColClient freeColClient, Unit unit, boolean isSmall, boolean ignoreLocation, boolean useTileImageLibrary)
freeColClient
- The FreeColClient
for the game.unit
- The Unit
to display.isSmall
- The image will be smaller if set to true
.ignoreLocation
- The image will not include production or state
information if set to true
.useTileImageLibrary
- If false use ImageLibrary in GUI.
If true use tileImageLibrary in SwingGUI.public Unit getUnit()
public void setSelected(boolean b)
b
- Whether or not this unit should be selected.public void setIgnoreLocation(boolean b)
b
- Whether or not this unit label should include production and
state information.public void setSmall(boolean isSmall)
isSmall
- The image will be smaller if set to true
.public java.lang.String getDescriptionLabel()
public void setDescriptionLabel(java.lang.String label)
label
- The string to set the label to.public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- The graphics context in which to do the painting.public void updateIcon()
public boolean canUnitBeEquippedWith(javax.swing.JLabel data)
data
- The label to add.public static java.lang.String getWorkLabel(WorkLocation wl)
wl
- The WorkLocation
to use.public boolean isOnCarrier()
isOnCarrier
in interface Draggable
public void actionPerformed(java.awt.event.ActionEvent ae)
actionPerformed
in interface java.awt.event.ActionListener