Class Fonts


  • public class Fonts
    extends Object
    Helper class for fonts.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • m_Properties

        protected static Properties m_Properties
        the properties.
      • FONTS

        public static String[] FONTS
        the supported font settings.
    • Constructor Detail

      • Fonts

        public Fonts()
    • Method Detail

      • initializeProperties

        protected static void initializeProperties()
        Initializes the properties if necessary.
      • getProperties

        public static Properties getProperties()
        Returns the properties in use.
        Returns:
        the properties
      • getString

        public static String getString​(String key,
                                       String defValue)
        Returns the string value listed in the props file, or the default value if not found.
        Parameters:
        key - the key of the property
        defValue - the default value to return if property is not stored in props file
        Returns:
        the value
      • getDefaultFont

        public static Font getDefaultFont​(String key)
        Returns the default Font used by the UI manager.
        Parameters:
        key - the key of the font
        Returns:
        the default font
      • getFont

        public static Font getFont​(String key,
                                   Font defValue)
        Returns the Font value listed in the props file, or the default value if not found.
        Parameters:
        key - the key of the property
        defValue - the default value to return if property is not stored in props file
        Returns:
        the value
      • getMonospacedFont

        public static Font getMonospacedFont()
        Returns the system wide Monospaced font.
        Returns:
        the font
      • getMonospacedFont

        public static Font getMonospacedFont​(int size)
        Returns the system wide Monospaced font with a custom size.
        Parameters:
        size - the custom size
        Returns:
        the font
      • getSansFont

        public static Font getSansFont()
        Returns the system wide Sans font.
        Returns:
        the font
      • getSansFont

        public static Font getSansFont​(int size)
        Returns the system wide Sans font with a custom size.
        Parameters:
        size - the custom size
        Returns:
        the font
      • initFonts

        public static void initFonts()
        Initializes all the fonts.
        See Also:
        FONTS
      • decodeFont

        public static Font decodeFont​(String s)
        Parses a font string ('name-face-size') and returns the Font object.
        Parameters:
        s - the string to parse
        Returns:
        the font
        See Also:
        Font.decode(String)
      • encodeFont

        public static String encodeFont​(Font f)
        Turns a font into a string representation that can get parsed with decodeFont(String) again.
        Parameters:
        f - the font to turn into a string
        Returns:
        the font
      • usePlain

        public static Component usePlain​(Component comp)
        Sets plain font for the component.
        Parameters:
        comp - the component to update
        Returns:
        the component
      • useBold

        public static Component useBold​(Component comp)
        Sets bold font for the component.
        Parameters:
        comp - the component to update
        Returns:
        the component
      • useItalic

        public static Component useItalic​(Component comp)
        Sets italic font for the component.
        Parameters:
        comp - the component to update
        Returns:
        the component