All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class symantec.itools.awt.TreeView2

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----symantec.itools.awt.TreeView2

public class TreeView2
extends Panel
Creates an "outline view" of text headings and, optionally, images. The headings are arranged in a hierarchical fashion, and can be expanded to show their sub-headings or collapsed, hiding their sub-headings.

A TreeView is typically used to display information that is organized in a hierarchical fashion like an index or table of contents.

A TreeNode2 object is used for each heading.

See Also:
TreeNode2

Variable Index

 o CHILD
Constant indicating that the new node is to be a child of the existing node.
 o count
 o g1
Offscreen graphics context used for buffering the painting process.
 o hasFocus
 o horizontalScrollBar
 o im1
Offscreen Image used for buffering the painting process.
 o isSun1_1
 o LAST
Constant indicating that the new node is to be the last sibling of the existing node.
 o NEXT
Constant indicating that the new node is to be the next sibling of the existing node.
 o redrawTriggered
 o SEL_CHANGED
Deprecated.
 o treeChanged
 o verticalScrollBar
 o viewCount

Constructor Index

 o TreeView2()
Constructs an empty TreeView2.
 o TreeView2(TreeNode2)
Constructs a TreeView2 with the given node.

Method Index

 o append(TreeNode2)
Adds a new node at root level.
 o changeSelection(TreeNode2)
 o clear()
 o drawTree()
Draws the TreeView2 into an offscreen image.
 o exists(String)
Determines if the node with the given text is in the TreeView2.
 o exists(TreeNode2)
Determines if the given node is in the TreeView2.
 o focusLost(Event, Object)
 o getBgHilite()
Deprecated.
 o getCount()
Returns the total number of nodes in the tree.
 o getFgHilite()
Deprecated.
 o getRootNode()
Returns the "root" node.
 o getSelectedNode()
Gets the currently selected node.
 o getSelectedObjects()
Returns the selected items or null if no items are selected.
 o getSelectedText()
Gets the text of the currently selected node.
 o getTreeStructure()
Gets a string array that reflects the current TreeView2's contents.
 o getViewCount()
Returns the total number of viewable nodes in the tree.
 o gotFocus(Event, Object)
 o handleEvent(Event)
 o insert(TreeNode2, TreeNode2, int)
Inserts a new node relative to an existing node in the tree.
 o keyDown(Event, int)
Processes KEY_PRESS and KEY_ACTION events.
 o minimumSize()
Returns the minimum dimensions to properly display this component.
 o mouseDown(Event, int, int)
Processes MOUSE_DOWN events.
 o paint(Graphics)
Paints this component using the given graphics context.
 o preferredSize()
Returns the recommended dimensions to properly display this component.
 o printTree(TreeNode2)
Print out the text of each node in the TreeView2 beginning with the given node.
 o redraw()
Lays out the vertical scrollbar as needed, then draws the TreeView2 into an offscreen image.
 o redraw(Graphics)
 o remove(String)
Removes the node with the given text from the TreeView2.
 o remove(TreeNode2)
Removes the given node from the TreeView2.
 o removeSelected()
Removes the currently selected node from the TreeView2.
 o sendActionEvent()
 o setBgHilite(Color)
Deprecated.
 o setFgHilite(Color)
Deprecated.
 o setLayout(LayoutManager)
Takes no action.
 o setTreeStructure(String[])
Initializes the TreeView2 from a string array.
 o triggerRedraw()
 o update(Graphics)
Handles redrawing of this component on the screen.

Variables

 o CHILD
 public static final int CHILD
Constant indicating that the new node is to be a child of the existing node.

See Also:
insert
 o NEXT
 public static final int NEXT
Constant indicating that the new node is to be the next sibling of the existing node.

See Also:
insert
 o LAST
 public static final int LAST
Constant indicating that the new node is to be the last sibling of the existing node.

See Also:
insert
 o SEL_CHANGED
 public static final int SEL_CHANGED
Note: SEL_CHANGED is deprecated. As of JDK version 1.1, replaced by ItemSelectable interface.

See Also:
ItemSelectable
 o verticalScrollBar
 protected Scrollbar verticalScrollBar
 o count
 protected int count
 o viewCount
 protected int viewCount
 o horizontalScrollBar
 protected Scrollbar horizontalScrollBar
 o isSun1_1
 protected boolean isSun1_1
 o im1
 protected Image im1
Offscreen Image used for buffering the painting process.

 o g1
 protected Graphics g1
Offscreen graphics context used for buffering the painting process.

 o redrawTriggered
 protected boolean redrawTriggered
 o treeChanged
 protected boolean treeChanged
 o hasFocus
 protected boolean hasFocus

Constructors

 o TreeView2
 public TreeView2()
Constructs an empty TreeView2.

 o TreeView2
 public TreeView2(TreeNode2 head)
Constructs a TreeView2 with the given node.

Parameters:
head - the root node of the constructed tree

Methods

 o clear
 public synchronized void clear()
 o setTreeStructure
 public void setTreeStructure(String s[])
Initializes the TreeView2 from a string array. There is one string for each node in the array. That string contains the text of the node indented with same number of leading spaces as the depth of that node in the tree.

Parameters:
s - the string array used for initialization
See Also:
getTreeStructure
 o getTreeStructure
 public String[] getTreeStructure()
Gets a string array that reflects the current TreeView2's contents. There is one string for each node in the array. That string contains the text of the node indented with same number of leading spaces as the depth of that node in the tree.

Returns:
the string array that reflects the TreeView2's contents
See Also:
setTreeStructure
 o setFgHilite
 public void setFgHilite(Color c)
Note: setFgHilite() is deprecated. As of JDK version 1.1, replaced by use of SystemColors.textHighlightText.

 o getFgHilite
 public Color getFgHilite()
Note: getFgHilite() is deprecated. As of JDK version 1.1, replaced by use of SystemColors.textHighlightText.

 o setBgHilite
 public void setBgHilite(Color c)
Note: setBgHilite() is deprecated. As of JDK version 1.1, replaced by use of SystemColors.textHighlight.

 o getBgHilite
 public Color getBgHilite()
Note: getBgHilite() is deprecated. As of JDK version 1.1, replaced by use of SystemColors.textHighlight.

 o getSelectedObjects
 public Object[] getSelectedObjects()
Returns the selected items or null if no items are selected.

This is a standard method of the ItemSelectable interface.

 o insert
 public void insert(TreeNode2 newNode,
                    TreeNode2 relativeNode,
                    int position)
Inserts a new node relative to an existing node in the tree.

Parameters:
newNode - the new node to insert into the tree
relativeNode - the existing node used for a position reference
position - where to insert the new node relative to relativeNode. Legal values are CHILD, NEXT and LAST.
See Also:
CHILD, NEXT, LAST, append
 o getRootNode
 public TreeNode2 getRootNode()
Returns the "root" node. The root node is the first top-level node in the tree hierarchy. All other nodes are either children or siblings of that one.

Returns:
the root tree node
 o getCount
 public int getCount()
Returns the total number of nodes in the tree.

 o getViewCount
 public int getViewCount()
Returns the total number of viewable nodes in the tree. A node is viewable if all of its parents are expanded.

 o exists
 public boolean exists(TreeNode2 node)
Determines if the given node is in the TreeView2.

Parameters:
node - the node to check
Returns:
true if the node is in the TreeView2, false if it is not
See Also:
exists
 o exists
 public boolean exists(String s)
Determines if the node with the given text is in the TreeView2.

Parameters:
s - the node text to find
Returns:
true if the node is in the TreeView2, false if it is not
See Also:
exists
 o append
 public void append(TreeNode2 newNode)
Adds a new node at root level. If there is no root node, the given node is made the root node. If there is a root node, the given node is made a sibling of the root node.

Parameters:
newNode - the new node to add
See Also:
insert
 o remove
 public TreeNode2 remove(String s)
Removes the node with the given text from the TreeView2.

Parameters:
s - the node text to find
Returns:
the TreeNode2 removed from this TreeView2 or null if not found
See Also:
remove, removeSelected
 o removeSelected
 public void removeSelected()
Removes the currently selected node from the TreeView2.

See Also:
remove, remove
 o remove
 public void remove(TreeNode2 node)
Removes the given node from the TreeView2.

Parameters:
node - the node to remove
Returns:
the TreeNode2 removed from this TreeView2 or null if not found
See Also:
remove, removeSelected
 o printTree
 public void printTree(TreeNode2 node)
Print out the text of each node in the TreeView2 beginning with the given node. The nodes are printed out one per line with no indenting.

Parameters:
node - the first node to print
 o handleEvent
 public synchronized boolean handleEvent(Event event)
Overrides:
handleEvent in class Component
 o mouseDown
 public boolean mouseDown(Event event,
                          int x,
                          int y)
Processes MOUSE_DOWN events. This is a standard Java AWT method which gets called by the AWT method handleEvent() in response to receiving a MOUSE_DOWN event. These events occur when the mouse button is pressed while inside this component.

Parameters:
event - the event
x - the component-relative horizontal coordinate of the mouse
y - the component-relative vertical coordinate of the mouse
Returns:
true if the event was handled
Overrides:
mouseDown in class Component
See Also:
mouseUp, handleEvent
 o keyDown
 public boolean keyDown(Event event,
                        int key)
Processes KEY_PRESS and KEY_ACTION events. This is a standard Java AWT method which gets called by the AWT method handleEvent() in response to receiving a KEY_PRESS or KEY_ACTION event. These events occur when this component has the focus and the user presses a "normal" or an "action" (F1, page up, etc) key.

Parameters:
event - the Event
key - the key that was pressed
Returns:
true if the event was handled
Overrides:
keyDown in class Component
See Also:
keyUp, handleEvent
 o gotFocus
 public boolean gotFocus(Event e,
                         Object what)
Overrides:
gotFocus in class Component
 o focusLost
 public boolean focusLost(Event e,
                          Object what)
 o sendActionEvent
 protected void sendActionEvent()
 o getSelectedNode
 public TreeNode2 getSelectedNode()
Gets the currently selected node.

Returns:
the currently selected node, or null if none selected
 o getSelectedText
 public String getSelectedText()
Gets the text of the currently selected node.

Returns:
the text of the currently selected node or null if no node is selected
 o changeSelection
 protected void changeSelection(TreeNode2 node)
 o update
 public synchronized void update(Graphics g)
Handles redrawing of this component on the screen. This is a standard Java AWT method which gets called by the Java AWT (repaint()) to handle repainting this component on the screen. The graphics context clipping region is set to the bounding rectangle of this component and its [0,0] coordinate is this component's top-left corner. Typically this method paints the background color to clear the component's drawing space, sets graphics context to be the foreground color, and then calls paint() to draw the component. It is overridden here to reduce flicker by eliminating the uneeded clearing of the background.

Parameters:
g - the graphics context
Overrides:
update in class Container
See Also:
repaint, paint
 o paint
 public void paint(Graphics g)
Paints this component using the given graphics context. This is a standard Java AWT method which typically gets called by the AWT to handle painting this component. It paints this component using the given graphics context. The graphics context clipping region is set to the bounding rectangle of this component and its [0,0] coordinate is this component's top-left corner.

Parameters:
g - the graphics context used for painting
Overrides:
paint in class Container
See Also:
repaint, update
 o redraw
 public void redraw()
Lays out the vertical scrollbar as needed, then draws the TreeView2 into an offscreen image. This is used for cleaner refresh.

 o redraw
 public void redraw(Graphics g)
 o drawTree
 public void drawTree()
Draws the TreeView2 into an offscreen image. This is used for cleaner refresh.

 o preferredSize
 public synchronized Dimension preferredSize()
Returns the recommended dimensions to properly display this component. This is a standard Java AWT method which gets called to determine the recommended size of this component.

Overrides:
preferredSize in class Container
See Also:
minimumSize
 o minimumSize
 public synchronized Dimension minimumSize()
Returns the minimum dimensions to properly display this component. This is a standard Java AWT method which gets called to determine the minimum size of this component.

Overrides:
minimumSize in class Container
See Also:
preferredSize
 o setLayout
 public void setLayout(LayoutManager lm)
Takes no action. This is a standard Java AWT method which gets called to specify which layout manager should be used to layout the components in standard containers. Since layout managers CANNOT BE USED with this container the standard setLayout has been OVERRIDDEN for this container and does nothing.

Parameters:
lm - the layout manager to use to layout this container's components (IGNORED)
Overrides:
setLayout in class Container
See Also:
getLayout
 o triggerRedraw
 protected void triggerRedraw()

All Packages  Class Hierarchy  This Package  Previous  Next  Index