Package swingtree

Enum Class UI.FontStyle

All Implemented Interfaces:
Serializable, Comparable<UI.FontStyle>, Constable, UIEnum<UI.FontStyle>
Enclosing class:
UI

@Immutable public static enum UI.FontStyle extends Enum<UI.FontStyle> implements UIEnum<UI.FontStyle>
Names how the glyphs of a font are drawn: upright and thin as PLAIN, thickened as BOLD, slanted as ITALIC, or both at once as BOLD_ITALIC. There are four constants because boldness and slant are two independent switches.

isBold() and isItalic() read those two switches back out, and withBold(boolean) and withItalic(boolean) change one of them while keeping the other, which is what a toolbar with a separate bold button and italic button needs.

See Also:
  • Enum Constant Details

    • PLAIN

      public static final UI.FontStyle PLAIN
      Glyphs drawn upright and unthickened.
    • BOLD

      public static final UI.FontStyle BOLD
      Glyphs drawn with thickened strokes and upright.
    • ITALIC

      public static final UI.FontStyle ITALIC
      Glyphs drawn slanted and unthickened.
    • BOLD_ITALIC

      public static final UI.FontStyle BOLD_ITALIC
      Glyphs drawn with thickened strokes and slanted.
  • Method Details

    • values

      public static UI.FontStyle[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static UI.FontStyle valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isBold

      public boolean isBold()
      Tells whether this style draws its glyphs with thickened strokes.
      Returns:
      True for BOLD and BOLD_ITALIC.
    • isItalic

      public boolean isItalic()
      Tells whether this style draws its glyphs slanted.
      Returns:
      True for ITALIC and BOLD_ITALIC.
    • withBold

      public UI.FontStyle withBold(boolean bold)
      Returns the style which is this one with boldness turned on or off and the slant left as it is. Turning boldness on for ITALIC therefore gives BOLD_ITALIC rather than BOLD, which is what a bold button sitting next to an italic button has to do.
      Parameters:
      bold - Whether the returned style should thicken its strokes.
      Returns:
      The style with the requested boldness and the slant of this one.
    • withItalic

      public UI.FontStyle withItalic(boolean italic)
      Returns the style which is this one with the slant turned on or off and the boldness left as it is. Turning the slant off for BOLD_ITALIC therefore gives BOLD rather than PLAIN, which is what an italic button sitting next to a bold button has to do.
      Parameters:
      italic - Whether the returned style should slant its glyphs.
      Returns:
      The style with the requested slant and the boldness of this one.