Class FontSizer


public class FontSizer extends OSPRuntime.Supported
A class for setting relative font sizes by level.
Version:
1.0
Author:
dobrown
  • Field Details

    • PROPERTY_LEVEL

      public static final String PROPERTY_LEVEL
      See Also:
    • TEXT_FONT

      public static final Font TEXT_FONT
      Base font for text fields
    • BUTTON_FONT

      public static final Font BUTTON_FONT
      Base font for buttons
    • ACCELERATOR_FONT

      public static final Font ACCELERATOR_FONT
      Base font for menu accelerators
    • CHECKBOXMENUITEM_ICON

      public static final ResizableIcon CHECKBOXMENUITEM_ICON
      Icons for checkbox, radio button and arrow menu items
    • RADIOBUTTONMENUITEM_ICON

      public static final ResizableIcon RADIOBUTTONMENUITEM_ICON
    • CHECKBOX_ICON

      public static final ResizableIcon CHECKBOX_ICON
    • RADIOBUTTON_ICON

      public static final ResizableIcon RADIOBUTTON_ICON
    • ARROW_ICON

      public static final ResizableIcon ARROW_ICON
    • MIN_LEVEL

      public static final int MIN_LEVEL
      maximum font level
      See Also:
    • MAX_LEVEL

      public static final int MAX_LEVEL
      See Also:
  • Method Details

    • setFontsIfNot

      public static int setFontsIfNot(int oldLevel, Object c)
    • setMenuFonts

      public static int setMenuFonts(JMenu c)
    • setFonts

      public static int setFonts(Object[] objectsToSize)
    • setFonts

      public static int setFonts(Container c)
    • setFont

      public static int setFont(Component c)
    • setFont

      public static int setFont(AbstractButton button)
    • setLevel

      public static void setLevel(int n)
      Sets the font level and informs all listeners.
      Parameters:
      n - a non-negative integer level
    • getLevel

      public static int getLevel()
      Gets the current font level.
      Returns:
      the level
    • levelUp

      public static void levelUp()
      Increments the font level.
    • levelDown

      public static void levelDown()
      Decrements the font level.
    • getFactor

      public static double getFactor()
      Gets the current factor.
      Returns:
      the factor
    • getIntegerFactor

      public static int getIntegerFactor()
      Gets the current integer factor.
      Returns:
      the integer factor
    • setFonts

      public static int setFonts(Object obj, int level)
      Sets the fonts of an object to a specified level.
      Parameters:
      obj - the object
      level - the level
      Returns:
    • getResizedFont

      public static Font getResizedFont(Font font, int level)
      Resizes a font to a specified level.
      Parameters:
      font - the font
      level - the level
      Returns:
      the resized font
    • getResizedFont

      public static Font getResizedFont(Font font, double factor)
      Resizes a font by a specified factor.
      Parameters:
      font - the font
      factor - the factor
      Returns:
      the resized font
    • getFactor

      public static double getFactor(int level)
      Gets the factor corresponding to a specified level.
      Parameters:
      level - the level
      Returns:
      the factor
    • getIntegerFactor

      public static int getIntegerFactor(int level)
      Gets the integer factor corresponding to a specified level.
      Parameters:
      level - the level
      Returns:
      the integer factor
    • addListener

      public static void addListener(String property, PropertyChangeListener listener)
      Adds a PropertyChangeListener.
      Parameters:
      property - the name of the property (only "level" accepted)
      listener - the object requesting property change notification
    • removeListener

      public static void removeListener(String property, PropertyChangeListener listener)
      Removes a PropertyChangeListener.
      Parameters:
      property - the name of the property (only "level" accepted)
      listener - the listener requesting removal