Package generic.theme

Class FontModifier

java.lang.Object
generic.theme.FontModifier

public class FontModifier extends Object
Class that can transform one font into another. For example if want a font that is the same basic font as some other font, but is just a different size,style, or family, you use a FontModifier
  • Constructor Details

    • FontModifier

      public FontModifier(String family, Integer style, Integer size)
      Creates a new FontModifier that can change a given font by one or more font properties.
      Parameters:
      family - if non-null, modifies a font to use this family
      style - if non-null, modifies a font to use this style
      size - if non-null, modifies a font to be this size
  • Method Details

    • addFamilyModifier

      public void addFamilyModifier(String newFamily)
      Sets the family for modifying a font
      Parameters:
      newFamily - the font family to use when modifying fonts
    • addSizeModfier

      public void addSizeModfier(int newSize)
      Sets the font size modifier
      Parameters:
      newSize - the size to use when modifying fonts
    • addStyleModifier

      public void addStyleModifier(int newStyle)
      Sets the font style modifier. This can be called multiple times to bold and italicize.
      Parameters:
      newStyle - the style to use for the font.
    • modify

      public Font modify(Font font)
      Returns a modified font for the given font.
      Parameters:
      font - the font to be modified
      Returns:
      a new modified font
    • getSerializationString

      public String getSerializationString()
      Returns a string that can be parsed by the parse(String) method of this class
      Returns:
      a string that can be parsed by the parse(String) method of this class
    • parse

      public static FontModifier parse(String value) throws ParseException
      Parses the given string as one or more font modifiers
      Parameters:
      value - the string to parse as modifiers
      Returns:
      a FontModifier as specified by the given string
      Throws:
      ParseException - if The value can't be parsed