JHotDraw 7.5.1

org.jhotdraw.gui.fontchooser
Class DefaultFontChooserModel

java.lang.Object
  extended by org.jhotdraw.gui.fontchooser.AbstractFontChooserModel
      extended by 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 $

Nested Class Summary
static class DefaultFontChooserModel.UIResource
           
 
Field Summary
protected  javax.swing.tree.DefaultMutableTreeNode root
          Root node.
 
Fields inherited from class org.jhotdraw.gui.fontchooser.AbstractFontChooserModel
listenerList
 
Constructor Summary
DefaultFontChooserModel()
           
DefaultFontChooserModel(java.awt.Font[] fonts)
           
 
Method Summary
protected  java.util.ArrayList<FontFamilyNode> collectFamiliesNamed(java.util.ArrayList<FontFamilyNode> families, java.lang.String... names)
           
 java.lang.Object getChild(java.lang.Object parent, int index)
           
 int getChildCount(java.lang.Object parent)
           
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
           
 java.lang.Object getRoot()
           
 boolean isEditable(javax.swing.tree.MutableTreeNode node)
          Returns true if node is editable by the user.
 boolean isLeaf(java.lang.Object node)
           
 void setFonts(java.awt.Font[] fonts)
          Sets the fonts of the DefaultFontChooserModel.
 void valueForPathChanged(javax.swing.tree.TreePath path, java.lang.Object newValue)
           
 
Methods inherited from class org.jhotdraw.gui.fontchooser.AbstractFontChooserModel
addTreeModelListener, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, fireTreeStructureChanged, getListeners, getTreeModelListeners, removeTreeModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root

protected javax.swing.tree.DefaultMutableTreeNode root
Root node.

Constructor Detail

DefaultFontChooserModel

public DefaultFontChooserModel()

DefaultFontChooserModel

public DefaultFontChooserModel(java.awt.Font[] fonts)
Method Detail

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)

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.