Package megameklab.ui.util
Class BayWeaponCriticalTree
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTree
megameklab.ui.util.BayWeaponCriticalTree
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible,Scrollable
Variant of DropTargetCriticalList for aerospace units that groups weapons into bays. Also includes support for
treating spheroid small craft and dropships firing arcs separately from their locations.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JTree
JTree.AccessibleJTree, JTree.DropLocation, JTree.DynamicUtilTreeNode, JTree.EmptySelectionModel, JTree.TreeModelHandler, JTree.TreeSelectionRedirectorNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intFields inherited from class javax.swing.JTree
ANCHOR_SELECTION_PATH_PROPERTY, CELL_EDITOR_PROPERTY, CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, editable, EDITABLE_PROPERTY, EXPANDS_SELECTED_PATHS_PROPERTY, INVOKES_STOP_CELL_EDITING_PROPERTY, invokesStopCellEditing, LARGE_MODEL_PROPERTY, largeModel, LEAD_SELECTION_PATH_PROPERTY, ROOT_VISIBLE_PROPERTY, rootVisible, ROW_HEIGHT_PROPERTY, rowHeight, SCROLLS_ON_EXPAND_PROPERTY, scrollsOnExpand, SELECTION_MODEL_PROPERTY, selectionModel, selectionRedirector, SHOWS_ROOT_HANDLES_PROPERTY, showsRootHandles, TOGGLE_CLICK_COUNT_PROPERTY, toggleClickCount, TREE_MODEL_PROPERTY, treeModel, treeModelListener, VISIBLE_ROW_COUNT_PROPERTY, visibleRowCountFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionBayWeaponCriticalTree(int location, EntitySource eSource, RefreshListener refresh) BayWeaponCriticalTree(int location, EntitySource eSource, RefreshListener refresh, int facing) -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled by the transfer handler when ammo is dropped on this location as a move command, indicating a single slot should be moved.voidaddAmmoToBay(megamek.common.equipment.WeaponMounted bay, megamek.common.equipment.AmmoMounted eq, int shots) voidaddBay(megamek.common.equipment.WeaponMounted bay) Moves a bay and all its contents from another locationvoidCalled by the transfer handler when equipment is dropped on this location.voidaddToBay(megamek.common.equipment.WeaponMounted bay, megamek.common.equipment.Mounted<?> eq) Adds an equipment mount to a bay.voidaddToLocation(List<megamek.common.equipment.Mounted<?>> eqList) Adds multiple equipment mounts to this location.voidaddToLocation(megamek.common.equipment.Mounted<?> eq) Adds equipment to a location without a bay.voidaddToNewBay(megamek.common.equipment.EquipmentType bayType, megamek.common.equipment.WeaponMounted eq) Adds a new bay of the appropriate type to the unit and adds the equipment to the bay.List<megamek.common.equipment.WeaponMounted> baysFor(megamek.common.equipment.Mounted<?> eq) Finds all bays in this arc where the given equipment can be added based on type and current AV.booleancanAdd(megamek.common.equipment.Mounted<?> eq) Determines whether equipment can be added to this location.Builds a String representation of the selected node that can be used by the transfer handler to find the node to be removed after export.megamek.common.equipment.WeaponMountedgetBayFromPath(TreePath path) Used by the unallocated equipment list to show the name of the location on the popup menuintbooleanisValidDropLocation(JTree.DropLocation loc, megamek.common.equipment.Mounted<?> eq) Determines whether the equipment can be dropped here.voidrebuild()voidremoveExported(String selection, int action) voidsetFacing(int facing) Sets whether this arc should show only forward-mounted, rear-mounted, or bothvoidupdateRefresh(RefreshListener refresh) booleanvalidForUnit(megamek.common.units.Aero aero) Used by the unallocated equipment list to determine whether the arc represented by this tree is valid for the aero unit.Methods inherited from class javax.swing.JTree
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearSelection, clearToggledPaths, collapsePath, collapseRow, convertValueToText, createTreeModel, createTreeModelListener, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, fireValueChanged, getAccessibleContext, getAnchorSelectionPath, getCellEditor, getCellRenderer, getClosestPathForLocation, getClosestRowForLocation, getDefaultTreeModel, getDescendantToggledPaths, getDragEnabled, getDropLocation, getDropMode, getEditingPath, getExpandedDescendants, getExpandsSelectedPaths, getInvokesStopCellEditing, getLastSelectedPathComponent, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getModel, getNextMatch, getPathBetweenRows, getPathBounds, getPathForLocation, getPathForRow, getPreferredScrollableViewportSize, getRowBounds, getRowCount, getRowForLocation, getRowForPath, getRowHeight, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollsOnExpand, getSelectionCount, getSelectionModel, getSelectionPath, getSelectionPaths, getSelectionRows, getShowsRootHandles, getToggleClickCount, getToolTipText, getTreeExpansionListeners, getTreeSelectionListeners, getTreeWillExpandListeners, getUI, getUIClassID, getVisibleRowCount, hasBeenExpanded, isCollapsed, isCollapsed, isEditable, isEditing, isExpanded, isExpanded, isFixedRowHeight, isLargeModel, isPathEditable, isPathSelected, isRootVisible, isRowSelected, isSelectionEmpty, isVisible, makeVisible, paramString, removeDescendantSelectedPaths, removeDescendantToggledPaths, removeSelectionInterval, removeSelectionPath, removeSelectionPaths, removeSelectionRow, removeSelectionRows, removeTreeExpansionListener, removeTreeSelectionListener, removeTreeWillExpandListener, scrollPathToVisible, scrollRowToVisible, setAnchorSelectionPath, setCellEditor, setCellRenderer, setDragEnabled, setDropMode, setEditable, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setModel, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionModel, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, startEditingAtPath, stopEditing, treeDidChange, updateUIMethods 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, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, 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, 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, updateMethods 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, validateTreeMethods 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 Details
-
FORWARD
public static final int FORWARD- See Also:
-
BOTH
public static final int BOTH- See Also:
-
AFT
public static final int AFT- See Also:
-
-
Constructor Details
-
BayWeaponCriticalTree
-
BayWeaponCriticalTree
public BayWeaponCriticalTree(int location, EntitySource eSource, RefreshListener refresh, int facing)
-
-
Method Details
-
setFacing
public void setFacing(int facing) Sets whether this arc should show only forward-mounted, rear-mounted, or both- Parameters:
facing- Either FORWARD, AFT, or BOTH
-
updateRefresh
-
rebuild
public void rebuild() -
getSlotCount
public int getSlotCount()- Returns:
- The number of weapon slots required by equipment allocated to this arc.
-
getMinimumSize
- Overrides:
getMinimumSizein classJComponent
-
getLocationName
Used by the unallocated equipment list to show the name of the location on the popup menu- Returns:
- The name of the location
-
validForUnit
public boolean validForUnit(megamek.common.units.Aero aero) Used by the unallocated equipment list to determine whether the arc represented by this tree is valid for the aero unit. This filters out aft side arcs for aerodyne small craft and broadsides for non-warships.- Parameters:
aero- The unit to check- Returns:
- Whether the arc is valid for the unit.
-
baysFor
Finds all bays in this arc where the given equipment can be added based on type and current AV.- Parameters:
eq- An equipment mount- Returns:
- A list of valid bays for the equipment
-
canAdd
public boolean canAdd(megamek.common.equipment.Mounted<?> eq) Determines whether equipment can be added to this location. Ammo requires a bay with a suitable weapon, as do weapon enhancements. All other equipment can be added.- Parameters:
eq- Potential equipment to be added to the location.- Returns:
- Whether the equipment can be added to the location.
-
addToNewBay
public void addToNewBay(megamek.common.equipment.EquipmentType bayType, megamek.common.equipment.WeaponMounted eq) Adds a new bay of the appropriate type to the unit and adds the equipment to the bay.- Parameters:
bayType- The type of bay to be added.eq- The equipment to be added.
-
addToBay
public void addToBay(@Nullable megamek.common.equipment.WeaponMounted bay, megamek.common.equipment.Mounted<?> eq) Adds an equipment mount to a bay. Changes the equipment mount's location and updates the bay's weapon or ammo list if necessary.- Parameters:
bay- The receiving weapon bayeq- The equipment to add to the bay
-
addAmmoToBay
public void addAmmoToBay(megamek.common.equipment.WeaponMounted bay, megamek.common.equipment.AmmoMounted eq, int shots) -
addToLocation
public void addToLocation(megamek.common.equipment.Mounted<?> eq) Adds equipment to a location without a bay.- Parameters:
eq- The equipment to add to the location of this tree
-
addToLocation
Adds multiple equipment mounts to this location. Weapons and ammo will go into the first available bay. Ammo that does not have a legal bay will be skipped.- Parameters:
eqList- The equipment to add
-
addToArc
Called by the transfer handler when equipment is dropped on this location.- Parameters:
eq- The equipment dropped on this locationpath- The tree node under the drop point
-
addAmmo
Called by the transfer handler when ammo is dropped on this location as a move command, indicating a single slot should be moved. A copy command (ctrl key held) will transfer all ammo usingaddToArc. -
addBay
public void addBay(megamek.common.equipment.WeaponMounted bay) Moves a bay and all its contents from another location- Parameters:
bay- The bay to move in
-
isValidDropLocation
Determines whether the equipment can be dropped here. In the case of ammo or weapon enhancement, there must be a matching weapon in the bay. A weapon that doesn't fit the bay will be placed in a new bay.- Parameters:
loc- The drop location from the TransferSupport object passed to the TransferHandlereq- The equipment to be dropped- Returns:
- Whether the equipment can be dropped in the location
-
getBayFromPath
-
encodeSelection
Builds a String representation of the selected node that can be used by the transfer handler to find the node to be removed after export.- Returns:
- A String in the format equipmentNum,nodeIndex[,bayNodeIndex]
-
removeExported
-