Class FontSelector

java.lang.Object
   |
   +----FontSelector

class FontSelector
extends Object
This class serves as the interface between the Framework properties and parts of the Framework that need Fonts. This class can return a Font (using method getFont()) for a specific Framework property and knows what to do if the property does not exist.

Version:
$Revision: 1.2 $
See Also:
getFont, getProperties, Font

Variable Index

 o defaultFontName
The name of the Font used in case the specified Framework property and the default font property both do not exist.
 o defaultFontProperty
The name of the Framework property that is used to get the name of the Font if the specified Framework property does not exits.

Constructor Index

 o FontSelector()

Method Index

 o getFont(String)
Returns the Font which is defined by the specified Framework property or a default Font.
 o main(String[])
This method is only used for testing this class.
 o newStyle(Font, int)
Duplicates a Font and adds additional styles.

Variables

 o defaultFontProperty
 private static String defaultFontProperty
The name of the Framework property that is used to get the name of the Font if the specified Framework property does not exits.

 o defaultFontName
 private static String defaultFontName
The name of the Font used in case the specified Framework property and the default font property both do not exist.

See Also:
defaultFontProperty

Constructors

 o FontSelector
 FontSelector()

Methods

 o getFont
 Font getFont(String property)
Returns the Font which is defined by the specified Framework property or a default Font. The Font that is returned is determined by executing the following steps in turn until one returns a Font.
  1. Use the specified Framework property to get the name of the Font.
  2. Use the default Font property to get the name of the Font.
  3. Use a default Font name.
Because the last step uses a name that is explicitly coded into this class, this method can always return a Font.

The default Font property can be used to specify a base for all Fonts used by the Framework. For each case where a different Font is needed, a specific property can be added to the Framework properties.

Parameters:
property - the Framework property that specifies a Font
Returns:
an instance of Font
See Also:
defaultFontProperty, defaultFontName
 o newStyle
 static Font newStyle(Font font,
                      int style)
Duplicates a Font and adds additional styles.

Parameters:
font - the original Font.
style - additional styles to add to the Font. Multiple styles can be combined. Please note that these styles are added to the styles the Font already has: adding style PLAIN to an italic Font results in a Font that is still italic.
Returns:
a new Font with additional styles.
 o main
 public static void main(String args[])
This method is only used for testing this class. It prints to System.out the Fonts in several styles that are generated for several properties that are specified on the command line.