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
,java.awt.event.ActionListener
,java.awt.event.MouseListener
,java.awt.event.MouseMotionListener
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,java.util.EventListener
,javax.swing.event.ChangeListener
public class MipavGraphPanel extends hypergraph.visualnet.GraphPanel implements java.awt.event.ActionListener
Displays the Mipav HyperGraph.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
MipavGraphPanel.PropertiesDialog
launches the dialog to add info-
Nested classes/interfaces inherited from class hypergraph.visualnet.GraphPanel
hypergraph.visualnet.GraphPanel.ExpandAction
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description private JDialogAction
actionDialog
private boolean
addNode
private JDialogAddNode
addNodeDialog
private javax.swing.Timer
clickTimer
protected ViewJColorChooser
colorChooser
ColorChooser for changing graph colors.protected hypergraph.graphApi.Node
colorNode
Current Node to color.private java.awt.Image
image
private boolean
isBGImageShowing
private hypergraph.graphApi.Graph
kGraph
private hypergraph.graphApi.Node
lastMouseClickNode
private java.awt.Image
logo
private ViewJFrameImage
m_kImageFrame
The ViewJFrameImage connect to this Graph, may be null.private java.lang.String
m_kLastCommand
Last command, used for determining the action the color chooser is associated with.private hypergraph.graphApi.Node
m_kMinDegree
If 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 java.awt.Image
newImage
protected ViewJColorChooser
nodeColorChooser
ColorChooser for changing graph colors.private JDialogHyperGraph
ownerDialog
private java.awt.Color
pickedColor
Default color to highlight the selected nodes on control- mouse-click:protected hypergraph.graphApi.Edge
pickedEdge
Current selected Edge.protected hypergraph.graphApi.Node
pickedNode
Current selected Node.protected hypergraph.graphApi.Node
pickedNodePrev
previously selected Node.private MipavGraphPanel.PropertiesDialog
propertiesDialog
private static long
serialVersionUID
generated serial idprivate javax.swing.JCheckBox
treeCheckBox
protected ViewJColorChooser
treeLevelColorChooser
ColorChooser 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, shrinkAction
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description MipavGraphPanel(hypergraph.graphApi.Graph kGraph, ViewJFrameImage kImageFrame, JDialogHyperGraph ownerDialog)
Creates the GraphPanel display.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
actionPerformed(java.awt.event.ActionEvent e)
void
addNode(java.lang.String name, java.lang.String notes)
Add a new node under the picked node.void
centerRootNode()
Centers the root node in the display.private void
deleteNode(hypergraph.graphApi.Node node)
Delete the input node and it's children nodes: Cannot delete the root node.private void
deleteNode(hypergraph.graphApi.Node node, hypergraph.graphApi.Node start, hypergraph.graphApi.Node root, java.util.Vector<hypergraph.graphApi.Node> deleteList)
Recursively deletes children from the tree.void
editAction(java.lang.String action)
Modify the Annotation field of the selected node.void
editNotes(java.lang.String notes)
Modify the Annotation field of the selected node.java.lang.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.hypergraph.graphApi.Node
findMinRoot()
Returns the node with the smallest number of 'parent' nodes.private java.awt.Color
findNodeColor(hypergraph.graphApi.Node node, int iLevel, int iTargetLevel)
Recursively finds the node color at a target level of the tree.hypergraph.graphApi.Node
findRoot()
Finds the Root of the tree.java.awt.Color
getNodeColor(hypergraph.graphApi.Node root, int iTreeLevel)
Finds the current color for the input level of the tree.MipavGraphPanel.PropertiesDialog
getPropertiesDialog()
void
increaseTextSize(boolean bBigger)
Increases or decreases the displayed text size.boolean
isBGImageShowing()
void
mouseClicked(java.awt.event.MouseEvent e)
void
mouseMoved(java.awt.event.MouseEvent e)
void
mousePressed(java.awt.event.MouseEvent e)
void
mouseReleased(java.awt.event.MouseEvent e)
void
nodeClicked(int iClickCount, hypergraph.graphApi.Node kNode)
Called if the node is clicked.void
paint(java.awt.Graphics g)
private void
popupBackground(java.awt.event.MouseEvent mouseEvent)
Opens up the background popup menu.private void
popupEdge(java.awt.event.MouseEvent mouseEvent, hypergraph.graphApi.Edge edge)
Opens the node popup menu.private void
popupNode(java.awt.event.MouseEvent mouseEvent, hypergraph.graphApi.Node node)
Opens the node popup menu.void
refreshText()
Refreshes the text display.private void
resetPicked()
Resets the colors of the picked nodes to the original colors.void
savePreferences()
Saves the global graph properties (background color, text sizes) to the default mipav graph preferences file in the Preferences.getPreferencesDir directory.void
setBGImageShowing(boolean isBGImageShowing)
void
setLogo(java.awt.Image l)
boolean
setNodeColor(int iTreeLevel, java.awt.Color kColor)
Sets the node color for all the nodes at the given level of the Graph.void
setNodeColor(hypergraph.graphApi.Node root, int iTreeLevel, int iTargetLevel, java.awt.Color kColor)
Uses recursion to set the node color for all the nodes at a given level of the Graph.void
setProperties()
-
Methods 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, valueChanged
-
Methods 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, updateUI
-
Methods 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, update
-
Methods 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, 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, 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, transferFocusUpCycle
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
generated serial id- See Also:
- Constant Field Values
-
m_kImageFrame
private ViewJFrameImage m_kImageFrame
The ViewJFrameImage connect to this Graph, may be null.
-
colorChooser
protected ViewJColorChooser colorChooser
ColorChooser for changing graph colors.
-
nodeColorChooser
protected ViewJColorChooser nodeColorChooser
ColorChooser for changing graph colors.
-
treeLevelColorChooser
protected ViewJColorChooser treeLevelColorChooser
ColorChooser for changing graph colors.
-
colorNode
protected hypergraph.graphApi.Node colorNode
Current Node to color.
-
pickedNode
protected hypergraph.graphApi.Node pickedNode
Current selected Node.
-
pickedNodePrev
protected hypergraph.graphApi.Node pickedNodePrev
previously selected Node.
-
pickedEdge
protected hypergraph.graphApi.Edge pickedEdge
Current selected Edge.
-
m_kLastCommand
private java.lang.String m_kLastCommand
Last command, used for determining the action the color chooser is associated with.
-
m_kMinDegree
private hypergraph.graphApi.Node m_kMinDegree
If 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
private java.awt.Color pickedColor
Default color to highlight the selected nodes on control- mouse-click:
-
ownerDialog
private JDialogHyperGraph ownerDialog
-
propertiesDialog
private MipavGraphPanel.PropertiesDialog propertiesDialog
-
addNodeDialog
private JDialogAddNode addNodeDialog
-
actionDialog
private JDialogAction actionDialog
-
addNode
private boolean addNode
-
treeCheckBox
private javax.swing.JCheckBox treeCheckBox
-
kGraph
private hypergraph.graphApi.Graph kGraph
-
logo
private java.awt.Image logo
-
lastMouseClickNode
private hypergraph.graphApi.Node lastMouseClickNode
-
isBGImageShowing
private boolean isBGImageShowing
-
clickTimer
private javax.swing.Timer clickTimer
-
image
private java.awt.Image image
-
newImage
private java.awt.Image newImage
-
-
Constructor Detail
-
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 Detail
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Specified by:
actionPerformed
in interfacejava.awt.event.ActionListener
-
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
public void addNode(java.lang.String name, java.lang.String notes)
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
public void editNotes(java.lang.String notes)
Modify the Annotation field of the selected node.- Parameters:
notes
- new annotation to add to the picked Node.
-
editAction
public void editAction(java.lang.String action)
Modify the Annotation field of the selected node.- Parameters:
notes
- new annotation to add to the picked Node.
-
findLevel
public java.lang.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
public java.awt.Color getNodeColor(hypergraph.graphApi.Node root, int iTreeLevel)
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
public void mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClicked
in interfacejava.awt.event.MouseListener
- Overrides:
mouseClicked
in classhypergraph.visualnet.GraphPanel
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
- Specified by:
mouseMoved
in interfacejava.awt.event.MouseMotionListener
- Overrides:
mouseMoved
in classhypergraph.visualnet.GraphPanel
-
getPropertiesDialog
public MipavGraphPanel.PropertiesDialog getPropertiesDialog()
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
- Specified by:
mousePressed
in interfacejava.awt.event.MouseListener
- Overrides:
mousePressed
in classhypergraph.hyperbolic.ModelPanel
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
- Specified by:
mouseReleased
in interfacejava.awt.event.MouseListener
- Overrides:
mouseReleased
in classhypergraph.hyperbolic.ModelPanel
-
nodeClicked
public void nodeClicked(int iClickCount, hypergraph.graphApi.Node kNode)
Called if the node is clicked.- Overrides:
nodeClicked
in 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
public boolean setNodeColor(int iTreeLevel, java.awt.Color kColor)
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, java.awt.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, java.util.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
private java.awt.Color findNodeColor(hypergraph.graphApi.Node node, int iLevel, int iTargetLevel)
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
private void popupBackground(java.awt.event.MouseEvent mouseEvent)
Opens up the background popup menu.- Parameters:
mouseEvent
-
-
popupEdge
private void popupEdge(java.awt.event.MouseEvent mouseEvent, hypergraph.graphApi.Edge edge)
Opens the node popup menu.- Parameters:
mouseEvent
-node
-
-
popupNode
private void popupNode(java.awt.event.MouseEvent mouseEvent, hypergraph.graphApi.Node node)
Opens the node popup menu.- Parameters:
mouseEvent
-node
-
-
resetPicked
private void resetPicked()
Resets the colors of the picked nodes to the original colors.
-
setLogo
public void setLogo(java.awt.Image l)
- Overrides:
setLogo
in classhypergraph.visualnet.GraphPanel
-
setBGImageShowing
public void setBGImageShowing(boolean isBGImageShowing)
-
isBGImageShowing
public boolean isBGImageShowing()
-
paint
public void paint(java.awt.Graphics g)
- Overrides:
paint
in classhypergraph.visualnet.GraphPanel
-
-