public class ConceptHierarchy extends JTree implements DragGestureListener, DragSourceListener, DropTargetListener
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.
JTree.AccessibleJTree, JTree.DropLocation, JTree.DynamicUtilTreeNode, JTree.EmptySelectionModel, JTree.TreeModelHandler, JTree.TreeSelectionRedirectorJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategyANCHOR_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, visibleRowCountaccessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
ConceptHierarchy()
Creates a
ConceptHierarchy with only the default root
UNIVERSE. |
ConceptHierarchy(File file)
Creates a
ConceptHierarchy from the file fileName. |
| Modifier and Type | Method and Description |
|---|---|
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(DragSourceDropEvent dsde)
Method of DragSourceListener interface
|
void |
dragEnter(DragSourceDragEvent dsde)
Method of DragSourceListener interface
|
void |
dragEnter(DropTargetDragEvent e)
Method of DropTaregetListener interface
|
void |
dragExit(DragSourceEvent dsde)
Method of DragSourceListener interface
|
void |
dragExit(DropTargetEvent e)
Method of DropTaregetListener interface
|
void |
dragGestureRecognized(DragGestureEvent dge)
Method of DragGestureListener interface
|
void |
dragOver(DragSourceDragEvent dsde)
Method of DragSourceListener interface
|
void |
dragOver(DropTargetDragEvent e)
Method of DropTaregetListener interface
|
void |
drop(DropTargetDropEvent e)
Method of DropTargetListener interface
|
void |
dropActionChanged(DragSourceDragEvent dsde)
Method of DragSourceListener interface
|
void |
dropActionChanged(DropTargetDragEvent e)
Method of DropTaregetListener interface
|
Concept |
getConceptByName(String conceptName)
Returns the
Concept named conceptName or
null if no Concept has conceptName. |
Concept |
getConceptByNameIgnoreCase(String conceptName)
Returns the
Concept named conceptName (ignoring case)
or null if no Concept has conceptName. |
Concept |
getConceptFor(String word)
Returns the
Concept of the word word or
null if no Concept has word. |
Word |
getWordByName(String wordName)
Returns the
Word named wordName or
null if no Word has wordName. |
Word |
getWordByNameIgnoreCase(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(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(Component owner) |
void |
writeHierarchy(File file)
Write this
ConceptHierarchy to the file fileName. |
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, getDropLocation, getDropMode, 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, setDropMode, setEditable, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setModel, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionModel, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, startEditingAtPath, stopEditing, treeDidChange, updateUIaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, 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, transferFocusBackward, transferFocusUpCyclepublic ConceptHierarchy()
ConceptHierarchy with only the default root
UNIVERSE.public ConceptHierarchy(File file)
ConceptHierarchy from the file fileName.file - the file from which the concept hierarchy data is to be readpublic void setOwner(Component owner)
public Concept getConceptByName(String conceptName)
Concept named conceptName or
null if no Concept has conceptName.
Suppose there are no two Concepts in the same hierarchy
with the same name.conceptName - the name of the ConceptConcept named conceptNamepublic Concept getConceptByNameIgnoreCase(String conceptName)
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.conceptName - the name of the ConceptConcept named conceptNamepublic Concept getConceptFor(String word)
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.word - the word whose Concept is to be looked upConcept of the word wordpublic Word getWordByName(String wordName)
Word named wordName or
null if no Word has wordName.
Suppose there are no two Words in the same hierarchy
with the same name.wordName - the name of the WordWord named wordNamepublic Word getWordByNameIgnoreCase(String wordName)
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.wordName - the name of the WordWord named wordNamepublic static boolean isa(Concept concept1, Concept concept2)
concept1 isa concept2,
i.e. concept2 is the parent of concept1
in the concept hierarchy.concept2 is the parent of concept1,
else fasepublic static boolean isaStar(Concept concept1, Concept concept2)
concept1 isa* concept2,
i.e. concept2 is concept1 itself or
an ancestor of concept1 in the concept hierarchy.concept2 is concept1 itself or
an ancestor of concept1, else falsepublic boolean addConcept(Concept newConcept, Concept parent)
Concept to this ConceptHierarchy as
a child of the node parent.
If newConcept is already in the hierarchy, show error message.newConcept - the new Concept to be addedparent - the Concept to which newConcept
is to be addedpublic boolean addWord(Word newWord, Concept parent)
Word to this ConceptHierarchy as a
child of the node parent.Words of Concept parent are listed before
all the Concepts that isa parent.
If newWord is already in the hierarchy, show error message.newWord - the new Word to be addedparent - the Concept to which newWord
is to be addedpublic void newConcept(Concept selectedConcept)
Concept and adds it to selectedConcept
in the hierarchy. The default name of the new Concept is
New Concept.public void newWord(Concept selectedConcept)
Word and adds it to selectedConcept
in the hierarchy. The default name of the new Word is
New Word.public void removeConcept(Concept oldConcept)
Concept from the hierarchy with all its children.oldConcept - the Concept to be removedparent - the Concept from which oldConcept
is to be removedpublic void removeWord(Word oldWord)
Word from the hierarchy.oldWord - the Word to be removedparent - the Concept from which oldWord
is to be removedpublic void clear()
public boolean isDuplicateConcept(Concept concept)
concept is already in the hierarchy, if so,
pop up an error message.concept - the concept to be checkedconcept is already in the hierarchy,
false otherwisepublic boolean isDuplicateWord(Word word)
word is already in the hierarchy, if so,
pop up an error message.word - the word to be checkedword is already in the hierarchy,
false otherwisepublic void readHierarchy(File file)
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.fileName - the name of the file from which the concept hierarchy
data is to be readpublic void writeHierarchy(File file)
ConceptHierarchy to the file fileName.
Previous content of the file is replaced.fileName - the name of the file to which the concept hierarchy data
is to be written.public void dragGestureRecognized(DragGestureEvent dge)
dragGestureRecognized in interface DragGestureListenerpublic void dragDropEnd(DragSourceDropEvent dsde)
dragDropEnd in interface DragSourceListenerpublic void dragEnter(DragSourceDragEvent dsde)
dragEnter in interface DragSourceListenerpublic void dragOver(DragSourceDragEvent dsde)
dragOver in interface DragSourceListenerpublic void dropActionChanged(DragSourceDragEvent dsde)
dropActionChanged in interface DragSourceListenerpublic void dragExit(DragSourceEvent dsde)
dragExit in interface DragSourceListenerpublic void drop(DropTargetDropEvent e)
drop in interface DropTargetListenerpublic void dragEnter(DropTargetDragEvent e)
dragEnter in interface DropTargetListenerpublic void dragOver(DropTargetDragEvent e)
dragOver in interface DropTargetListenerpublic void dragExit(DropTargetEvent e)
dragExit in interface DropTargetListenerpublic void dropActionChanged(DropTargetDragEvent e)
dropActionChanged in interface DropTargetListenerCopyright © 2016 New York University. All rights reserved.