Package adams.gui.core
Class Fonts
- java.lang.Object
-
- adams.gui.core.Fonts
-
public class Fonts extends Object
Helper class for fonts.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description static String
FILENAME
the name of the props file.static String[]
FONTS
the supported font settings.protected static Properties
m_Properties
the properties.
-
Constructor Summary
Constructors Constructor Description Fonts()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Font
decodeFont(String s)
Parses a font string ('name-face-size') and returns the Font object.static String
encodeFont(Font f)
Turns a font into a string representation that can get parsed withdecodeFont(String)
again.static Font
getDefaultFont(String key)
Returns the default Font used by the UI manager.static Font
getFont(String key, Font defValue)
Returns the Font value listed in the props file, or the default value if not found.static Font
getMonospacedFont()
Returns the system wide Monospaced font.static Font
getMonospacedFont(int size)
Returns the system wide Monospaced font with a custom size.static Properties
getProperties()
Returns the properties in use.static Font
getSansFont()
Returns the system wide Sans font.static Font
getSansFont(int size)
Returns the system wide Sans font with a custom size.static String
getString(String key, String defValue)
Returns the string value listed in the props file, or the default value if not found.static void
initFonts()
Initializes all the fonts.protected static void
initializeProperties()
Initializes the properties if necessary.static Component
useBold(Component comp)
Sets bold font for the component.static Component
useItalic(Component comp)
Sets italic font for the component.static Component
usePlain(Component comp)
Sets plain font for the component.
-
-
-
Field Detail
-
FILENAME
public static final String FILENAME
the name of the props file.- See Also:
- Constant Field Values
-
m_Properties
protected static Properties m_Properties
the properties.
-
FONTS
public static String[] FONTS
the supported font settings.
-
-
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 propertydefValue
- 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 propertydefValue
- 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 withdecodeFont(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
-
-