Package mekhq.gui
Class StratConPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
mekhq.gui.StratConPanel
- All Implemented Interfaces:
ActionListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
This panel handles AtB-StratCon GUI interactions with a specific scenario track.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
FieldsFields 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
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorsConstructorDescriptionStratConPanel
(CampaignGUI gui, JLabel infoArea) Constructs a StratConPanel instance, given a parent campaign GUI and a pointer to an info area. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Handles action events triggered by various StratCon-related commands from the right-click context menu.boolean
void
Event handler for when a mouse button is released.void
Renders the panel, hexes, forces, facilities and all that.void
selectTrack
(StratConCampaignState campaignState, StratConTrackState track) Handler for when a specific track is selected - switches rendering to that track.void
setCommitForces
(boolean commitForces) Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, 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, 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
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 Details
-
HEX_X_RADIUS
public static final int HEX_X_RADIUS- See Also:
-
HEX_Y_RADIUS
public static final int HEX_Y_RADIUS- See Also:
-
-
Constructor Details
-
StratConPanel
Constructs a StratConPanel instance, given a parent campaign GUI and a pointer to an info area.
-
-
Method Details
-
selectTrack
Handler for when a specific track is selected - switches rendering to that track. -
paintComponent
Renders the panel, hexes, forces, facilities and all that.- Overrides:
paintComponent
in classJComponent
-
mouseReleasedHandler
Event handler for when a mouse button is released. -
getSelectedScenario
-
getCurrentTrack
-
getSelectedCoords
-
actionPerformed
Handles action events triggered by various StratCon-related commands from the right-click context menu. This method processes user interactions to update the game state, scenarios, facilities, and UI elements based on the selected command and inputs from the context menu.The supported commands and their effects are as follows:
RIGHT_CLICK_COMMAND_MANAGE_FORCES
: Displays the force management UI for the selected coordinates.- If no scenario exists at the selected coordinates, the force management UI is directly displayed.
- If a scenario exists, it only displays the UI if the scenario is unresolved.
RIGHT_CLICK_COMMAND_MANAGE_SCENARIO
: Displays the scenario wizard with the current scenario at the selected coordinates if the scenario's state isPRIMARY_FORCES_COMMITTED
.RIGHT_CLICK_COMMAND_REVEAL_TRACK
: Toggles the "GM revealed" state for the current track and updates the menu text to reflect the state ("Hide Track" or "Reveal Track").RIGHT_CLICK_COMMAND_STICKY_FORCE
: Toggles the sticky force assignment for a given force ID at the selected track. When toggled:- -- If selected, the force is added to the track as sticky.
- -- If deselected, the force is removed from the track's sticky forces.
RIGHT_CLICK_COMMAND_REMOVE_FACILITY
: Deletes the facility present at the selected coordinates.RIGHT_CLICK_COMMAND_CAPTURE_FACILITY
: Changes the ownership of the facility at the selected coordinates to a different faction or player, as per the rules defined inStratConRulesManager
.RIGHT_CLICK_COMMAND_ADD_FACILITY
: Adds a new facility to the selected coordinates. The facility's properties (visibility, type, etc.) are copied from the provided source facility.RIGHT_CLICK_COMMAND_REMOVE_SCENARIO
: Deletes the currently selected scenario from the campaign.
- Specified by:
actionPerformed
in interfaceActionListener
- Parameters:
evt
- theActionEvent
representing the user's action. Contains information about the triggering source and command (e.g., which menu item was selected).Behavior:
- The method retrieves the
StratConCoords
currently selected by the user, and performs actions based on the provided command string in the event. - The scenarios, forces, and facilities of the
currentTrack
are modified based on the command type, and updates are visually reflected in the UI. - If a UI-related command is processed (e.g., displaying the scenario wizard or force assignment UI), the appropriate UI components are updated and made visible to the user.
General Information: If no valid
StratConCoords
are selected at the time of the event, the method will terminate with no further action. Certain commands (e.g.,RIGHT_CLICK_COMMAND_REVEAL_TRACK
,RIGHT_CLICK_COMMAND_ADD_FACILITY
) require valid coordinates or source properties to execute successfully.If no specific actions from the above list are matched (no corresponding `case`), the method performs no effect.
- The method retrieves the
-
getPreferredSize
- Overrides:
getPreferredSize
in classJComponent
-
isCommitForces
public boolean isCommitForces() -
setCommitForces
public void setCommitForces(boolean commitForces)
-