Class MoraleBar

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class MoraleBar extends JPanel
A compact, segmented gauge that visualizes enemy AtBMoraleLevel.

The bar has one segment per possible morale level, ordered from the morale scale's minimum to its maximum. The gauge reads like the enemy's morale meter: the more segments that are lit, the higher the enemy's morale. The colors are presented from the player's perspective: low enemy morale (a routed enemy) is green because it is favourable for the player, climbing through orange and into red at the highest morale (a dangerous, fully-committed enemy). Hovering a segment shows the name and description of that morale level.

See Also:
  • Constructor Details

    • MoraleBar

      public MoraleBar(@Nonnull AtBMoraleLevel moraleLevel, @Nonnull String labelText)
      Creates a morale bar for the given morale level, with a label drawn beneath the active segment.
      Parameters:
      moraleLevel - the enemy morale level to display
      labelText - the text to show beneath the current level (for example the morale level's name, or a contract-specific name such as "Peaceful"). Pass a blank string to show no label.
  • Method Details

    • setToolTipText

      public void setToolTipText(@Nullable String text)
      Forwards the tooltip to the wrapped gauge so that the area around the segments (gaps and the label) shows this fallback tooltip, while individual segments keep their own per-level tooltips.
      Overrides:
      setToolTipText in class JComponent
      Parameters:
      text - the tooltip text, or null for none
    • createDialogPanel

      @Nonnull public static JPanel createDialogPanel(@Nonnull AtBContract contract)
      Builds a self-contained panel wrapping a MoraleBar, suitable for embedding in dialogs such as the immersive "Morale Update" notification. The bar is given generous horizontal padding so it reads as a centered gauge rather than spanning the full dialog width. The label beneath the active segment honours the contract's special "Peaceful" wording for routed garrison/retainer contracts, matching the briefing-room contract panel.
      Parameters:
      contract - the contract whose enemy morale should be displayed
      Returns:
      a transparent panel containing the configured morale bar
    • getMoraleDisplay

      @Nonnull public static MoraleBar.MoraleDisplay getMoraleDisplay(@Nonnull AtBContract contract)
      Computes the morale label and tooltip for a contract, applying the special "Peaceful" wording used for routed garrison-duty and retainer contracts. This is the single source of truth shared by the briefing-room contract panel and the morale dialog so the two never diverge.
      Parameters:
      contract - the contract whose enemy morale should be described
      Returns:
      the label and tooltip to display