|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Canvas org.w3c.tools.widgets.TreeBrowser
public class TreeBrowser
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 its 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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.Canvas |
---|
java.awt.Canvas.AccessibleAWTCanvas |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected int |
fontHeight
|
protected java.util.Vector |
items
|
static int |
MULTIPLE
The policy that enables a multiple selection of nodes. |
static int |
SCROLLBARS_ALWAYS
Specifies that the horizontal/vertical scrollbars should always be shown regardless of the respective sizes of the TreeBrowser. |
static int |
SCROLLBARS_ASNEEDED
Specifies that horizontal/vertical scrollbars should be shown only when the size of the nodes exceeds the size of the TreeBrowser in the horizontal/vertical dimension. |
protected java.util.Vector |
selection
|
protected int |
selectionPolicy
|
static int |
SINGLE
This policy that lets just one node selected at the same time. |
protected int |
topItem
|
protected int |
visibleItemCount
|
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
protected |
TreeBrowser()
|
|
TreeBrowser(java.lang.Object root,
java.lang.String label,
NodeHandler handler,
java.awt.Image icon)
Builds a new browser instance |
Method Summary | |
---|---|
void |
adjustmentValueChanged(java.awt.event.AdjustmentEvent evt)
Updates graphical appearance in response to a scroll. |
void |
collapse(TreeNode item)
Contracts the representation of the specified node. |
TreeNode |
getNode(java.lang.Object obj)
Gets the node associated to the specified object, or null if any. |
TreeNode |
getParent(TreeNode child)
Returns the parent node of the specified node. |
java.awt.Dimension |
getPreferredSize()
|
int |
getSelectionPolicy()
Gets the selection policy. |
protected void |
initialize(java.lang.Object item,
java.lang.String label,
NodeHandler handler,
java.awt.Image icon)
|
void |
insert(TreeNode parent,
java.lang.Object item,
NodeHandler handler,
java.lang.String label,
java.awt.Image icon)
Inserts new node. |
protected TreeNode |
itemAt(int y)
this should be private. |
void |
paint(java.awt.Graphics g)
repaints the View. |
void |
remove(TreeNode node)
Removes the specified node. |
void |
removeBranch(TreeNode node)
Removes the specified node and its children. |
void |
select(TreeNode node)
Selects the specified node. |
java.util.Enumeration |
selection()
Returns an Enumeraiton of selected items. |
void |
setHorizontalScrollbar(java.awt.Scrollbar a)
Sets 'a' as horizontal Scrollbar. |
void |
setScrollbarDisplayPolicy(int scrollbarDisplayPolicy)
Sets the scrollbars display policy to the specified policy. |
void |
setSelectionBackgroudColor(java.awt.Color color)
Sets the background color of a selected node to the specified color. |
void |
setSelectionFontColor(java.awt.Color color)
Sets the color of a selected node to the specified color. |
void |
setSelectionPolicy(int policy)
Sets the selection policy. |
void |
setVerticalScrollbar(java.awt.Scrollbar a)
Sets 'a' as vertical Scrollbar. |
void |
unselect(TreeNode node)
Unselects the specified node. |
void |
unselectAll()
Unselects all selected items. |
void |
update(java.awt.Graphics pg)
|
Methods inherited from class java.awt.Canvas |
---|
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int SCROLLBARS_ALWAYS
public static final int SCROLLBARS_ASNEEDED
public static final int SINGLE
public static final int MULTIPLE
protected java.util.Vector items
protected java.util.Vector selection
protected int topItem
protected int visibleItemCount
protected int selectionPolicy
protected int fontHeight
Constructor Detail |
---|
public TreeBrowser(java.lang.Object root, java.lang.String label, NodeHandler handler, java.awt.Image icon)
root
- the root node for this hierarchylabel
- the label that should be displayed for this itemhandler
- the handler for this nodeicon
- the icon that must be displayed for this itemprotected TreeBrowser()
Method Detail |
---|
protected void initialize(java.lang.Object item, java.lang.String label, NodeHandler handler, java.awt.Image icon)
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class java.awt.Component
public void setSelectionFontColor(java.awt.Color color)
color
- the color used to paint a selected nodepublic void setSelectionBackgroudColor(java.awt.Color color)
color
- the color used to paint the background of a selected nodepublic void setScrollbarDisplayPolicy(int scrollbarDisplayPolicy)
scrollbarDisplayPolicy
- SCROLLBARS_NEVER | SCROLLBARS_ASNEEDED |
SCROLLBARS_ALWAYSpublic void paint(java.awt.Graphics g)
paint
in class java.awt.Canvas
protected TreeNode itemAt(int y)
public void update(java.awt.Graphics pg)
update
in class java.awt.Canvas
public void insert(TreeNode parent, java.lang.Object item, NodeHandler handler, java.lang.String label, java.awt.Image icon)
parent
- the parent node.public void remove(TreeNode node)
node
- the node to removepublic void removeBranch(TreeNode node)
node
- the node to removepublic void collapse(TreeNode item)
item
- the node to contractspublic void setSelectionPolicy(int policy)
policy:
- SINGLE or MULTIPLEpublic int getSelectionPolicy()
public void select(TreeNode node)
node
- the node to selectpublic void unselect(TreeNode node)
node
- the node to unselectpublic void unselectAll()
public java.util.Enumeration selection()
public void setVerticalScrollbar(java.awt.Scrollbar a)
public void setHorizontalScrollbar(java.awt.Scrollbar a)
public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt)
adjustmentValueChanged
in interface java.awt.event.AdjustmentListener
public TreeNode getParent(TreeNode child)
child
- the child node you want to get its parentpublic TreeNode getNode(java.lang.Object obj)
obj
- the object related to a node
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |