Class PhaseScoreField

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class PhaseScoreField extends JPanel
Reusable component that renders a wrapped descriptive label and a compact integer input (0..4). The label is a non-editable JTextArea that wraps at ~200px; the component adds a 20px left inset so the label appears offset. The spinner is aligned to the first line of the label.
See Also:
  • Constructor Details

    • PhaseScoreField

      public PhaseScoreField(String labelText, int initial)
      Create a PhaseScoreField containing a wrapped label and a numeric spinner.
      Parameters:
      labelText - text label to display (may be multi-line)
      initial - initial integer value for the spinner (0..4)
  • Method Details

    • getLabelFont

      public static Font getLabelFont()
      Return the shared label font used across all PhaseScoreField instances.
      Returns:
      default label font (24pt sans-serif)
    • setGlobalLabelWidth

      public static void setGlobalLabelWidth(int px)
      Set a global label width used by all PhaseScoreField instances created after calling this method. This helps align the spinner input across multiple rows so the entry fields start at a consistent position.
      Parameters:
      px - target global label width in pixels (will be clamped to a sensible minimum)
    • getGlobalLabelWidth

      public static int getGlobalLabelWidth()
      Return the configured global label width in pixels used by new instances.
      Returns:
      global label width in pixels
    • computeMaxLabelPixelWidth

      public static int computeMaxLabelPixelWidth(Font font, String[] labels)
      Compute the pixel width of the longest label string using the given font. Returns the maximum string width in pixels.
      Parameters:
      font - font to use when measuring (may be null to use default)
      labels - array of label texts to measure
      Returns:
      maximum string width in pixels (>=0)
    • setLabel

      public void setLabel(String text)
      Set the visible label text for this row.
      Parameters:
      text - new label text
    • getLabel

      public String getLabel()
      Get the current label text for this field.
      Returns:
      label text
    • getValue

      public int getValue()
      Get the integer value currently selected in the spinner.
      Returns:
      spinner integer value (0..4)
    • setValue

      public void setValue(int v)
      Set the spinner value clamped to the valid range (0..4).
      Parameters:
      v - desired spinner value
    • setName

      public void setName(String name)
      Overrides:
      setName in class Component
    • getSpinnerX

      public int getSpinnerX()
      Get the X coordinate of the spinner inside this component (pixels).
      Returns:
      spinner X position in pixels
    • getLabelWrapWidth

      public int getLabelWrapWidth()
      Return the configured label wrap container's current width in pixels.
      Returns:
      label wrap width in pixels
    • getActualGap

      public int getActualGap()
      Actual horizontal gap in pixels between the label wrap right edge and the spinner left edge.
      Returns:
      pixel gap between label and spinner