wt.clients.widgets
Class JIBATree

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JTree
                  extended bywt.clients.widgets.JIBATree
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Scrollable, Serializable

public class JIBATree
extends JTree

------------------------------------------------------------ This class extends JTree and provide some extended functionalities acrossing the IBA. It contains a hashtable which takes the ObjectID as the key and the DefaultMutableTreeNode as the object. It provides easier methods to find specific node. It also provides the choices of linear search and binary search for sorting the tree. The search will be done when the user add the node or update the node.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JTree
JTree.AccessibleJTree, JTree.DynamicUtilTreeNode, JTree.EmptySelectionModel, JTree.TreeModelHandler, JTree.TreeSelectionRedirector
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private  DefaultTreeModel defaultTreeModel
           
private  boolean multiRoot
           
private  Hashtable nodeTable
           
 
Fields inherited from class javax.swing.JTree
ANCHOR_SELECTION_PATH_PROPERTY, CELL_EDITOR_PROPERTY, CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, editable, EDITABLE_PROPERTY, EXPANDS_SELECTED_PATHS_PROPERTY, INVOKES_STOP_CELL_EDITING_PROPERTY, invokesStopCellEditing, LARGE_MODEL_PROPERTY, largeModel, LEAD_SELECTION_PATH_PROPERTY, ROOT_VISIBLE_PROPERTY, rootVisible, ROW_HEIGHT_PROPERTY, rowHeight, SCROLLS_ON_EXPAND_PROPERTY, scrollsOnExpand, SELECTION_MODEL_PROPERTY, selectionModel, selectionRedirector, SHOWS_ROOT_HANDLES_PROPERTY, showsRootHandles, TOGGLE_CLICK_COUNT_PROPERTY, toggleClickCount, TREE_MODEL_PROPERTY, treeModel, treeModelListener, VISIBLE_ROW_COUNT_PROPERTY, visibleRowCount
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
JIBATree(boolean multiRoot)
          Constructor to construct the tree.
 
Method Summary
 void addEntry(DefaultMutableTreeNode node)
          Add a new entry in the hashtable
private  int addInOrderBinarySearch(DefaultMutableTreeNode parent, DefaultMutableTreeNode node)
          Do a binary search on the children of the parent node and return the position which this node should add to.
 void addNode(DefaultMutableTreeNode parent, DefaultMutableTreeNode node)
          This method will add the node to the parent node.
 JToolTip createToolTip()
           
 void expandNode(DefaultMutableTreeNode node)
          Expand the tree node
 void expandNode(Object obj)
          Expand the tree node
 DefaultMutableTreeNode findNode(Object obj)
          Method to find a node from the user object using the hashtable
 DefaultMutableTreeNode findNode(String key)
          Method to find a node from the key (ObjectID) using the hashtable
 Enumeration getKeys()
          Return the Enumeration of keys of the hashtable
 DefaultMutableTreeNode getRoot()
          Return the root of the tree
 DefaultMutableTreeNode getSelectedNode()
          Get the selected node
 Vector getSelectedNodes()
          Get the selected nodes
 Object getSelectedObject()
          Get the selected User Object
 Vector getSelectedObjects()
          Get the selected User Objects
 String getToolTipText(MouseEvent evt)
           
 DefaultTreeModel getTreeModel()
          Method to return the DefaultTreeModel this tree is using
 Enumeration getValues()
          Return the enumeration of values of the hashtable
 void nodeStructureChanged(DefaultMutableTreeNode node)
          Call the nodeStructureChanged method from the DefaultTreeModel
 void removeAllChildren(DefaultMutableTreeNode node)
          This method will remove the node children from itself.
 boolean removeEntry(Object obj)
          Remove the entry in the hashtable
 void removeNode(DefaultMutableTreeNode parent, DefaultMutableTreeNode node)
          This method will remove the node from it's parent.
 void selectAndExpandNode(DefaultMutableTreeNode node)
          Select and expand the tree node
 void selectAndExpandNode(Object obj)
          Select and expand the tree node
 void selectNode(DefaultMutableTreeNode node)
          Select the tree node
 void selectNode(Object obj)
          Slect the tree node
 void setMultiSelection(boolean multi)
          Set the tree Selection as SINGLE or DISCONTIGUOUS
 void setRoot(DefaultMutableTreeNode root)
          Set the root of this tree to root
 void setTreeProperties()
          This method is for setting the multiroot tree properties.
 void updateNode(DefaultMutableTreeNode node, Object obj)
          This method will update the node with the new object.
 
Methods inherited from class javax.swing.JTree
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearSelection, clearToggledPaths, collapsePath, collapseRow, convertValueToText, createTreeModel, createTreeModelListener, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, fireValueChanged, getAccessibleContext, getAnchorSelectionPath, getCellEditor, getCellRenderer, getClosestPathForLocation, getClosestRowForLocation, getDefaultTreeModel, getDescendantToggledPaths, getDragEnabled, getEditingPath, getExpandedDescendants, getExpandsSelectedPaths, getInvokesStopCellEditing, getLastSelectedPathComponent, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getModel, getNextMatch, getPathBetweenRows, getPathBounds, getPathForLocation, getPathForRow, getPreferredScrollableViewportSize, getRowBounds, getRowCount, getRowForLocation, getRowForPath, getRowHeight, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollsOnExpand, getSelectionCount, getSelectionModel, getSelectionPath, getSelectionPaths, getSelectionRows, getShowsRootHandles, getToggleClickCount, getTreeExpansionListeners, getTreeSelectionListeners, getTreeWillExpandListeners, getUI, getUIClassID, getVisibleRowCount, hasBeenExpanded, isCollapsed, isCollapsed, isEditable, isEditing, isExpanded, isExpanded, isFixedRowHeight, isLargeModel, isPathEditable, isPathSelected, isRootVisible, isRowSelected, isSelectionEmpty, isVisible, makeVisible, paramString, removeDescendantSelectedPaths, removeDescendantToggledPaths, removeSelectionInterval, removeSelectionPath, removeSelectionPaths, removeSelectionRow, removeSelectionRows, removeTreeExpansionListener, removeTreeSelectionListener, removeTreeWillExpandListener, scrollPathToVisible, scrollRowToVisible, setAnchorSelectionPath, setCellEditor, setCellRenderer, setDragEnabled, setEditable, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setModel, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionModel, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, startEditingAtPath, stopEditing, treeDidChange, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

multiRoot

private boolean multiRoot

nodeTable

private Hashtable nodeTable

defaultTreeModel

private DefaultTreeModel defaultTreeModel
Constructor Detail

JIBATree

public JIBATree(boolean multiRoot)
Constructor to construct the tree.

Parameters:
multiRoot - indicate whether it's a multiroot or not
Method Detail

setTreeProperties

public void setTreeProperties()
This method is for setting the multiroot tree properties.


setMultiSelection

public void setMultiSelection(boolean multi)
Set the tree Selection as SINGLE or DISCONTIGUOUS

Parameters:
multi - boolean; false indiciate SINGLE.

getTreeModel

public DefaultTreeModel getTreeModel()
Method to return the DefaultTreeModel this tree is using

Returns:
DefaultTreeModel

getRoot

public DefaultMutableTreeNode getRoot()
Return the root of the tree

Returns:
root of the tree

setRoot

public void setRoot(DefaultMutableTreeNode root)
Set the root of this tree to root

Parameters:
root - the root to be set

getKeys

public Enumeration getKeys()
Return the Enumeration of keys of the hashtable

Returns:
enumeration of keys

getValues

public Enumeration getValues()
Return the enumeration of values of the hashtable

Returns:
enumeration of values

findNode

public DefaultMutableTreeNode findNode(String key)
Method to find a node from the key (ObjectID) using the hashtable

Returns:
DefaultMutableTreeNode associated with this key

findNode

public DefaultMutableTreeNode findNode(Object obj)
Method to find a node from the user object using the hashtable

Parameters:
obj - Object as the key
Returns:
DefaultMutableTreeNode associated with this key

addEntry

public void addEntry(DefaultMutableTreeNode node)
Add a new entry in the hashtable

Parameters:
node - New node to add to the hashtable

removeEntry

public boolean removeEntry(Object obj)
Remove the entry in the hashtable

Parameters:
obj - Object key which will be removed from the hashtable
Returns:
successfully remove the node or not

addNode

public void addNode(DefaultMutableTreeNode parent,
                    DefaultMutableTreeNode node)
This method will add the node to the parent node. It updates the hashtable.

Parameters:
parent - DefaultMutableTreeNode parent node

addInOrderBinarySearch

private int addInOrderBinarySearch(DefaultMutableTreeNode parent,
                                   DefaultMutableTreeNode node)
Do a binary search on the children of the parent node and return the position which this node should add to. THe comparsion is done by using the DefaultMutableTreeNode toString method.

Parameters:
parent - DefaultMutableTreeNode which the node will be added to.
Returns:
int index position where this node should be added to the parent

removeNode

public void removeNode(DefaultMutableTreeNode parent,
                       DefaultMutableTreeNode node)
This method will remove the node from it's parent. It also updates the hashtable. It also is a recursive method which will remove all the children in this branch.

Parameters:
parent - DefaultMutableTreeNode parent node

removeAllChildren

public void removeAllChildren(DefaultMutableTreeNode node)
This method will remove the node children from itself. It also updates the hashtable. It also is a recursive method which will remove all the children in this branch.


updateNode

public void updateNode(DefaultMutableTreeNode node,
                       Object obj)
This method will update the node with the new object.

Parameters:
node - DefaultMutableTreeNode to be updated
obj - Object that will be put into the node

nodeStructureChanged

public void nodeStructureChanged(DefaultMutableTreeNode node)
Call the nodeStructureChanged method from the DefaultTreeModel


getSelectedNode

public DefaultMutableTreeNode getSelectedNode()
Get the selected node

Returns:
DefaultMutableTreeNode which has been selected

getSelectedObject

public Object getSelectedObject()
Get the selected User Object

Returns:
Object of the selected node

getSelectedNodes

public Vector getSelectedNodes()
Get the selected nodes

Returns:
Vector containing the DefaultMutableTreeNode

getSelectedObjects

public Vector getSelectedObjects()
Get the selected User Objects

Returns:
Vector containing the user objects

selectNode

public void selectNode(DefaultMutableTreeNode node)
Select the tree node

Parameters:
node - node to be selected

selectNode

public void selectNode(Object obj)
Slect the tree node

Parameters:
obj - object that the selected node will contain

expandNode

public void expandNode(DefaultMutableTreeNode node)
Expand the tree node

Parameters:
node - node to be expanded

expandNode

public void expandNode(Object obj)
Expand the tree node

Parameters:
obj - object that the expanded node will contain

selectAndExpandNode

public void selectAndExpandNode(DefaultMutableTreeNode node)
Select and expand the tree node

Parameters:
node - node to be selected and expanded

selectAndExpandNode

public void selectAndExpandNode(Object obj)
Select and expand the tree node

Parameters:
obj - object that the selected and expanded node will contain

getToolTipText

public String getToolTipText(MouseEvent evt)

createToolTip

public JToolTip createToolTip()