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

public class MipavGraphPanel extends hypergraph.visualnet.GraphPanel implements ActionListener
Displays the Mipav HyperGraph.
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      generated serial id
      See Also:
    • 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 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 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 JCheckBox treeCheckBox
    • kGraph

      private hypergraph.graphApi.Graph kGraph
    • lastMouseClickNode

      private hypergraph.graphApi.Node lastMouseClickNode
    • isBGImageShowing

      private boolean isBGImageShowing
    • clickTimer

      private Timer clickTimer
    • image

      private Image image
    • newImage

      private 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

      public void actionPerformed(ActionEvent e)
      Specified by:
      actionPerformed in interface 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(String name, 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(String notes)
      Modify the Annotation field of the selected node.
      Parameters:
      notes - new annotation to add to the picked Node.
    • editAction

      public void editAction(String action)
      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

      public 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(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
      Overrides:
      mouseClicked in class hypergraph.visualnet.GraphPanel
    • mouseMoved

      public void mouseMoved(MouseEvent e)
      Specified by:
      mouseMoved in interface MouseMotionListener
      Overrides:
      mouseMoved in class hypergraph.visualnet.GraphPanel
    • getPropertiesDialog

      public MipavGraphPanel.PropertiesDialog getPropertiesDialog()
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
      Overrides:
      mousePressed in class hypergraph.hyperbolic.ModelPanel
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
      Overrides:
      mouseReleased in class hypergraph.hyperbolic.ModelPanel
    • nodeClicked

      public void nodeClicked(int iClickCount, hypergraph.graphApi.Node kNode)
      Called if the node is clicked.
      Overrides:
      nodeClicked in class hypergraph.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, 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, 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

      private 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(MouseEvent mouseEvent)
      Opens up the background popup menu.
      Parameters:
      mouseEvent -
    • popupEdge

      private void popupEdge(MouseEvent mouseEvent, hypergraph.graphApi.Edge edge)
      Opens the node popup menu.
      Parameters:
      mouseEvent -
      node -
    • popupNode

      private void popupNode(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(Image l)
      Overrides:
      setLogo in class hypergraph.visualnet.GraphPanel
    • setBGImageShowing

      public void setBGImageShowing(boolean isBGImageShowing)
    • isBGImageShowing

      public boolean isBGImageShowing()
    • paint

      public void paint(Graphics g)
      Overrides:
      paint in class hypergraph.visualnet.GraphPanel