org.icepdf.ri.util
Class FontPropertiesManager

java.lang.Object
  extended by org.icepdf.ri.util.FontPropertiesManager

public class FontPropertiesManager
extends java.lang.Object

This class provides a very basic Font Properties Management system. When this class is initiated, the properites file "pdfviewerfontcache.properties" is read from the default application file path. If the file cannot be found then all system fonts are read from the operating system and are written to the "pdfviewerfontcache.properties" file.

This class is designed to speed up the load time of the viewer application by reading already parsed font information from the properties file. If new fonts are added to the system, the "pdfviewerfontcache.properties" file can be deleted to trigger this class to re-read the System fonts and re-create a new "pdfviewerfontcache.properties" properites file. // read/store the font cache. ResourceBundle messageBundle = ResourceBundle.getBundle( PropertiesManager.DEFAULT_MESSAGE_BUNDLE); PropertiesManager properties = new PropertiesManager(System.getProperties(), ResourceBundle.getBundle(PropertiesManager.DEFAULT_MESSAGE_BUNDLE)); new FontPropertiesManager(properties, System.getProperties(), messageBundle);

Since:
2.0

Constructor Summary
FontPropertiesManager(PropertiesManager appProps, java.util.Properties sysProps, java.util.ResourceBundle messageBundle)
          Create a new instance of the FontPropertiesManager class.
FontPropertiesManager(PropertiesManager appProps, java.util.ResourceBundle messageBundle)
          Create a new instance of the FontPropertiesManager class.
 
Method Summary
 void clearProperties()
          Clears any font references from the font managers internal cache.
 boolean getBoolean(java.lang.String propertyName, boolean defaultValue)
           
 boolean loadProperties()
          Loads the properties file and loads any font data that it contains.
 boolean readDefaulFontPaths(java.lang.String[] extraFontPaths)
          Sets the default font properties files by readying available system font paths.
 void readFontPaths(java.lang.String[] fontPaths)
          Reads the specified file paths and loads any found font fonts in the font Manager.
 void removeFontCacheFile()
          Removes the the properties file from the file system.
 void saveProperties()
          Touches the properties file, writing out any font properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FontPropertiesManager

public FontPropertiesManager(PropertiesManager appProps,
                             java.util.Properties sysProps,
                             java.util.ResourceBundle messageBundle)
Create a new instance of the FontPropertiesManager class. This constructor will automatically scan the system for the available fonts.

Typical usage would look like this:

Parameters:
appProps - properties manager reference
sysProps - system properties.
messageBundle - application message bundle.

FontPropertiesManager

public FontPropertiesManager(PropertiesManager appProps,
                             java.util.ResourceBundle messageBundle)
Create a new instance of the FontPropertiesManager class. This constructor will not scan the system for fonts. The users must call one of the following methods to scan for fonts; readFontPaths(java.lang.String[]) or readDefaulFontPaths(String[])

Typical usage would look like this:

Parameters:
appProps - properties manager reference
messageBundle - application message bundle.
Method Detail

removeFontCacheFile

public void removeFontCacheFile()
Removes the the properties file from the file system.


clearProperties

public void clearProperties()
Clears any font references from the font managers internal cache.


loadProperties

public boolean loadProperties()
Loads the properties file and loads any font data that it contains. If no font cache file is found then a new one is created and false is returned. If a file is found the properties in it are loaded and added to the fontManager class, true is returned.

Returns:
true if font file has been found and loaded, false otherwise.

readFontPaths

public void readFontPaths(java.lang.String[] fontPaths)
Reads the specified file paths and loads any found font fonts in the font Manager. In order to persist the results a call to saveProperties() needs to be called.

Parameters:
fontPaths - array of paths containing folders

saveProperties

public void saveProperties()
Touches the properties file, writing out any font properties.


readDefaulFontPaths

public boolean readDefaulFontPaths(java.lang.String[] extraFontPaths)
Sets the default font properties files by readying available system font paths.

Parameters:
extraFontPaths - extra font paths to load on top of the default paths.
Returns:
true if system font search returned without error, otherwise false.

getBoolean

public boolean getBoolean(java.lang.String propertyName,
                          boolean defaultValue)