Class FontCache
java.lang.Object
org.graphstream.ui.swing_viewer.util.FontCache
public class FontCache
extends java.lang.Object
A cache for fonts.
This cache allows to avoid reloading fonts and allows to quickly lookup a font based on its name, its style (bold, italic) and its size.
-
Field Summary
Fields Modifier and Type Field Description static FontCache
defaultFontCache
The default font cache. -
Constructor Summary
Constructors Constructor Description FontCache()
New empty font cache. -
Method Summary
Modifier and Type Method Description static FontCache
defaultFontCache()
Default singleton instance for shared font cache.java.awt.Font
getDefaultFont()
The default font.java.awt.Font
getDefaultFont(org.graphstream.ui.graphicGraph.stylesheet.StyleConstants.TextStyle style, int size)
java.awt.Font
getFont(java.lang.String name, org.graphstream.ui.graphicGraph.stylesheet.StyleConstants.TextStyle style, int size)
Lookup a font, and if not found, try to load it, if still not available, return the default font.
-
Field Details
-
defaultFontCache
The default font cache.
-
-
Constructor Details
-
FontCache
public FontCache()New empty font cache.
-
-
Method Details
-
getDefaultFont
public java.awt.Font getDefaultFont()The default font.- Returns:
- A font.
-
defaultFontCache
Default singleton instance for shared font cache. This method and cache can only be used in the Swing thread.- Returns:
- The default singleton font cache instance.
-
getDefaultFont
public java.awt.Font getDefaultFont(org.graphstream.ui.graphicGraph.stylesheet.StyleConstants.TextStyle style, int size) -
getFont
public java.awt.Font getFont(java.lang.String name, org.graphstream.ui.graphicGraph.stylesheet.StyleConstants.TextStyle style, int size)Lookup a font, and if not found, try to load it, if still not available, return the default font.- Parameters:
name
- The font name.style
- A style, taken from the styles available in the style sheets.size
- The font size in points.- Returns:
- A font.
-