|
Eclipse Platform Release 3.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.jface.resource.ResourceRegistry
org.eclipse.jface.resource.FontRegistry
A font registry maintains a mapping between symbolic font names and SWT fonts.
A font registry owns all of the font objects registered with it, and automatically disposes of them when the SWT Display that creates the fonts is disposed. Because of this, clients do not need to (indeed, must not attempt to) dispose of font objects themselves.
A special constructor is provided for populating a font registry from a property files using the standard Java resource bundle mechanism.
Methods are provided for registering listeners that will be kept apprised of changes to list of registed fonts.
Clients may instantiate this class (it was not designed to be subclassed).
Since 3.0 this class extends ResourceRegistry.
Field Summary | |
protected Runnable | displayRunnable
Runnable that cleans up the manager on disposal of the display. |
Constructor Summary | |
FontRegistry()
Creates an empty font registry. | |
FontRegistry(Display display)
Creates an empty font registry. | |
FontRegistry(String location)
Load the FontRegistry using the ClassLoader from the PlatformUI plug-in | |
FontRegistry(String location,
ClassLoader loader)
Creates a font registry and initializes its content from a property file. |
Method Summary | |
FontData | bestData(FontData[] fonts,
Display display)
Deprecated. use bestDataArray in order to support Motif multiple entry fonts. |
FontData[] | bestDataArray(FontData[] fonts,
Display display)
Find the first valid fontData in the provided list. |
protected void | clearCaches()
Disposes all currently allocated resources. |
Font | defaultFont()
Returns the default font data. |
Font | get(String symbolicName)
Returns the font associated with the given symbolic font name. |
Font | getBold(String symbolicName)
Returns the bold font associated with the given symbolic font name. |
FontData[] | getFontData(String symbolicName)
Returns the font data associated with the given symbolic font name. |
Font | getItalic(String symbolicName)
Returns the italic font associated with the given symbolic font name. |
Set | getKeySet()
|
boolean | hasValueFor(String fontKey)
Return whether or not the receiver has a value for the supplied key. |
void | put(String symbolicName,
FontData[] fontData)
Adds (or replaces) a font to this font registry under the given symbolic name. |
Methods inherited from class org.eclipse.jface.resource.ResourceRegistry |
addListener, fireMappingChanged, removeListener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Runnable displayRunnable
Constructor Detail |
public FontRegistry()
There must be an SWT Display created in the current thread before calling this method.
public FontRegistry(String location, ClassLoader loader) throws MissingResourceException
There must be an SWT Display created in the current thread before calling this method.
The OS name (retrieved using System.getProperty("os.name")) is converted to lowercase, purged of whitespace, and appended as suffix (separated by an underscore '_') to the given location string to yield the base name of a resource bundle acceptable to ResourceBundle.getBundle. The standard Java resource bundle mechanism is then used to locate and open the appropriate properties file, taking into account locale specific variations.
For example, on the Windows 2000 operating system the location string "com.example.myapp.Fonts" yields the base name "com.example.myapp.Fonts_windows2000". For the US English locale, this further elaborates to the resource bundle name "com.example.myapp.Fonts_windows2000_en_us".
If no appropriate OS-specific resource bundle is found, the process is repeated using the location as the base bundle name.
The property file contains entries that look like this:
textfont.0=MS Sans Serif-regular-10 textfont.1=Times New Roman-regular-10 titlefont.0=MS Sans Serif-regular-12 titlefont.1=Times New Roman-regular-12Each entry maps a symbolic font names (the font registry keys) with a ".
FontRegistry registry = new FontRegistry("com.example.myapp.fonts"); Font font = registry.get("textfont"); control.setFont(font); ...
public FontRegistry(String location) throws MissingResourceException
public FontRegistry(Display display)
Method Detail |
public FontData bestData(FontData[] fonts, Display display)
public FontData[] bestDataArray(FontData[] fonts, Display display)
public Font defaultFont()
public FontData[] getFontData(String symbolicName)
public Font get(String symbolicName)
public Font getBold(String symbolicName)
public Font getItalic(String symbolicName)
public Set getKeySet()
public boolean hasValueFor(String fontKey)
protected void clearCaches()
public void put(String symbolicName, FontData[] fontData)
A property change event is reported whenever the mapping from a symbolic name to a font changes. The source of the event is this registry; the property name is the symbolic font name.
|
Eclipse Platform Release 3.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.