Class FontCache

java.lang.Object
org.ka2ddo.yaac.gui.FontCache
All Implemented Interfaces:
Iterable<Map.Entry<String,Font>>

public class FontCache extends Object implements Iterable<Map.Entry<String,Font>>
This is a place to keep the font choices used for some of the GUI rendering in YAAC.
Author:
Andrew Pavlin, KA2DDO
  • Method Details

    • getInstance

      public static FontCache getInstance()
      Get a reference to the singleton FontCache
      Returns:
      FontCache object
    • getFont

      public Font getFont(String category)
      Get the font to use for a a particular GUI category.
      Parameters:
      category - Font family name
      Returns:
      the currently preferred Font for this category
    • setFont

      public void setFont(String category, Font f)
      Set the font to use for the logical font category.
      Parameters:
      category - String name of font category, as taken from the constant Strings in the Font class
      f - the Font to associate with the category
    • iterator

      public Iterator<Map.Entry<String,Font>> iterator()
      Create an Iterator for scanning through the configured Fonts.
      Specified by:
      iterator in interface Iterable<Map.Entry<String,Font>>
      Returns:
      an entrySet Iterator for the font map
    • addFontChangeListener

      public void addFontChangeListener(FontChangeListener l)
      Register a listener to be informed when the user changes font selections.
      Parameters:
      l - FontChangeListener to register
    • removeFontChangeListener

      public void removeFontChangeListener(FontChangeListener l)
      Unregister a listener from being informed of user font selection changes.
      Parameters:
      l - FontChangeListener to unregister
    • setupJFrameForMenuFonts

      public static void setupJFrameForMenuFonts(JFrame frame)
      Helper method for configuring a JFrame to use user-selected fonts for the menu bar.
      Parameters:
      frame - JFrame to initialize with configured sanserif font
    • setupJComponentForFonts

      public static void setupJComponentForFonts(JComponent comp)
      Helper method to configure an arbitrary JComponent to get its font updated when the user font choice is changed.
      Parameters:
      comp - JComponent to associate with configured font