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
-
fontHeight
-
-
items
-
-
MULTIPLE
-
-
selection
-
-
selectionPolicy
-
-
SINGLE
-
-
topItem
-
-
visibleItemCount
-
-
TreeBrowser()
-
-
TreeBrowser(Object, String, NodeHandler, Image)
- Builds a new browser instance
-
adjustmentValueChanged(AdjustmentEvent)
- Updates graphical appearance in response to a scroll.
-
collapse(TreeNode)
- contracts the representation of this node.
-
getNode(Object)
-
-
getParent(TreeNode)
- Returns parent node.
-
getSelectionPolicy()
- Gets the selection policy.
-
initialize(Object, String, NodeHandler, Image)
-
-
insert(TreeNode, Object, NodeHandler, String, Image)
- Inserts new node.
-
paint(Graphics)
- repaints the View.
-
remove(TreeNode)
- Removes a node.
-
removeBranch(TreeNode)
- Removes a node and its children
NOTE: if two threads are doing adds and removes,
this can lead to IndexOutOfBound exception.
-
select(TreeNode)
- Selects a node.
-
selection()
- return an Enumeraiton of selected items.
-
setSelectionPolicy(int)
- Sets the selection policy.
-
setVerticalScrollbar(Scrollbar)
- Sets 'a' as vertical Scrollbar.
-
unselect(TreeNode)
- Selects a node.
-
unselectAll()
- Unselects any selected item.
-
update(Graphics)
- Redraws the current context, using double buffering.
SINGLE
public static final int SINGLE
MULTIPLE
public static final int MULTIPLE
items
protected Vector items
selection
protected Vector selection
topItem
protected int topItem
visibleItemCount
protected int visibleItemCount
selectionPolicy
protected int selectionPolicy
fontHeight
protected int fontHeight
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
TreeBrowser
protected TreeBrowser()
initialize
protected void initialize(Object item,
String label,
NodeHandler handler,
Image icon)
update
public void update(Graphics pg)
- Redraws the current context, using double buffering.
- Overrides:
- update in class Component
paint
public void paint(Graphics g)
- repaints the View.
- Overrides:
- paint in class Canvas
insert
public void insert(TreeNode parent,
Object item,
NodeHandler handler,
String label,
Image icon)
- Inserts new node.
- Parameters:
- parent - the parent node.
remove
public void remove(TreeNode node)
- Removes a node.
This simply removes a node, without modifying its children if any. USE
WITH CAUTION.
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
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.
setSelectionPolicy
public void setSelectionPolicy(int policy)
- Sets the selection policy.
- Parameters:
- policy: - SINGLE or MULTIPLE
getSelectionPolicy
public int getSelectionPolicy()
- Gets the selection policy.
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()
unselect
public void unselect(TreeNode node)
- Selects a node.
Unselects the given node.
It is caller's responsibility to call repaint()
unselectAll
public void unselectAll()
- Unselects any selected item.
selection
public Enumeration selection()
- return an Enumeraiton of selected items.
setVerticalScrollbar
public void setVerticalScrollbar(Scrollbar a)
- Sets 'a' as vertical Scrollbar.
The Browser becomes an AdjustmentListener of this scrollbar.
adjustmentValueChanged
public void adjustmentValueChanged(AdjustmentEvent evt)
- Updates graphical appearance in response to a scroll.
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.
getNode
public TreeNode getNode(Object o)
All Packages Class Hierarchy This Package Previous Next Index