Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.flexstor.common.awt.tree
Class Tree  view Tree download Tree.java

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended bycom.flexstor.common.awt.tree.Tree
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.AdjustmentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.io.Serializable

public class Tree
extends java.awt.Panel
implements java.awt.event.KeyListener, java.awt.event.AdjustmentListener, java.awt.event.MouseListener

The ProtoView Tree control is designed to display and navigate through a hierarchical list of items. Items in the tree are referred to as nodes. The FlexTreeNode class which accompanies the Tree is used to refer to individual nodes of the tree.

Version:
3.0

Nested Class Summary
 
Nested classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  com.flexstor.common.awt.ActionMulticaster actionMulticaster
           
private  boolean bAllowPaint
           
private  java.awt.Color bkgndClr
           
private  boolean bLayoutInProgress
           
private  boolean bPaintInProgress
           
private  boolean bShowLines
           
protected  FlexTreeNode firstVisNode
           
static int HITTEST_BUTTON
          HitTest constant returned by getHitTestFlags when the x,y coordinates to the HitTest method were over a plus/minus button of a node.
static int HITTEST_IMAGE
          HitTest constant returned by getHitTestFlags when the x,y coordinates to the HitTest method were over the image area of a node.
static int HITTEST_MARGIN
          HitTest constant returned by getHitTestFlags when the x,y coordinates to the HitTest method were over the margin area of a node.
static int HITTEST_NONE
          HitTest constant returned by getHitTestFlags when the x,y coordinates to the HitTest method were not over a populated area of the tree.
static int HITTEST_TEXT
          HitTest constant returned by getHitTestFlags when the x,y coordinates to the HitTest method were over the text area of a node.
static int HITTEST_TEXT_RIGHT
          HitTest constant returned by getHitTestFlags when the x,y coordinates to the HitTest method were over the area to the right of the node text.
private  FlexTreeNode lastVisNode
           
private  java.awt.Scrollbar m_hscroll
           
protected  int m_iHScroll
           
protected  int m_iIndent
           
protected  int m_iLineHeight
           
protected  int m_iLinesPerPage
           
private  java.awt.Image m_im
           
private  int m_iMaxLineLen
           
protected  java.awt.Image m_imMinus
           
protected  java.awt.Image m_imPlus
           
private  int m_iVisCount
           
private  int m_iVScroll
           
private  java.awt.Scrollbar m_vscroll
           
private  int nHitTest
           
private  long nLastScrollTime
           
private  int nTreeId
           
private  java.awt.Panel pCorner
          Filler Panel to server as RightBottom corner of tree panel when both scrollbars are visible
private  FlexTreeNode rootNode
           
protected  TreeSelectionI selection
           
 
Fields inherited from class java.awt.Panel
 
Fields inherited from class java.awt.Container
 
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
Tree()
          Constuctor.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener l)
           
 void addRootNode(FlexTreeNode root)
          Add new node to level 0 It is a wrapper for addNode(null, FlexTreeNode.LAST_SIBLING, text, iImage, iSelImage)
 void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
          This method is called when an adjustable value changes.
 void checkFirstVisibleNode()
          Ensures that the first visible node does not have its removed flag set to true.
private  void doFullLayout()
           
 void drawSelectedBorder(java.awt.Graphics g, int l, int t, int w, int h)
           
 int ensureVisible(FlexTreeNode node)
          Make the specified node to be visible in the window.
private  void fireActionEvent(TreeActionEvent e)
           
 FlexTreeNode getCurrentNode()
           
 FlexTreeNode getFirstVisibleNode()
          Get the first visible node of the tree.
 boolean getLines()
          Get an option to display lines between nodes and images.
 java.awt.Dimension getPreferredSize()
          Return the preferred size of the Tree control.
 boolean getRedraw()
          Get an option to redraw tree on any modification of tree structure.
 FlexTreeNode getRootNode()
          Get the root node of the tree.
 int getSelectedCount()
           
 java.util.ArrayList getSelectedItems(boolean bSubItems)
           
protected  int getTreeId()
           
protected  FlexTreeNode getTrueRootNode()
           
 int getVisibleCount()
          Get the number of items that are expanded and visible when scrolling through tree.
 FlexTreeNode hitTest(int x, int y)
          Perform mouse position testing to determine where the mouse pointer is located with respect to the nodes in the tree.
 void invalidate()
          Invalidates this container to indicate that it (and all parent containers) need to be laid out.
 boolean isFocusTraversable()
          Tests whether or not this component is in the group that can be traversed using the keyboard traversal mechanism (such as the TAB key).
 boolean isNodeVisible(FlexTreeNode node)
          Return true if node is visible at the time.
 boolean isSelected(FlexTreeNode n)
           
 void keyPressed(java.awt.event.KeyEvent e)
          This method is called when a key is pressed.
 void keyReleased(java.awt.event.KeyEvent e)
          This method is called when a key is released.
 void keyTyped(java.awt.event.KeyEvent e)
          This method is called when a key is typed.
 void mouseClicked(java.awt.event.MouseEvent e)
          This method is called when the mouse is clicked (pressed and released in short succession) on a component.
 void mouseEntered(java.awt.event.MouseEvent e)
          This method is called when the mouse enters a component.
 void mouseExited(java.awt.event.MouseEvent e)
          This method is called when the mouse exits a component.
 void mousePressed(java.awt.event.MouseEvent e)
          This method is called when the mouse is pressed over a component.
 void mouseReleased(java.awt.event.MouseEvent e)
          This method is called when the mouse is released over a component.
private  int nodeWidth(FlexTreeNode node)
           
 void paint(java.awt.Graphics g)
          Paints this container.
private  void paintImage()
           
 void removeActionListener(java.awt.event.ActionListener l)
           
 void removeNotify()
          Called when this container is removed from its parent container to inform it to destroy its peer.
 void repaint(boolean bRecalculateLayout)
           
 void reset()
          Remove all nodes from the tree.
 void setBackgroundColor(java.awt.Color bkgnd)
           
 void setCurrentNode(FlexTreeNode n)
           
 void setFirstVisible(FlexTreeNode node)
          Set the first node that is visible at the top of the tree window to the specified node.
 void setLines(boolean enable)
          Set an option to display lines between nodes and images.
 void setMinusImage(java.awt.Image image)
          Set the image of the "minus" button.
 void setMultiSelection(boolean bState)
           
 void setPlusImage(java.awt.Image image)
          Set the image of the "plus" button.
 void setRedraw(boolean enable)
          Set an option to redraw tree on any modification of tree structure.
 void unselectAllNodes()
           
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HITTEST_NONE

public static final int HITTEST_NONE
HitTest constant returned by getHitTestFlags when the x,y coordinates to the HitTest method were not over a populated area of the tree.

See Also:
Constant Field Values

HITTEST_MARGIN

public static final int HITTEST_MARGIN
HitTest constant returned by getHitTestFlags when the x,y coordinates to the HitTest method were over the margin area of a node.

See Also:
Constant Field Values

HITTEST_BUTTON

public static final int HITTEST_BUTTON
HitTest constant returned by getHitTestFlags when the x,y coordinates to the HitTest method were over a plus/minus button of a node.

See Also:
Constant Field Values

HITTEST_IMAGE

public static final int HITTEST_IMAGE
HitTest constant returned by getHitTestFlags when the x,y coordinates to the HitTest method were over the image area of a node.

See Also:
Constant Field Values

HITTEST_TEXT

public static final int HITTEST_TEXT
HitTest constant returned by getHitTestFlags when the x,y coordinates to the HitTest method were over the text area of a node.

See Also:
Constant Field Values

HITTEST_TEXT_RIGHT

public static final int HITTEST_TEXT_RIGHT
HitTest constant returned by getHitTestFlags when the x,y coordinates to the HitTest method were over the area to the right of the node text.

See Also:
Constant Field Values

pCorner

private java.awt.Panel pCorner
Filler Panel to server as RightBottom corner of tree panel when both scrollbars are visible


m_vscroll

private java.awt.Scrollbar m_vscroll

m_hscroll

private java.awt.Scrollbar m_hscroll

selection

protected TreeSelectionI selection

actionMulticaster

protected com.flexstor.common.awt.ActionMulticaster actionMulticaster

m_imPlus

protected java.awt.Image m_imPlus

m_imMinus

protected java.awt.Image m_imMinus

m_im

private java.awt.Image m_im

rootNode

private FlexTreeNode rootNode

firstVisNode

protected FlexTreeNode firstVisNode

lastVisNode

private FlexTreeNode lastVisNode

nTreeId

private int nTreeId

m_iVisCount

private int m_iVisCount

m_iLinesPerPage

protected int m_iLinesPerPage

m_iHScroll

protected int m_iHScroll

m_iVScroll

private int m_iVScroll

m_iMaxLineLen

private int m_iMaxLineLen

nHitTest

private int nHitTest

m_iIndent

protected int m_iIndent

m_iLineHeight

protected int m_iLineHeight

nLastScrollTime

private long nLastScrollTime

bShowLines

private boolean bShowLines

bAllowPaint

private boolean bAllowPaint

bLayoutInProgress

private boolean bLayoutInProgress

bPaintInProgress

private boolean bPaintInProgress

bkgndClr

private java.awt.Color bkgndClr
Constructor Detail

Tree

public Tree()
Constuctor.

Method Detail

getTreeId

protected int getTreeId()

setBackgroundColor

public void setBackgroundColor(java.awt.Color bkgnd)

checkFirstVisibleNode

public void checkFirstVisibleNode()
Ensures that the first visible node does not have its removed flag set to true. This can happen when the first visible item in the tree is delted (Bug #6565)


removeNotify

public void removeNotify()
Description copied from class: java.awt.Container
Called when this container is removed from its parent container to inform it to destroy its peer. This causes the peers of all child component to be destroyed as well.


setMultiSelection

public void setMultiSelection(boolean bState)

getFirstVisibleNode

public FlexTreeNode getFirstVisibleNode()
Get the first visible node of the tree. This is the first node that is visible if the tree is scrolled all the way to the top. This method will return null if there are no nodes in the tree. Visible nodes are nodes which are at the root level, or child nodes whose anscestors are all expanded.


setFirstVisible

public void setFirstVisible(FlexTreeNode node)
Set the first node that is visible at the top of the tree window to the specified node. Here, visible is meant literally as the first line that the user can see at the top of the component.


getRootNode

public FlexTreeNode getRootNode()
Get the root node of the tree. There may be multiple nodes at the root level, in which case this method returns the first one. The method will return null if the tree is empty.


getTrueRootNode

protected FlexTreeNode getTrueRootNode()

isNodeVisible

public boolean isNodeVisible(FlexTreeNode node)
Return true if node is visible at the time.


ensureVisible

public int ensureVisible(FlexTreeNode node)
Make the specified node to be visible in the window.


hitTest

public FlexTreeNode hitTest(int x,
                            int y)
Perform mouse position testing to determine where the mouse pointer is located with respect to the nodes in the tree.


setLines

public void setLines(boolean enable)
Set an option to display lines between nodes and images.


getLines

public boolean getLines()
Get an option to display lines between nodes and images.


getRedraw

public boolean getRedraw()
Get an option to redraw tree on any modification of tree structure.


setRedraw

public void setRedraw(boolean enable)
Set an option to redraw tree on any modification of tree structure. This property can be used when performing a large number of insertions or deletions of nodes by setting this property to false.


getVisibleCount

public int getVisibleCount()
Get the number of items that are expanded and visible when scrolling through tree. It is not just the number of nodes visible on the screen at the current moment.


nodeWidth

private int nodeWidth(FlexTreeNode node)

setPlusImage

public void setPlusImage(java.awt.Image image)
Set the image of the "plus" button.


setMinusImage

public void setMinusImage(java.awt.Image image)
Set the image of the "minus" button.


addRootNode

public void addRootNode(FlexTreeNode root)
Add new node to level 0 It is a wrapper for addNode(null, FlexTreeNode.LAST_SIBLING, text, iImage, iSelImage)


reset

public void reset()
Remove all nodes from the tree.


getPreferredSize

public java.awt.Dimension getPreferredSize()
Return the preferred size of the Tree control. If size was never set, then returned value is new Dimension(200,250).


getSelectedItems

public java.util.ArrayList getSelectedItems(boolean bSubItems)

setCurrentNode

public void setCurrentNode(FlexTreeNode n)

getCurrentNode

public FlexTreeNode getCurrentNode()

unselectAllNodes

public void unselectAllNodes()

getSelectedCount

public int getSelectedCount()

isSelected

public boolean isSelected(FlexTreeNode n)

isFocusTraversable

public boolean isFocusTraversable()
Description copied from class: java.awt.Component
Tests whether or not this component is in the group that can be traversed using the keyboard traversal mechanism (such as the TAB key).


addActionListener

public void addActionListener(java.awt.event.ActionListener l)

removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)

fireActionEvent

private void fireActionEvent(TreeActionEvent e)

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Description copied from interface: java.awt.event.KeyListener
This method is called when a key is typed. A key is considered typed when it and all modifiers have been pressed and released, mapping to a single virtual key.

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Description copied from interface: java.awt.event.KeyListener
This method is called when a key is released.

Specified by:
keyReleased in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Description copied from interface: java.awt.event.KeyListener
This method is called when a key is pressed.

Specified by:
keyPressed in interface java.awt.event.KeyListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Description copied from interface: java.awt.event.MouseListener
This method is called when the mouse is clicked (pressed and released in short succession) on a component.

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Description copied from interface: java.awt.event.MouseListener
This method is called when the mouse is pressed over a component.

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Description copied from interface: java.awt.event.MouseListener
This method is called when the mouse is released over a component.

Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Description copied from interface: java.awt.event.MouseListener
This method is called when the mouse enters a component.

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Description copied from interface: java.awt.event.MouseListener
This method is called when the mouse exits a component.

Specified by:
mouseExited in interface java.awt.event.MouseListener

adjustmentValueChanged

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
Description copied from interface: java.awt.event.AdjustmentListener
This method is called when an adjustable value changes.

Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener

invalidate

public void invalidate()
Description copied from class: java.awt.Container
Invalidates this container to indicate that it (and all parent containers) need to be laid out.


repaint

public void repaint(boolean bRecalculateLayout)

doFullLayout

private void doFullLayout()

paint

public void paint(java.awt.Graphics g)
Description copied from class: java.awt.Container
Paints this container. The implementation of this method in this class forwards to any lightweight components in this container. If this method is subclassed, this method should still be invoked as a superclass method so that lightweight components are properly drawn.


paintImage

private void paintImage()

drawSelectedBorder

public void drawSelectedBorder(java.awt.Graphics g,
                               int l,
                               int t,
                               int w,
                               int h)