org.jhotdraw.gui.fontchooser
Class DefaultFontChooserModel
java.lang.Object
org.jhotdraw.gui.fontchooser.AbstractFontChooserModel
org.jhotdraw.gui.fontchooser.DefaultFontChooserModel
- All Implemented Interfaces:
- javax.swing.tree.TreeModel, FontChooserModel
- Direct Known Subclasses:
- DefaultFontChooserModel.UIResource
public class DefaultFontChooserModel
- extends AbstractFontChooserModel
DefaultFontChooserModel with a predefined set of font collections.
Loading the fonts may take a lot of time. Therefore it is recommended to
create a Future during the startup of an application, and set the fonts in
the font chooser model when they are needed.
Example:
private static FutureTask future = new FutureTask(new Callable() {
public Font[] call() throws Exception {
return GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
}
});
- Author:
- Werner Randelshofer
@version $Id: DefaultFontChooserModel.java 652 2010-05-27 13:19:16Z rawcoder $
Field Summary |
protected javax.swing.tree.DefaultMutableTreeNode |
root
Root node. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
root
protected javax.swing.tree.DefaultMutableTreeNode root
- Root node.
DefaultFontChooserModel
public DefaultFontChooserModel()
DefaultFontChooserModel
public DefaultFontChooserModel(java.awt.Font[] fonts)
setFonts
public void setFonts(java.awt.Font[] fonts)
- Sets the fonts of the DefaultFontChooserModel.
Fires treeStructureChanged event on the root node.
- Parameters:
fonts
-
collectFamiliesNamed
protected java.util.ArrayList<FontFamilyNode> collectFamiliesNamed(java.util.ArrayList<FontFamilyNode> families,
java.lang.String... names)
isEditable
public boolean isEditable(javax.swing.tree.MutableTreeNode node)
- Description copied from interface:
FontChooserModel
- Returns
true
if node
is editable by the user.
This method returns true, if the node and all its parents are editable.
- Parameters:
node
- a node in the tree, obtained from this data source
- Returns:
- true if
node
is editable
getRoot
public java.lang.Object getRoot()
getChild
public java.lang.Object getChild(java.lang.Object parent,
int index)
getChildCount
public int getChildCount(java.lang.Object parent)
isLeaf
public boolean isLeaf(java.lang.Object node)
valueForPathChanged
public void valueForPathChanged(javax.swing.tree.TreePath path,
java.lang.Object newValue)
getIndexOfChild
public int getIndexOfChild(java.lang.Object parent,
java.lang.Object child)