org.ascape.util.vis
Class ERVDerivedFontMap

java.lang.Object
  extended by org.ascape.util.vis.ERVDerivedFontMap
All Implemented Interfaces:
java.io.Serializable

public class ERVDerivedFontMap
extends java.lang.Object
implements java.io.Serializable

Class DerivedFontMap is used to maintain instances of derived fonts. This minimizes calls to Font.deriveFont, which makes up a new Font each time it is called. This is particularly useful in highly dynamic environments (such as animation, or a place where objects and fonts are resized often). Any of the single-argument calls to Font.deriveFont are supported for storage and retrieval via getFont. Multi-argument calls to deriveFont are passed through the getFont call but are NOT stored. The user can make up some arbitrary key and store the key-Font pair in the map via the setFont() method. It is useful to note that the font size is roughly proportional to the pixel size, so if one needs a font to fit into an approximately 24 pixel high space, a good place to start experimenting is with with a Font returned by a call to a DerivedFontMap.getFont(24f). The results will of course vary quite a bit depending on the baseFont.

Since:
1.0
Version:
2.9
Author:
Roger Critchlow, Carl Tollander, Miles Parker, Matthew Hendrey, and others
See Also:
Serialized Form

Constructor Summary
ERVDerivedFontMap(java.awt.Font baseFont)
          Usually the baseFont has a size of 1, e.g.
 
Method Summary
 java.awt.Font getFont(java.awt.geom.AffineTransform transform)
          Return a new Font object by replicating the current Font object and applying a new transform to it.
 java.awt.Font getFont(float fontSize)
          Obtain a derived font, creating one if need be.
 java.awt.Font getFont(int style)
          Return a new Font object by replicating the current Font object and applying a new style to it.
 java.awt.Font getFont(java.util.Map attributes)
          Return a new Font object by replicating the current Font object and applying a new set of font attributes to it.
 java.awt.Font getFont(java.lang.Object key)
          Obtain a font stored by key.
 void setFont(java.lang.Object key, java.awt.Font font)
          Store a font (this should be a font derived from the base font) under a special key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERVDerivedFontMap

public ERVDerivedFontMap(java.awt.Font baseFont)
Usually the baseFont has a size of 1, e.g. new Font("Serif", Font.PLAIN, 1));

Parameters:
baseFont - parameter
Method Detail

getFont

public java.awt.Font getFont(float fontSize)
Obtain a derived font, creating one if need be. The argument is rounded to the nearest integer, then converted to a java.lang.Float which is used as the storage and retrieval key.

Parameters:
fontSize - parameter
Returns:
the font

getFont

public java.awt.Font getFont(java.awt.geom.AffineTransform transform)
Return a new Font object by replicating the current Font object and applying a new transform to it.

Parameters:
transform - parameter
Returns:
the font

getFont

public java.awt.Font getFont(int style)
Return a new Font object by replicating the current Font object and applying a new style to it.

Parameters:
style - parameter
Returns:
the font

getFont

public java.awt.Font getFont(java.util.Map attributes)
Return a new Font object by replicating the current Font object and applying a new set of font attributes to it.

Parameters:
attributes - parameter
Returns:
the font

getFont

public java.awt.Font getFont(java.lang.Object key)
Obtain a font stored by key. This is used in situations where a special key is needed, for example, when the programmer would otherwise be calling a multiple-argument call to Font.deriveFont() .

Parameters:
key - parameter
Returns:
the font

setFont

public void setFont(java.lang.Object key,
                    java.awt.Font font)
Store a font (this should be a font derived from the base font) under a special key.

Parameters:
key - the font
font - the font


Copyright © 1998-2008 The Brookings Institution, NuTech Solutions, Metascape, LLC All Rights Reserved.