All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class symantec.itools.awt.TreeView

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

public class TreeView
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 TreeNode object is used for each heading.

See Also:
TreeNode

Variable Index

 o CHILD
Constant indicating that the new node is to be a child of the existing node.
 o g1
Offscreen graphics context used for buffering the painting process.
 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 SEL_CHANGED
The type ID of the event posted when the selection has changed.

Constructor Index

 o TreeView()
Constructs an empty TreeView.
 o TreeView(TreeNode)
Constructs a TreeView with the given node.

Method Index

 o append(TreeNode)
Adds a new node at root level.
 o drawTree()
Draws the TreeView into an offscreen image.
 o exists(String)
Determines if the node with the given text is in the TreeView.
 o exists(TreeNode)
Determines if the given node is in the TreeView.
 o getBackground()
Determines the current background color.
 o getBgHilite()
Gets the current background color of the selection hilite.
 o getCount()
Returns the total number of nodes in the tree.
 o getFgHilite()
Gets the current foreground color of the selection hilite.
 o getForeground()
Gets the current foreground color.
 o getRootNode()
Returns the "root" node.
 o getSelectedNode()
Gets the currently selected node.
 o getSelectedText()
Gets the text of the currently selected node.
 o getTreeStructure()
Gets a string array that reflects the current TreeView's contents.
 o getViewCount()
Returns the total number of viewable nodes in the tree.
 o handleEvent(Event)
Processes events for this component.
 o insert(TreeNode, TreeNode, 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(TreeNode)
Print out the text of each node in the TreeView beginning with the given node.
 o redraw()
Lays out the vertical and horizontal scrollbar as needed, then draws the TreeView into an offscreen image.
 o remove(String)
Removes the node with the given text from the TreeView.
 o remove(TreeNode)
Removes the given node from the TreeView.
 o removeSelected()
Removes the currently selected node from the TreeView.
 o setBackground(Color)
Sets this component's background color.
 o setBgHilite(Color)
Sets the background color of the selection hilite.
 o setFgHilite(Color)
Sets the foreground color of the selection hilite.
 o setForeground(Color)
Sets this component's foreground color.
 o setLayout(LayoutManager)
Takes no action.
 o setTreeStructure(String[])
Initializes the TreeView from a string array.
 o update(Graphics)
Handles redrawing of this component on the screen.

Variables

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

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

See Also:
insert
 o LAST
  public final static 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 final static int SEL_CHANGED
The type ID of the event posted when the selection has changed.

 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.

Constructors

 o TreeView
  public TreeView()
Constructs an empty TreeView.

 o TreeView
  public TreeView(TreeNode head)
Constructs a TreeView with the given node.

Methods

 o setBackground
  public void setBackground(Color c)
Sets this component's background color. This is a standard Java AWT method which gets called to change the background color of this component.

Parameters:
c - the new background color
Overrides:
setBackground in class Component
See Also:
getBackground, setForeground
 o getBackground
  public Color getBackground()
Determines the current background color. This is a standard Java AWT method which gets called to determine the current background color for this component. If the background color hasn't been explicity specified using the setBackground() method, the background color of this component's parent is returned.

Returns:
the current background color
Overrides:
getBackground in class Component
See Also:
setBackground, getForeground
 o setForeground
  public void setForeground(Color c)
Sets this component's foreground color. This is a standard Java AWT method which gets called to change the foreground color of this component.

Parameters:
c - the new foreground color
Overrides:
setForeground in class Component
See Also:
getForeground, setBackground
 o getForeground
  public Color getForeground()
Gets the current foreground color. This is a standard Java AWT method which gets called to determine the current foreground color for this component. If the foreground color has not been explicitly set using the setForeground() method, the foreground color of of this component's parent is returned.

Returns:
the current foreground color
Overrides:
getForeground in class Component
See Also:
setForeground, getBackground
 o setFgHilite
  public void setFgHilite(Color c)
Sets the foreground color of the selection hilite.

Parameters:
c - the new foreground selection hilite color
See Also:
getFgHilite
 o getFgHilite
  public Color getFgHilite()
Gets the current foreground color of the selection hilite.

Returns:
the current foreground selection hilite color
See Also:
setFgHilite
 o setBgHilite
  public void setBgHilite(Color c)
Sets the background color of the selection hilite.

See Also:
getBgHilite
 o getBgHilite
  public Color getBgHilite()
Gets the current background color of the selection hilite.

Returns:
the current background selection hilite color
See Also:
setBgHilite
 o insert
  public void insert(TreeNode newNode,
                     TreeNode 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 TreeNode 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(TreeNode node)
Determines if the given node is in the TreeView.

Parameters:
node - the node to check
Returns:
true if the node is in the TreeView, 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 TreeView.

Parameters:
s - the node text to find
Returns:
true if the node is in the TreeView, false if it is not
See Also:
exists
 o append
  public void append(TreeNode 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 TreeNode remove(String s)
Removes the node with the given text from the TreeView.

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

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

Parameters:
node - the node to remove
Returns:
the TreeNode removed from this TreeView or null if not found
See Also:
remove, removeSelected
 o printTree
  public void printTree(TreeNode node)
Print out the text of each node in the TreeView 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 boolean handleEvent(Event e)
Processes events for this component. This is a standard Java AWT method which gets called by the AWT to handle this component's events. The default handler for components dispatches to one of the following methods as needed: action(), gotFocus(), lostFocus(), keyDown(), keyUp(), mouseEnter(), mouseExit(), mouseMove(), mouseDrag(), mouseDown(), or mouseUp().

Parameters:
event - the event to handle
Returns:
true if the event was handled and no further action is needed, false to pass the event to this component's parent
Overrides:
handleEvent in class Component
See Also:
action, gotFocus, lostFocus, keyDown, keyUp, mouseEnter, mouseExit, mouseMove, mouseDrag, mouseDown, mouseUp
 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 getSelectedNode
  public TreeNode 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 update
  public 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 unnecessary clearing of the background.

Parameters:
g - the graphics context
Overrides:
update in class Component
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 and horizontal scrollbar as needed, then draws the TreeView into an offscreen image. This is used for cleaner refresh.

 o drawTree
  public void drawTree()
Draws the TreeView into an offscreen image. This is used for cleaner refresh.

 o setTreeStructure
  public void setTreeStructure(String s[])
Initializes the TreeView 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 TreeView'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 TreeView's contents
See Also:
setTreeStructure
 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

All Packages  Class Hierarchy  This Package  Previous  Next  Index