prefuse.util
Class FontLib

java.lang.Object
  extended by prefuse.util.FontLib

public class FontLib
extends java.lang.Object

Library maintaining a cache of fonts and other useful font computation routines.

Author:
jeffrey heer

Constructor Summary
FontLib()
           
 
Method Summary
static void clearCache()
          Clear the Font object cache.
static int getCacheLookupCount()
          Get the number of cache lookups to the Font object cache.
static int getCacheMissCount()
          Get the number of cache misses to the Font object cache.
static java.awt.Font getFont(java.lang.String name, double size)
          Get a Font instance with the given font family name and size.
static java.awt.Font getFont(java.lang.String name, int style, double size)
          Get a Font instance with the given font family name, style, and size
static java.awt.Font getFont(java.lang.String name, int style, int size)
          Get a Font instance with the given font family name, style, and size
static java.awt.Font getIntermediateFont(java.awt.Font f1, java.awt.Font f2, double frac)
          Interpolate between two font instances.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FontLib

public FontLib()
Method Detail

getFont

public static java.awt.Font getFont(java.lang.String name,
                                    double size)
Get a Font instance with the given font family name and size. A plain font style is assumed.

Parameters:
name - the font name. Any font installed on your system should be valid. Common examples include "Arial", "Verdana", "Tahoma", "Times New Roman", "Georgia", and "Courier New".
size - the size, in points, of the font
Returns:
the requested Font instance

getFont

public static java.awt.Font getFont(java.lang.String name,
                                    int style,
                                    double size)
Get a Font instance with the given font family name, style, and size

Parameters:
name - the font name. Any font installed on your system should be valid. Common examples include "Arial", "Verdana", "Tahoma", "Times New Roman", "Georgia", and "Courier New".
style - the font style, such as bold or italics. This field uses the same style values as the Java Font class.
size - the size, in points, of the font
Returns:
the requested Font instance

getFont

public static java.awt.Font getFont(java.lang.String name,
                                    int style,
                                    int size)
Get a Font instance with the given font family name, style, and size

Parameters:
name - the font name. Any font installed on your system should be valid. Common examples include "Arial", "Verdana", "Tahoma", "Times New Roman", "Georgia", and "Courier New".
style - the font style, such as bold or italics. This field uses the same style values as the Java Font class.
size - the size, in points, of the font
Returns:
the requested Font instance

getCacheMissCount

public static int getCacheMissCount()
Get the number of cache misses to the Font object cache.

Returns:
the number of cache misses

getCacheLookupCount

public static int getCacheLookupCount()
Get the number of cache lookups to the Font object cache.

Returns:
the number of cache lookups

clearCache

public static void clearCache()
Clear the Font object cache.


getIntermediateFont

public static java.awt.Font getIntermediateFont(java.awt.Font f1,
                                                java.awt.Font f2,
                                                double frac)
Interpolate between two font instances. Font sizes are interpolated linearly. If the interpolation fraction is under 0.5, the face and style of the starting font are used, otherwise the face and style of the second font are applied.

Parameters:
f1 - the starting font
f2 - the target font
frac - a fraction between 0 and 1.0 controlling the interpolation amount.
Returns:
an interpolated Font instance


Copyright © 2007 Regents of the University of California