Class CritCellUtil

java.lang.Object
megameklab.ui.util.CritCellUtil

public final class CritCellUtil extends Object
Contains constants and utils for a unified crit cell display across unit types.
  • Field Details

    • CRITICAL_CELL_WIDTH_STRING

      public static final String CRITICAL_CELL_WIDTH_STRING
      The base width of Crit Cells across units with 3 columns of crit lists
    • CRITICAL_CELL_ADD_HEIGHT

      public static final int CRITICAL_CELL_ADD_HEIGHT
      The height added to the text height of Crit Cells (padding)
      See Also:
    • ZERO_CRIT_SEPARATOR_HEIGHT

      public static final int ZERO_CRIT_SEPARATOR_HEIGHT
      The vertical padding (in pixels) inserted above the first virtual (0-crit) slot entry.
      See Also:
    • CRITICAL_CELL_BORDER_COLOR

      public static final Color CRITICAL_CELL_BORDER_COLOR
    • EMPTY_CRITICAL_CELL_TEXT

      public static final String EMPTY_CRITICAL_CELL_TEXT
      See Also:
  • Constructor Details

    • CritCellUtil

      public CritCellUtil()
  • Method Details

    • locationBorder

      public static Border locationBorder(String title)
      Parameters:
      title - the title for this component
      Returns:
      a titled border using the given string as title placed centered atop the Component and using a LocationBorder as a border. To be used for crit location blocks, especially when they have additional information ("Slots: 0/2") above or below the crits to group them visually.
    • locationBorderNoLine

      public static Border locationBorderNoLine(String title)
      Parameters:
      title - the title for this Component
      Returns:
      a titled but otherwise empty border using the given string as the title placed centered atop the Component.
    • formatCell

      public static void formatCell(JLabel cell, @Nullable megamek.common.equipment.Mounted<?> mounted, boolean useColor, megamek.common.units.Entity entity, int index)
      Applies crit cell formatting to the given JLabel cell, which is assumed to display the given mounted in the given entity at the given crit cell index. The JLabel cell should be a ListCellRenderer or TreeCellRenderer return value.