Jet.Concepts
Class ConceptHierarchy

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JTree
                  extended byJet.Concepts.ConceptHierarchy
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.dnd.DragGestureListener, java.awt.dnd.DragSourceListener, java.awt.dnd.DropTargetListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable

public class ConceptHierarchy
extends javax.swing.JTree
implements java.awt.dnd.DragGestureListener, java.awt.dnd.DragSourceListener, java.awt.dnd.DropTargetListener

A ConceptHierarchy is an extended JTree. It consists of Concepts and Words as its tree nodes. Besides the tree data structure, it also has four hashtables to store references to the data, making searching faster. These hashtables are only accessible from within the packet though. One doesn't need to know the roles of these hashtables in order to use the ConceptHierarchy.

ConceptHierarchy has a default root "UNIVERSE" which is invisible. User defined hierarchy either read from a file or entered from a ConceptHierarchyWindow is added to "UNIVERSE". Thus a ConceptHierarchy can be a forest with the underlined tree structure.

ConceptHierarchy should be called within a Component in order to have its error message shown properly. See the constructors.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JTree
javax.swing.JTree.AccessibleJTree, javax.swing.JTree.DynamicUtilTreeNode, javax.swing.JTree.EmptySelectionModel, javax.swing.JTree.TreeModelHandler, javax.swing.JTree.TreeSelectionRedirector
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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
 
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.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
ConceptHierarchy()
          Creates a ConceptHierarchy with only the default root UNIVERSE.
ConceptHierarchy(java.io.File file)
          Creates a ConceptHierarchy from the file fileName.
 
Method Summary
 boolean addConcept(Concept newConcept, Concept parent)
          Adds a new Concept to this ConceptHierarchy as a child of the node parent.
 boolean addWord(Word newWord, Concept parent)
          Adds a new Word to this ConceptHierarchy as a child of the node parent.
All the Words of Concept parent are listed before all the Concepts that isa parent.
 void clear()
          Removes all the nodes from the hierarchy except the default root UNIVERSE.
 void dragDropEnd(java.awt.dnd.DragSourceDropEvent dsde)
          Method of DragSourceListener interface
 void dragEnter(java.awt.dnd.DragSourceDragEvent dsde)
          Method of DragSourceListener interface
 void dragEnter(java.awt.dnd.DropTargetDragEvent e)
          Method of DropTaregetListener interface
 void dragExit(java.awt.dnd.DragSourceEvent dsde)
          Method of DragSourceListener interface
 void dragExit(java.awt.dnd.DropTargetEvent e)
          Method of DropTaregetListener interface
 void dragGestureRecognized(java.awt.dnd.DragGestureEvent dge)
          Method of DragGestureListener interface
 void dragOver(java.awt.dnd.DragSourceDragEvent dsde)
          Method of DragSourceListener interface
 void dragOver(java.awt.dnd.DropTargetDragEvent e)
          Method of DropTaregetListener interface
 void drop(java.awt.dnd.DropTargetDropEvent e)
          Method of DropTargetListener interface
 void dropActionChanged(java.awt.dnd.DragSourceDragEvent dsde)
          Method of DragSourceListener interface
 void dropActionChanged(java.awt.dnd.DropTargetDragEvent e)
          Method of DropTaregetListener interface
 Concept getConceptByName(java.lang.String conceptName)
          Returns the Concept named conceptName or null if no Concept has conceptName.
 Concept getConceptByNameIgnoreCase(java.lang.String conceptName)
          Returns the Concept named conceptName (ignoring case) or null if no Concept has conceptName.
 Concept getConceptFor(java.lang.String word)
          Returns the Concept of the word word or null if no Concept has word.
 Word getWordByName(java.lang.String wordName)
          Returns the Word named wordName or null if no Word has wordName.
 Word getWordByNameIgnoreCase(java.lang.String wordName)
          Returns the Word named wordName (ignoring case) or null if no Word has wordName.
static boolean isa(Concept concept1, Concept concept2)
          Returns true if concept1 isa concept2, i.e. concept2 is the parent of concept1 in the concept hierarchy.
static boolean isaStar(Concept concept1, Concept concept2)
          Returns true if concept1 isa* concept2, i.e. concept2 is concept1 itself or an ancestor of concept1 in the concept hierarchy.
 boolean isDuplicateConcept(Concept concept)
          Checks if concept is already in the hierarchy, if so, pop up an error message.
 boolean isDuplicateWord(Word word)
          Checks if word is already in the hierarchy, if so, pop up an error message.
 void newConcept(Concept selectedConcept)
          Makes a new Concept and adds it to selectedConcept in the hierarchy.
 void newWord(Concept selectedConcept)
          Makes a new Word and adds it to selectedConcept in the hierarchy.
 void readHierarchy(java.io.File file)
          Re-create this ConceptHierarchy from the file fileName.
 void removeConcept(Concept oldConcept)
          Removes a Concept from the hierarchy with all its children.
 void removeWord(Word oldWord)
          Removes a Word from the hierarchy.
 void setOwner(java.awt.Component owner)
           
 void writeHierarchy(java.io.File file)
          Write this ConceptHierarchy to the file fileName.
 
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, getToolTipText, 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, createToolTip, 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
 

Constructor Detail

ConceptHierarchy

public ConceptHierarchy()
Creates a ConceptHierarchy with only the default root UNIVERSE.


ConceptHierarchy

public ConceptHierarchy(java.io.File file)
Creates a ConceptHierarchy from the file fileName.

Parameters:
file - the file from which the concept hierarchy data is to be read
Method Detail

setOwner

public void setOwner(java.awt.Component owner)

getConceptByName

public Concept getConceptByName(java.lang.String conceptName)
Returns the Concept named conceptName or null if no Concept has conceptName. Suppose there are no two Concepts in the same hierarchy with the same name.

Parameters:
conceptName - the name of the Concept
Returns:
the Concept named conceptName

getConceptByNameIgnoreCase

public Concept getConceptByNameIgnoreCase(java.lang.String conceptName)
Returns the Concept named conceptName (ignoring case) or null if no Concept has conceptName. Suppose there are no two Concepts in the same hierarchy with the same name.

Parameters:
conceptName - the name of the Concept
Returns:
the Concept named conceptName

getConceptFor

public Concept getConceptFor(java.lang.String word)
Returns the Concept of the word word or null if no Concept has word. Suppose there are no two Words in the same hierarchy with the same name.

Parameters:
word - the word whose Concept is to be looked up
Returns:
the Concept of the word word

getWordByName

public Word getWordByName(java.lang.String wordName)
Returns the Word named wordName or null if no Word has wordName. Suppose there are no two Words in the same hierarchy with the same name.

Parameters:
wordName - the name of the Word
Returns:
the Word named wordName

getWordByNameIgnoreCase

public Word getWordByNameIgnoreCase(java.lang.String wordName)
Returns the Word named wordName (ignoring case) or null if no Word has wordName. Suppose there are no two Words in the same hierarchy with the same name.

Parameters:
wordName - the name of the Word
Returns:
the Word named wordName

isa

public static boolean isa(Concept concept1,
                          Concept concept2)
Returns true if concept1 isa concept2, i.e. concept2 is the parent of concept1 in the concept hierarchy.

Returns:
true if concept2 is the parent of concept1, else fase

isaStar

public static boolean isaStar(Concept concept1,
                              Concept concept2)
Returns true if concept1 isa* concept2, i.e. concept2 is concept1 itself or an ancestor of concept1 in the concept hierarchy.

Returns:
true if concept2 is concept1 itself or an ancestor of concept1, else false

addConcept

public boolean addConcept(Concept newConcept,
                          Concept parent)
Adds a new Concept to this ConceptHierarchy as a child of the node parent. If newConcept is already in the hierarchy, show error message.

Parameters:
newConcept - the new Concept to be added
parent - the Concept to which newConcept is to be added
Returns:
true if succeeded, false otherwise (duplicate concepts)

addWord

public boolean addWord(Word newWord,
                       Concept parent)
Adds a new Word to this ConceptHierarchy as a child of the node parent.
All the Words of Concept parent are listed before all the Concepts that isa parent. If newWord is already in the hierarchy, show error message.

Parameters:
newWord - the new Word to be added
parent - the Concept to which newWord is to be added
Returns:
true if succeeded, false otherwise (duplicate words)

newConcept

public void newConcept(Concept selectedConcept)
Makes a new Concept and adds it to selectedConcept in the hierarchy. The default name of the new Concept is New Concept.


newWord

public void newWord(Concept selectedConcept)
Makes a new Word and adds it to selectedConcept in the hierarchy. The default name of the new Word is New Word.


removeConcept

public void removeConcept(Concept oldConcept)
Removes a Concept from the hierarchy with all its children.

Parameters:
oldConcept - the Concept to be removed

removeWord

public void removeWord(Word oldWord)
Removes a Word from the hierarchy.

Parameters:
oldWord - the Word to be removed

clear

public void clear()
Removes all the nodes from the hierarchy except the default root UNIVERSE.


isDuplicateConcept

public boolean isDuplicateConcept(Concept concept)
Checks if concept is already in the hierarchy, if so, pop up an error message.

Parameters:
concept - the concept to be checked
Returns:
true if concept is already in the hierarchy, false otherwise

isDuplicateWord

public boolean isDuplicateWord(Word word)
Checks if word is already in the hierarchy, if so, pop up an error message.

Parameters:
word - the word to be checked
Returns:
true if word is already in the hierarchy, false otherwise

readHierarchy

public void readHierarchy(java.io.File file)
Re-create this ConceptHierarchy from the file fileName. The current hierarchy is replaced. File format is defined elsewhere with the constraint that all concepts and words are listed such that all the nodes appear after their direct ancestors appear, e.g. in Breadth-First order, Depth-First order, etc.


writeHierarchy

public void writeHierarchy(java.io.File file)
Write this ConceptHierarchy to the file fileName. Previous content of the file is replaced.


dragGestureRecognized

public void dragGestureRecognized(java.awt.dnd.DragGestureEvent dge)
Method of DragGestureListener interface

Specified by:
dragGestureRecognized in interface java.awt.dnd.DragGestureListener

dragDropEnd

public void dragDropEnd(java.awt.dnd.DragSourceDropEvent dsde)
Method of DragSourceListener interface

Specified by:
dragDropEnd in interface java.awt.dnd.DragSourceListener

dragEnter

public void dragEnter(java.awt.dnd.DragSourceDragEvent dsde)
Method of DragSourceListener interface

Specified by:
dragEnter in interface java.awt.dnd.DragSourceListener

dragOver

public void dragOver(java.awt.dnd.DragSourceDragEvent dsde)
Method of DragSourceListener interface

Specified by:
dragOver in interface java.awt.dnd.DragSourceListener

dropActionChanged

public void dropActionChanged(java.awt.dnd.DragSourceDragEvent dsde)
Method of DragSourceListener interface

Specified by:
dropActionChanged in interface java.awt.dnd.DragSourceListener

dragExit

public void dragExit(java.awt.dnd.DragSourceEvent dsde)
Method of DragSourceListener interface

Specified by:
dragExit in interface java.awt.dnd.DragSourceListener

drop

public void drop(java.awt.dnd.DropTargetDropEvent e)
Method of DropTargetListener interface

Specified by:
drop in interface java.awt.dnd.DropTargetListener

dragEnter

public void dragEnter(java.awt.dnd.DropTargetDragEvent e)
Method of DropTaregetListener interface

Specified by:
dragEnter in interface java.awt.dnd.DropTargetListener

dragOver

public void dragOver(java.awt.dnd.DropTargetDragEvent e)
Method of DropTaregetListener interface

Specified by:
dragOver in interface java.awt.dnd.DropTargetListener

dragExit

public void dragExit(java.awt.dnd.DropTargetEvent e)
Method of DropTaregetListener interface

Specified by:
dragExit in interface java.awt.dnd.DropTargetListener

dropActionChanged

public void dropActionChanged(java.awt.dnd.DropTargetDragEvent e)
Method of DropTaregetListener interface

Specified by:
dropActionChanged in interface java.awt.dnd.DropTargetListener