Class MipavGraphPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
hypergraph.hyperbolic.ModelPanel
hypergraph.visualnet.GraphPanel
gov.nih.mipav.view.graphVisualization.MipavGraphPanel
- All Implemented Interfaces:
hypergraph.visualnet.GraphLayoutListener,hypergraph.visualnet.GraphSelectionListener,ActionListener,MouseListener,MouseMotionListener,ImageObserver,MenuContainer,Serializable,EventListener,ChangeListener
Displays the Mipav HyperGraph.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclasslaunches the dialog to add infoNested classes/interfaces inherited from class hypergraph.visualnet.GraphPanel
hypergraph.visualnet.GraphPanel.ExpandActionNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate JDialogActionprivate booleanprivate JDialogAddNodeprivate Timerprotected ViewJColorChooserColorChooser for changing graph colors.protected hypergraph.graphApi.NodeCurrent Node to color.private Imageprivate booleanprivate hypergraph.graphApi.Graphprivate hypergraph.graphApi.Nodeprivate Imageprivate ViewJFrameImageThe ViewJFrameImage connect to this Graph, may be null.private StringLast command, used for determining the action the color chooser is associated with.private hypergraph.graphApi.NodeIf there is no Root node, this is the Node with the smallest number of parent nodes, and serves as a default Root for the Graph.private Imageprotected ViewJColorChooserColorChooser for changing graph colors.private JDialogHyperGraphprivate ColorDefault color to highlight the selected nodes on control- mouse-click:protected hypergraph.graphApi.EdgeCurrent selected Edge.protected hypergraph.graphApi.NodeCurrent selected Node.protected hypergraph.graphApi.Nodepreviously selected Node.private MipavGraphPanel.PropertiesDialogprivate static final longgenerated serial idprivate JCheckBoxprotected ViewJColorChooserColorChooser for changing graph colors.Fields inherited from class hypergraph.visualnet.GraphPanel
EDGE_LINECOLOR, EDGE_LINEWIDTH, EDGE_STROKE, EDGE_TEXTCOLOR, expandAction, NODE_BACKGROUND, NODE_EXPANDED, NODE_FOREGROUND, NODE_ICON, shrinkActionFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionMipavGraphPanel(hypergraph.graphApi.Graph kGraph, ViewJFrameImage kImageFrame, JDialogHyperGraph ownerDialog) Creates the GraphPanel display. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidAdd a new node under the picked node.voidCenters the root node in the display.private voiddeleteNode(hypergraph.graphApi.Node node) Delete the input node and it's children nodes: Cannot delete the root node.private voiddeleteNode(hypergraph.graphApi.Node node, hypergraph.graphApi.Node start, hypergraph.graphApi.Node root, Vector<hypergraph.graphApi.Node> deleteList) Recursively deletes children from the tree.voideditAction(String action) Modify the Annotation field of the selected node.voidModify the Annotation field of the selected node.findLevel(hypergraph.graphApi.Node root, hypergraph.graphApi.Node target, int iLevel) Finds the depth, or level of the target node from the Root node.hypergraph.graphApi.NodeReturns the node with the smallest number of 'parent' nodes.private ColorfindNodeColor(hypergraph.graphApi.Node node, int iLevel, int iTargetLevel) Recursively finds the node color at a target level of the tree.hypergraph.graphApi.NodefindRoot()Finds the Root of the tree.getNodeColor(hypergraph.graphApi.Node root, int iTreeLevel) Finds the current color for the input level of the tree.voidincreaseTextSize(boolean bBigger) Increases or decreases the displayed text size.booleanvoidvoidvoidvoidvoidnodeClicked(int iClickCount, hypergraph.graphApi.Node kNode) Called if the node is clicked.voidprivate voidpopupBackground(MouseEvent mouseEvent) Opens up the background popup menu.private voidpopupEdge(MouseEvent mouseEvent, hypergraph.graphApi.Edge edge) Opens the node popup menu.private voidpopupNode(MouseEvent mouseEvent, hypergraph.graphApi.Node node) Opens the node popup menu.voidRefreshes the text display.private voidResets the colors of the picked nodes to the original colors.voidSaves the global graph properties (background color, text sizes) to the default mipav graph preferences file in the Preferences.getPreferencesDir directory.voidsetBGImageShowing(boolean isBGImageShowing) voidbooleansetNodeColor(int iTreeLevel, Color kColor) Sets the node color for all the nodes at the given level of the Graph.voidsetNodeColor(hypergraph.graphApi.Node root, int iTreeLevel, int iTargetLevel, Color kColor) Uses recursion to set the node color for all the nodes at a given level of the Graph.voidMethods inherited from class hypergraph.visualnet.GraphPanel
centerNode, checkLayout, createGraphLayout, expandNode, getEdgeRenderer, getElement, getGraph, getGraphLayout, getHoverElement, getNodeRenderer, getSelectionModel, getVisibleEdgeIterator, getVisibleNodeIterator, hasExpander, initDefaultAttributes, isExpanded, isOnLogo, loadProperties, logoClicked, setEdgeRenderer, setGraph, setGraphLayout, setGraphSelectionModel, setHoverElement, setNodeRenderer, setSmallLogo, shrinkNode, valueChanged, valueChangedMethods inherited from class hypergraph.hyperbolic.ModelPanel
center, getInversViewMatrix, getLineRenderer, getModel, getProjector, getPropertyManager, getScale, getTextRenderer, getUI, getUIClassID, getViewMatrix, mouseDragged, mouseEntered, mouseExited, paintLine, paintRenderer, paintText, project, refreshProperties, setLineRenderer, setModel, setProjector, setTextRenderer, setUI, setViewMatrix, stateChanged, unProject, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, 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, updateMethods inherited from class java.awt.Container
add, 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, validateTreeMethods 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, 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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.awt.event.MouseListener
mouseEntered, mouseExited
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDgenerated serial id- See Also:
-
m_kImageFrame
The ViewJFrameImage connect to this Graph, may be null. -
colorChooser
ColorChooser for changing graph colors. -
nodeColorChooser
ColorChooser for changing graph colors. -
treeLevelColorChooser
ColorChooser for changing graph colors. -
colorNode
protected hypergraph.graphApi.Node colorNodeCurrent Node to color. -
pickedNode
protected hypergraph.graphApi.Node pickedNodeCurrent selected Node. -
pickedNodePrev
protected hypergraph.graphApi.Node pickedNodePrevpreviously selected Node. -
pickedEdge
protected hypergraph.graphApi.Edge pickedEdgeCurrent selected Edge. -
m_kLastCommand
Last command, used for determining the action the color chooser is associated with. -
m_kMinDegree
private hypergraph.graphApi.Node m_kMinDegreeIf there is no Root node, this is the Node with the smallest number of parent nodes, and serves as a default Root for the Graph. -
pickedColor
Default color to highlight the selected nodes on control- mouse-click: -
ownerDialog
-
propertiesDialog
-
addNodeDialog
-
actionDialog
-
addNode
private boolean addNode -
treeCheckBox
-
kGraph
private hypergraph.graphApi.Graph kGraph -
logo
-
lastMouseClickNode
private hypergraph.graphApi.Node lastMouseClickNode -
isBGImageShowing
private boolean isBGImageShowing -
clickTimer
-
image
-
newImage
-
-
Constructor Details
-
MipavGraphPanel
public MipavGraphPanel(hypergraph.graphApi.Graph kGraph, ViewJFrameImage kImageFrame, JDialogHyperGraph ownerDialog) Creates the GraphPanel display.- Parameters:
kGraph- Graph to display.kImageFrame- ViewJFrameImage (may be null).
-
-
Method Details
-
actionPerformed
- Specified by:
actionPerformedin interfaceActionListener
-
setProperties
public void setProperties() -
savePreferences
public void savePreferences()Saves the global graph properties (background color, text sizes) to the default mipav graph preferences file in the Preferences.getPreferencesDir directory. -
addNode
Add a new node under the picked node.- Parameters:
name- The name of the new node.notes- Any notes to add to the node's Annotation field.
-
centerRootNode
public void centerRootNode()Centers the root node in the display. -
editNotes
Modify the Annotation field of the selected node.- Parameters:
notes- new annotation to add to the picked Node.
-
editAction
Modify the Annotation field of the selected node.- Parameters:
notes- new annotation to add to the picked Node.
-
findLevel
public Integer findLevel(hypergraph.graphApi.Node root, hypergraph.graphApi.Node target, int iLevel) Finds the depth, or level of the target node from the Root node.- Parameters:
root- Root node of the Graph.target- Target Node.iLevel- Current depth level.- Returns:
- the level of the Target in the Graph.
-
findMinRoot
public hypergraph.graphApi.Node findMinRoot()Returns the node with the smallest number of 'parent' nodes. If the tree has a true Root node, with zero parents, the Root is returned. Otherwise the node with the smallest number of inputs is returned. For Graphs without a true Root, there may be more than one MinRoot.- Returns:
-
findRoot
public hypergraph.graphApi.Node findRoot()Finds the Root of the tree. If there is no true Root (with zero inputs), returns null.- Returns:
-
getNodeColor
Finds the current color for the input level of the tree.- Parameters:
root- the tree root node.iTreeLevel- the level to querery the color of.- Returns:
- The node color at the given tree depth.
-
increaseTextSize
public void increaseTextSize(boolean bBigger) Increases or decreases the displayed text size.- Parameters:
bBigger- when true increases the size, when false decreases the size.
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener- Overrides:
mouseClickedin classhypergraph.visualnet.GraphPanel
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener- Overrides:
mouseMovedin classhypergraph.visualnet.GraphPanel
-
getPropertiesDialog
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener- Overrides:
mousePressedin classhypergraph.hyperbolic.ModelPanel
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener- Overrides:
mouseReleasedin classhypergraph.hyperbolic.ModelPanel
-
nodeClicked
public void nodeClicked(int iClickCount, hypergraph.graphApi.Node kNode) Called if the node is clicked.- Overrides:
nodeClickedin classhypergraph.visualnet.GraphPanel- Parameters:
iClickCount- The number of clicks on the node.kNode- The node that has been clicked on.
-
refreshText
public void refreshText()Refreshes the text display. -
setNodeColor
Sets the node color for all the nodes at the given level of the Graph. Uses the "TreeLevel" node Attribute.- Parameters:
iTreeLevel- level of the Graph from the root.kColor- new color.- Returns:
- true on success, false if the "TreeLevel" node attribute is not set.
-
setNodeColor
public void setNodeColor(hypergraph.graphApi.Node root, int iTreeLevel, int iTargetLevel, Color kColor) Uses recursion to set the node color for all the nodes at a given level of the Graph.- Parameters:
root- Root Node.iTreeLevel- current level in the recursion.iTargetLevel- target level.kColor- new color.
-
deleteNode
private void deleteNode(hypergraph.graphApi.Node node) Delete the input node and it's children nodes: Cannot delete the root node.- Parameters:
node-
-
deleteNode
private void deleteNode(hypergraph.graphApi.Node node, hypergraph.graphApi.Node start, hypergraph.graphApi.Node root, Vector<hypergraph.graphApi.Node> deleteList) Recursively deletes children from the tree. The original node to delete is the start node. The recursion stops when the root node is reached, or if the start node is reached (for example when it is part of a loop with it's children) or when all the children have been added to the delete list.- Parameters:
node- current node to delete.start- original parent node that triggered the delete.root- the root of the graph (cannot be deleted)deleteList- the list of nodes to be deleted. Prevents infinite recursion when nodes are in a loop.
-
findNodeColor
Recursively finds the node color at a target level of the tree.- Parameters:
node- the current node (root of the subtree).iLevel- the current recursion level.iTargetLevel- the target level of the tree.- Returns:
- the color of the Node at the target level.
-
popupBackground
Opens up the background popup menu.- Parameters:
mouseEvent-
-
popupEdge
Opens the node popup menu.- Parameters:
mouseEvent-node-
-
popupNode
Opens the node popup menu.- Parameters:
mouseEvent-node-
-
resetPicked
private void resetPicked()Resets the colors of the picked nodes to the original colors. -
setLogo
- Overrides:
setLogoin classhypergraph.visualnet.GraphPanel
-
setBGImageShowing
public void setBGImageShowing(boolean isBGImageShowing) -
isBGImageShowing
public boolean isBGImageShowing() -
paint
- Overrides:
paintin classhypergraph.visualnet.GraphPanel
-