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.AccessibleJPanelNested 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
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_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
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 TypeMethodDescriptionvoidHandles action events triggered by various StratCon-related commands from the right-click context menu.voidLeaves paint mode, restoring normal selection and panning.getTerrainImage(String terrainType) booleanDeprecated, for removal: This API element is subject to removal in a future version.booleanNamed for the terrain brush rather thanisPainting, which would sit confusingly beside the package-privateJComponent.isPaintingthis panel inherits but cannot override - a reader inside the painting code would have no way to tell the two apart.voidEvent handler for when a mouse button is released.voidGM tool: opens the terrain palette, putting the map into paint mode until the palette is closed.voidRenders the panel, hexes, forces, facilities and all that.voidGM tool: clears the current sector and regenerates its terrain (and cities/roads), then repaints.voidGM tool: un-reveals every hex in the current sector so scouting can be re-tested, then repaints.voidGM tool: prompts for new sector dimensions and applies them, growing or shrinking at the right and bottom edges.voidScouts (permanently reveals) every hex in the currently selected sector, then repaints.voidselectTrack(StratConCampaignState campaignState, StratConTrackState track) Handler for when a specific track is selected - switches rendering to that track.voidsetCommitForces(boolean commitForces) voidvoidsetPaintBrushRadius(int radius) Sets the brush radius in hexes: 0 paints a single hex, 1 paints it and its neighbors, and so on.voidsetPaintTerrain(String terrain) Sets the terrain the brush lays down.voidsetSelectedCoords(StratConCoords coords) voidToggles the current sector's "GM revealed" state, which shows or hides otherwise-hidden objects (cloaked scenarios, invisible facilities, and unscouted hexes).Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, 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, 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
-
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
-
getStratConScenarioWizard
-
getAssignmentUI
-
selectTrack
Handler for when a specific track is selected - switches rendering to that track. -
scoutCurrentSector
public void scoutCurrentSector()Scouts (permanently reveals) every hex in the currently selected sector, then repaints. Unlike the GM sector reveal, this marks the hexes as revealed, so their contents stay visible afterward. -
regenerateCurrentSector
public void regenerateCurrentSector()GM tool: clears the current sector and regenerates its terrain (and cities/roads), then repaints. Scenarios, facilities, and assigned forces are left in place. -
openTerrainPaintDialog
public void openTerrainPaintDialog()GM tool: opens the terrain palette, putting the map into paint mode until the palette is closed. -
resizeSector
public void resizeSector()GM tool: prompts for new sector dimensions and applies them, growing or shrinking at the right and bottom edges. Warns first when the new size would displace anything. -
setPaintTerrain
Sets the terrain the brush lays down. Called by the terrain palette. -
setPaintBrushRadius
public void setPaintBrushRadius(int radius) Sets the brush radius in hexes: 0 paints a single hex, 1 paints it and its neighbors, and so on. -
isPaintingTerrain
public boolean isPaintingTerrain()Named for the terrain brush rather thanisPainting, which would sit confusingly beside the package-privateJComponent.isPaintingthis panel inherits but cannot override - a reader inside the painting code would have no way to tell the two apart.- Returns:
truewhile the terrain palette is open and clicks paint rather than select.
-
exitPaintMode
public void exitPaintMode()Leaves paint mode, restoring normal selection and panning. Called when the terrain palette closes. -
getTerrainImage
- Returns:
- the map sprite for a terrain type, for the terrain palette to render alongside the name.
-
resetSectorFog
public void resetSectorFog()GM tool: un-reveals every hex in the current sector so scouting can be re-tested, then repaints. Open water is re-revealed, since it never holds fog of war. -
toggleHiddenObjects
public void toggleHiddenObjects()Toggles the current sector's "GM revealed" state, which shows or hides otherwise-hidden objects (cloaked scenarios, invisible facilities, and unscouted hexes). Formerly the "Reveal/Hide Sector" right-click item. -
paintComponent
Renders the panel, hexes, forces, facilities and all that.- Overrides:
paintComponentin classJComponent
-
mouseReleasedHandler
Event handler for when a mouse button is released. -
getSelectedScenario
-
getCurrentTrack
-
setCurrentTrack
-
getSelectedCoords
-
setSelectedCoords
-
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:
actionPerformedin interfaceActionListener- Parameters:
evt- theActionEventrepresenting the user's action. Contains information about the triggering source and command (e.g., which menu item was selected).Behavior:
- The method retrieves the
StratConCoordscurrently selected by the user, and performs actions based on the provided command string in the event. - The scenarios, forces, and facilities of the
currentTrackare 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
StratConCoordsare 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:
getPreferredSizein classJComponent
-
isCommitForces
Deprecated, for removal: This API element is subject to removal in a future version. -
setCommitForces
public void setCommitForces(boolean commitForces)
-