Class FontProperty

java.lang.Object
ca.corbett.extras.properties.AbstractProperty
ca.corbett.extras.properties.FontProperty

public class FontProperty extends AbstractProperty
Represents a property field that allows storing a Font, along with associated style and optional color attributes.
Author:
scorbo2
  • Field Details

    • DEFAULT_FONT

      public static final Font DEFAULT_FONT
    • font

      protected Font font
    • textColor

      protected Color textColor
    • bgColor

      protected Color bgColor
    • allowSizeSelection

      protected boolean allowSizeSelection
  • Constructor Details

    • FontProperty

      public FontProperty(String name, String label)
      Creates a new FontProperty with all default values. This will use FontProperty.DEFAULT_FONT as the font, and will set null for both foreground and background colors.
      Parameters:
      name - The fully qualified field name.
      label - The field label.
    • FontProperty

      public FontProperty(String name, String label, Font font)
      Creates a new FontProperty with the given font and null for both foreground and background colors.
      Parameters:
      name - The fully qualified field name.
      label - The field label.
      font - The initial font.
    • FontProperty

      public FontProperty(String name, String label, Font font, Color textColor)
      Creates a new FontProperty with the given font and the given foreground color, and null for the background color.
      Parameters:
      name - The fully qualified field name.
      label - The field label.
      font - The initial font.
      textColor - The foreground color.
    • FontProperty

      public FontProperty(String name, String label, Color textColor)
      Creates a new FontProperty with the default font and the given foreground color and a null background color. FontProperty.DEFAULT_FONT will be used for the font.
      Parameters:
      name - The fully qualified field name.
      label - The field label.
      textColor - The foreground color.
    • FontProperty

      public FontProperty(String name, String label, Color textColor, Color bgColor)
      Creates a new FontProperty with the default font and the given foreground color and the given background color. FontProperty.DEFAULT_FONT will be used for the font.
      Parameters:
      name - The fully qualified field name.
      label - The field label.
      textColor - The foreground color.
      bgColor - The background color.
    • FontProperty

      public FontProperty(String name, String label, Font font, Color textColor, Color bgColor)
      Creates a new FontProperty with the given font and the given foreground color and the given background color.
      Parameters:
      name - The fully qualified field name.
      label - The field label.
      font - The initial font.
      textColor - The foreground color.
      bgColor - The background color.
  • Method Details

    • setFont

      public FontProperty setFont(Font font)
    • getTextColor

      public Color getTextColor()
    • getBgColor

      public Color getBgColor()
    • setTextColor

      public FontProperty setTextColor(Color color)
    • setBgColor

      public void setBgColor(Color color)
    • getFont

      public Font getFont()
    • isAllowSizeSelection

      public boolean isAllowSizeSelection()
    • setAllowSizeSelection

      public FontProperty setAllowSizeSelection(boolean allow)
    • saveToProps

      public void saveToProps(Properties props)
      Description copied from class: AbstractProperty
      Saves the current value(s) of this property to the given Properties instance.
      Specified by:
      saveToProps in class AbstractProperty
      Parameters:
      props - Any Properties instance which will receive the value(s) of this property.
    • loadFromProps

      public void loadFromProps(Properties props)
      Description copied from class: AbstractProperty
      Loads the value(s) for this property from the given Properties instance, overwriting any current value. The current value of this property will be used as a default value in the event that this property does not exist in the given Properties instance.
      Specified by:
      loadFromProps in class AbstractProperty
      Parameters:
      props - Any Properties instance which contains value(s) for this property.
    • generateFormFieldImpl

      protected FormField generateFormFieldImpl()
      Description copied from class: AbstractProperty
      Descendant classes must implement this method to generate a FormField associated with this property. The generateFormField() method in this class will call this abstract method to create the FormField, which will then be augmented with our fully qualified name, read-only state, help text, and extra attributes.
      Specified by:
      generateFormFieldImpl in class AbstractProperty
      Returns:
      A FormField associated with this property.
    • loadFromFormField

      public void loadFromFormField(FormField field)
      Description copied from class: AbstractProperty
      Populates this Property's value(s) from the given form field, assuming the field is of the correct type.
      Specified by:
      loadFromFormField in class AbstractProperty
      Parameters:
      field - The FormField containing a value for this property.