net.sourceforge.nite.gui.textviewer
Class NTree

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTree
                  extended by net.sourceforge.nite.gui.textviewer.NTree
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.Scrollable, QueryResultHandler, TimeHandler

public class NTree
extends javax.swing.JTree
implements TimeHandler, QueryResultHandler

A simple extension of JTree that allows a data element to be associated with each tree node so that time highlighting and query highlighting can be achieved.

Author:
judyr, edited by jonathan
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTree
javax.swing.JTree.DynamicUtilTreeNode
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static int ADD
           
static int REMOVE
           
 
Fields inherited from class javax.swing.JTree
ANCHOR_SELECTION_PATH_PROPERTY, CELL_EDITOR_PROPERTY, CELL_RENDERER_PROPERTY, EDITABLE_PROPERTY, EXPANDS_SELECTED_PATHS_PROPERTY, INVOKES_STOP_CELL_EDITING_PROPERTY, LARGE_MODEL_PROPERTY, LEAD_SELECTION_PATH_PROPERTY, ROOT_VISIBLE_PROPERTY, ROW_HEIGHT_PROPERTY, SCROLLS_ON_EXPAND_PROPERTY, SELECTION_MODEL_PROPERTY, SHOWS_ROOT_HANDLES_PROPERTY, TOGGLE_CLICK_COUNT_PROPERTY, TREE_MODEL_PROPERTY, VISIBLE_ROW_COUNT_PROPERTY
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
NTree()
          Constructor for NTree.
NTree(NTreeNode nroot)
          Constructor for NTree.
 
Method Summary
 void acceptQueryResult(NOMElement result)
          accept a query result as an individual element
 void acceptQueryResults(java.util.List results)
          accept a query result as a list of NOMElements
 void acceptTimeChange(double systemTime)
          Causes the display components which correspond to the specified time to be highlighted This uses the TimeIntervalInterator provided by TimeIntervalMapper to find all the display components for the specified time.
 void acceptTimeSpanChange(double start, double end)
          Causes the display components which are in time scope between the specified start and end times to be highlighted NOT YET IMPLEMENTED
 void clearHighlights()
           
 Clock getClock()
          Return the Clock that is currently syncronising this TimeHandler
 java.util.Set getDataNodes(ObjectModelElement el)
           
 double getMaxTime()
          get the largest end time of any NTreeNode so far added to this NTree.
 java.util.Set getSelectedElements()
          Method getSelectedElements.
 java.util.List getSelectedElementsOrdered()
          Method getSelectedElementsOrdered.
 java.util.Set getSelectedTreeNodes()
           
 java.util.Set getSelectedTreeNodesOrdered()
           
 void insertDisplayElement(ObjectModelElement newElement, ObjectModelElement parent, int position)
          Find the tree nodes which represent the specified parent.
 void redisplayElement(ObjectModelElement e)
          Find the tree nodes which display this object model element and redraw them given the data in the specified element
 void reIndex()
          Clears up the nodes/data indices and remakes them
 void removeDisplayComponent(ObjectModelElement e)
          Find the nodes which represent this element and delete them (and their children) from the tree.
 void setClock(Clock c)
          Set the Clock to which this TimeHandler is registered
 void setHighlighted(ObjectModelElement el, java.awt.Color c)
          allow the user to add a highlight to an element
 void setQueryHighlightColor(java.awt.Color color)
          set the colour of the highlighting for queries
 void setRoot(NTreeNode nroot)
           
 void setSelected(ObjectModelElement el)
          allow the user to set the selected element
 void setTime(double time)
          Broadcast a new time.
 void setTimeHighlightColor(java.awt.Color color)
          Change the Color used for all registered TimeHandlers to highlight times
 void setTimeSpan(double start, double end)
          Broadcast a new span to all registered TimeHandlers.
 void setUpDataElements()
           
 void setUpDataElements(NTreeNode root)
           
 void setUpTimeMapper()
           
 void setUpTimeMapper(NTreeNode root)
          Initialises the TimeIntervalMapper data structure which maintains a mapping between display components and times.
 
Methods inherited from class javax.swing.JTree
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearSelection, collapsePath, collapseRow, convertValueToText, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, getAccessibleContext, getAnchorSelectionPath, getCellEditor, getCellRenderer, getClosestPathForLocation, getClosestRowForLocation, getDragEnabled, getEditingPath, getExpandedDescendants, getExpandsSelectedPaths, getInvokesStopCellEditing, getLastSelectedPathComponent, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getModel, getNextMatch, getPathBounds, getPathForLocation, getPathForRow, getPreferredScrollableViewportSize, getRowBounds, getRowCount, getRowForLocation, getRowForPath, getRowHeight, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollsOnExpand, getSelectionCount, getSelectionModel, getSelectionPath, getSelectionPaths, getSelectionRows, getShowsRootHandles, getToggleClickCount, getToolTipText, getTreeExpansionListeners, getTreeSelectionListeners, getTreeWillExpandListeners, getUI, getUIClassID, getVisibleRowCount, hasBeenExpanded, isCollapsed, isCollapsed, isEditable, isEditing, isExpanded, isExpanded, isFixedRowHeight, isLargeModel, isPathEditable, isPathSelected, isRootVisible, isRowSelected, isSelectionEmpty, isVisible, makeVisible, removeSelectionInterval, removeSelectionPath, removeSelectionPaths, removeSelectionRow, removeSelectionRows, removeTreeExpansionListener, removeTreeSelectionListener, removeTreeWillExpandListener, scrollPathToVisible, scrollRowToVisible, setAnchorSelectionPath, setCellEditor, setCellRenderer, setDragEnabled, setEditable, 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, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ADD

public static final int ADD
See Also:
Constant Field Values

REMOVE

public static final int REMOVE
See Also:
Constant Field Values
Constructor Detail

NTree

public NTree()
Constructor for NTree.


NTree

public NTree(NTreeNode nroot)
Constructor for NTree.

Parameters:
root -
Method Detail

setRoot

public void setRoot(NTreeNode nroot)

setUpTimeMapper

public void setUpTimeMapper(NTreeNode root)
Initialises the TimeIntervalMapper data structure which maintains a mapping between display components and times.


setUpTimeMapper

public void setUpTimeMapper()

setUpDataElements

public void setUpDataElements(NTreeNode root)

setUpDataElements

public void setUpDataElements()

acceptTimeChange

public void acceptTimeChange(double systemTime)
Causes the display components which correspond to the specified time to be highlighted This uses the TimeIntervalInterator provided by TimeIntervalMapper to find all the display components for the specified time. A record of the previous iterator is maintained so that it is possible to turn off the highlighting on components which are no longer in the time frame

Specified by:
acceptTimeChange in interface TimeHandler
See Also:
TimeHandler.acceptTimeChange(double)

setTimeHighlightColor

public void setTimeHighlightColor(java.awt.Color color)
Description copied from interface: TimeHandler
Change the Color used for all registered TimeHandlers to highlight times

Specified by:
setTimeHighlightColor in interface TimeHandler

setTime

public void setTime(double time)
Description copied from interface: TimeHandler
Broadcast a new time. Implement by sending a setSystemTime call to the current Clock.

Specified by:
setTime in interface TimeHandler
See Also:
TimeHandler.setTime(double)

acceptTimeSpanChange

public void acceptTimeSpanChange(double start,
                                 double end)
Causes the display components which are in time scope between the specified start and end times to be highlighted NOT YET IMPLEMENTED

Specified by:
acceptTimeSpanChange in interface TimeHandler

setTimeSpan

public void setTimeSpan(double start,
                        double end)
Description copied from interface: TimeHandler
Broadcast a new span to all registered TimeHandlers.

Specified by:
setTimeSpan in interface TimeHandler
See Also:
TimeHandler.setTimeSpan(double, double)

setClock

public void setClock(Clock c)
Description copied from interface: TimeHandler
Set the Clock to which this TimeHandler is registered

Specified by:
setClock in interface TimeHandler

getClock

public Clock getClock()
Description copied from interface: TimeHandler
Return the Clock that is currently syncronising this TimeHandler

Specified by:
getClock in interface TimeHandler
See Also:
TimeHandler.getClock()

setSelected

public void setSelected(ObjectModelElement el)
allow the user to set the selected element


clearHighlights

public void clearHighlights()

getDataNodes

public java.util.Set getDataNodes(ObjectModelElement el)

setHighlighted

public void setHighlighted(ObjectModelElement el,
                           java.awt.Color c)
allow the user to add a highlight to an element


getSelectedElements

public java.util.Set getSelectedElements()
Method getSelectedElements.

Returns:
Set

getSelectedElementsOrdered

public java.util.List getSelectedElementsOrdered()
Method getSelectedElementsOrdered.

Returns:
the list ordered in the way the connected nodes appear in the tree

getSelectedTreeNodes

public java.util.Set getSelectedTreeNodes()

getSelectedTreeNodesOrdered

public java.util.Set getSelectedTreeNodesOrdered()

redisplayElement

public void redisplayElement(ObjectModelElement e)
Find the tree nodes which display this object model element and redraw them given the data in the specified element


removeDisplayComponent

public void removeDisplayComponent(ObjectModelElement e)
Find the nodes which represent this element and delete them (and their children) from the tree.


insertDisplayElement

public void insertDisplayElement(ObjectModelElement newElement,
                                 ObjectModelElement parent,
                                 int position)
Find the tree nodes which represent the specified parent. Find which node represents the positionth child of them and add a new tree node to represent the specified node there


acceptQueryResults

public void acceptQueryResults(java.util.List results)
accept a query result as a list of NOMElements

Specified by:
acceptQueryResults in interface QueryResultHandler

acceptQueryResult

public void acceptQueryResult(NOMElement result)
accept a query result as an individual element

Specified by:
acceptQueryResult in interface QueryResultHandler

setQueryHighlightColor

public void setQueryHighlightColor(java.awt.Color color)
set the colour of the highlighting for queries

Specified by:
setQueryHighlightColor in interface QueryResultHandler

reIndex

public void reIndex()
Clears up the nodes/data indices and remakes them


getMaxTime

public double getMaxTime()
get the largest end time of any NTreeNode so far added to this NTree. Unimplemented - returns 0.0

Specified by:
getMaxTime in interface TimeHandler