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
-
CHILD
- Constant indicating that the new node is to be a child
of the existing node.
-
g1
- Offscreen graphics context used for buffering the painting process.
-
im1
- Offscreen image used for buffering the painting process.
-
isSun1_1
-
-
LAST
- Constant indicating that the new node is to be the last
sibling of the existing node.
-
NEXT
- Constant indicating that the new node is to be the next
sibling of the existing node.
-
SEL_CHANGED
- The type ID of the event posted when the selection has changed.
-
TreeView()
- Constructs an empty TreeView.
-
TreeView(TreeNode)
- Constructs a TreeView with the given node.
-
append(TreeNode)
- Adds a new node at root level.
-
drawTree()
- Draws the TreeView into an offscreen image.
-
exists(String)
- Determines if the node with the given text is in the TreeView.
-
exists(TreeNode)
- Determines if the given node is in the TreeView.
-
getBackground()
- Determines the current background color.
-
getBgHilite()
- Gets the current background color of the selection hilite.
-
getCount()
- Returns the total number of nodes in the tree.
-
getFgHilite()
- Gets the current foreground color of the selection hilite.
-
getForeground()
- Gets the current foreground color.
-
getRootNode()
- Returns the "root" node.
-
getSelectedNode()
- Gets the currently selected node.
-
getSelectedText()
- Gets the text of the currently selected node.
-
getTreeStructure()
- Gets a string array that reflects the current TreeView's contents.
-
getViewCount()
- Returns the total number of viewable nodes in the tree.
-
handleEvent(Event)
- Processes events for this component.
-
insert(TreeNode, TreeNode, int)
- Inserts a new node relative to an existing node in the tree.
-
keyDown(Event, int)
- Processes KEY_PRESS and KEY_ACTION events.
-
minimumSize()
- Returns the minimum dimensions to properly display this component.
-
mouseDown(Event, int, int)
- Processes MOUSE_DOWN events.
-
paint(Graphics)
- Paints this component using the given graphics context.
-
preferredSize()
- Returns the recommended dimensions to properly display this component.
-
printTree(TreeNode)
- Print out the text of each node in the TreeView beginning with
the given node.
-
redraw()
- Lays out the vertical and horizontal scrollbar as needed, then draws the TreeView into
an offscreen image.
-
remove(String)
- Removes the node with the given text from the TreeView.
-
remove(TreeNode)
- Removes the given node from the TreeView.
-
removeSelected()
- Removes the currently selected node from the TreeView.
-
setBackground(Color)
- Sets this component's background color.
-
setBgHilite(Color)
- Sets the background color of the selection hilite.
-
setFgHilite(Color)
- Sets the foreground color of the selection hilite.
-
setForeground(Color)
- Sets this component's foreground color.
-
setLayout(LayoutManager)
- Takes no action.
-
setTreeStructure(String[])
- Initializes the TreeView from a string array.
-
update(Graphics)
- Handles redrawing of this component on the screen.
CHILD
public final static int CHILD
- Constant indicating that the new node is to be a child
of the existing node.
- See Also:
- insert
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
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
SEL_CHANGED
public final static int SEL_CHANGED
- The type ID of the event posted when the selection has changed.
isSun1_1
protected boolean isSun1_1
im1
protected Image im1
- Offscreen image used for buffering the painting process.
g1
protected Graphics g1
- Offscreen graphics context used for buffering the painting process.
TreeView
public TreeView()
- Constructs an empty TreeView.
TreeView
public TreeView(TreeNode head)
- Constructs a TreeView with the given node.
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
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
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
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
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
getFgHilite
public Color getFgHilite()
- Gets the current foreground color of the selection hilite.
- Returns:
- the current foreground selection hilite color
- See Also:
- setFgHilite
setBgHilite
public void setBgHilite(Color c)
- Sets the background color of the selection hilite.
- See Also:
- getBgHilite
getBgHilite
public Color getBgHilite()
- Gets the current background color of the selection hilite.
- Returns:
- the current background selection hilite color
- See Also:
- setBgHilite
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
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
getCount
public int getCount()
- Returns the total number of nodes in the tree.
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.
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
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
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
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
removeSelected
public void removeSelected()
- Removes the currently selected node from the TreeView.
- See Also:
- remove, remove
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
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
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
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
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
getSelectedNode
public TreeNode getSelectedNode()
- Gets the currently selected node.
- Returns:
- the currently selected node, or null if none selected
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
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
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
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.
drawTree
public void drawTree()
- Draws the TreeView into an offscreen image. This is used for cleaner refresh.
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
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
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
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
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