All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.tools.widgets.TreeBrowser

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----w3c.tools.widgets.TreeBrowser

public class TreeBrowser
extends Canvas
implements AdjustmentListener
The TreeBrowser class. This class is a generic framework to browser any hierachical structure. Genericity is obtained through the use of 'handlers': the TreeBrowser itself does not perform any action in response to user events, but simply forward them as notifications to handlers. Each item inserted may have ots own handler, but handlers may also (this is the most common case) be shared between handlers. Any item added in the Tree is displayed with an icon and a label. When a handler receive a notification on a node, it may change this node, to modify or update its appearance.

See Also:
DirectoryBrowser, TreeNode

Variable Index

 o fontHeight
 o items
 o MULTIPLE
 o selection
 o selectionPolicy
 o SINGLE
 o topItem
 o visibleItemCount

Constructor Index

 o TreeBrowser()
 o TreeBrowser(Object, String, NodeHandler, Image)
Builds a new browser instance

Method Index

 o adjustmentValueChanged(AdjustmentEvent)
Updates graphical appearance in response to a scroll.
 o collapse(TreeNode)
contracts the representation of this node.
 o getNode(Object)
 o getParent(TreeNode)
Returns parent node.
 o getSelectionPolicy()
Gets the selection policy.
 o initialize(Object, String, NodeHandler, Image)
 o insert(TreeNode, Object, NodeHandler, String, Image)
Inserts new node.
 o paint(Graphics)
repaints the View.
 o remove(TreeNode)
Removes a node.
 o removeBranch(TreeNode)
Removes a node and its children NOTE: if two threads are doing adds and removes, this can lead to IndexOutOfBound exception.
 o select(TreeNode)
Selects a node.
 o selection()
return an Enumeraiton of selected items.
 o setSelectionPolicy(int)
Sets the selection policy.
 o setVerticalScrollbar(Scrollbar)
Sets 'a' as vertical Scrollbar.
 o unselect(TreeNode)
Selects a node.
 o unselectAll()
Unselects any selected item.
 o update(Graphics)
Redraws the current context, using double buffering.

Variables

 o SINGLE
 public static final int SINGLE
 o MULTIPLE
 public static final int MULTIPLE
 o items
 protected Vector items
 o selection
 protected Vector selection
 o topItem
 protected int topItem
 o visibleItemCount
 protected int visibleItemCount
 o selectionPolicy
 protected int selectionPolicy
 o fontHeight
 protected int fontHeight

Constructors

 o TreeBrowser
 public TreeBrowser(Object root,
                    String label,
                    NodeHandler handler,
                    Image icon)
Builds a new browser instance

Parameters:
root - the root node for this hierarchy
label - the label that should be displayed for this item
handler - the handler for this node
icon - the icon that must be displayed for this item
 o TreeBrowser
 protected TreeBrowser()

Methods

 o initialize
 protected void initialize(Object item,
                           String label,
                           NodeHandler handler,
                           Image icon)
 o update
 public void update(Graphics pg)
Redraws the current context, using double buffering.

Overrides:
update in class Component
 o paint
 public void paint(Graphics g)
repaints the View.

Overrides:
paint in class Canvas
 o insert
 public void insert(TreeNode parent,
                    Object item,
                    NodeHandler handler,
                    String label,
                    Image icon)
Inserts new node.

Parameters:
parent - the parent node.
 o remove
 public void remove(TreeNode node)
Removes a node. This simply removes a node, without modifying its children if any. USE WITH CAUTION.

 o removeBranch
 public void removeBranch(TreeNode node)
Removes a node and its children NOTE: if two threads are doing adds and removes, this can lead to IndexOutOfBound exception. You will probably have to use locks to get rid of that problem

 o collapse
 public synchronized void collapse(TreeNode item)
contracts the representation of this node. removes all the children nodes of 'item'. It is caller's responsibility to call repaint() afterwards.

 o setSelectionPolicy
 public void setSelectionPolicy(int policy)
Sets the selection policy.

Parameters:
policy: - SINGLE or MULTIPLE
 o getSelectionPolicy
 public int getSelectionPolicy()
Gets the selection policy.

 o select
 public void select(TreeNode node)
Selects a node. Selects the given node. If selectionPolicy is SINGLE any previously selected node is unselected first. It is caller's responsibility to call repaint()

 o unselect
 public void unselect(TreeNode node)
Selects a node. Unselects the given node. It is caller's responsibility to call repaint()

 o unselectAll
 public void unselectAll()
Unselects any selected item.

 o selection
 public Enumeration selection()
return an Enumeraiton of selected items.

 o setVerticalScrollbar
 public void setVerticalScrollbar(Scrollbar a)
Sets 'a' as vertical Scrollbar. The Browser becomes an AdjustmentListener of this scrollbar.

 o adjustmentValueChanged
 public void adjustmentValueChanged(AdjustmentEvent evt)
Updates graphical appearance in response to a scroll.

 o getParent
 public TreeNode getParent(TreeNode child)
Returns parent node. If 'child' is a valid node belonging to the Tree and has a parent node, returns its parent. Returns null otherwise.

 o getNode
 public TreeNode getNode(Object o)

All Packages  Class Hierarchy  This Package  Previous  Next  Index