Package ghidra.graph.viewer

# Class GraphViewer<V extends VisualVertex,E extends VisualEdge<V>>

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.uci.ics.jung.visualization.BasicVisualizationServer<V,E>
edu.uci.ics.jung.visualization.VisualizationViewer<V,E>
ghidra.graph.viewer.GraphViewer<V,E>

Type Parameters:
  `V` - the vertex type
  `E` - the edge type

All Implemented Interfaces:
  `edu.uci.ics.jung.visualization.util.ChangeEventSupport`, `edu.uci.ics.jung.visualization.VisualizationServer<V,E>`, `ImageObserver`, `MenuContainer`, `Serializable`, `EventListener`, `Accessible`, `ChangeListener`

public class GraphViewer<V extends VisualVertex,E extends VisualEdge<V>> extends edu.uci.ics.jung.visualization.VisualizationViewer<V,E>
The base viewer for the Graph module. This viewer provides methods for manipulating the graph using the mouse.

The viewer is currently an extension of the `VisualizationViewer` and as such it is accessed by much of the event handling subsystem, such as the mouse plugins, as well as the rendering system.

Also, tooltips/popups for edges and vertices are handled by this class.

This class creates a `VisualGraphViewUpdater` that perform graph transformations, such as panning the graph, with and without animation, as requested.

See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class edu.uci.ics.jung.visualization.VisualizationViewer

  `edu.uci.ics.jung.visualization.VisualizationViewer.GraphMouse`

  ## Nested classes/interfaces inherited from class edu.uci.ics.jung.visualization.BasicVisualizationServer

  `edu.uci.ics.jung.visualization.BasicVisualizationServer.VisualizationListener`

  ## Nested classes/interfaces inherited from class javax.swing.JPanel

  `JPanel.AccessibleJPanel`

  ## Nested classes/interfaces inherited from class javax.swing.JComponent

  `JComponent.AccessibleJComponent`

  ## Nested classes/interfaces inherited from class java.awt.Container

  `Container.AccessibleAWTContainer`

  ## Nested classes/interfaces inherited from class java.awt.Component

  `Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy`

  ## Nested classes/interfaces inherited from interface edu.uci.ics.jung.visualization.VisualizationServer

  `edu.uci.ics.jung.visualization.VisualizationServer.Paintable`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected VisualGraphOptions`
  `vgOptions`

  ### Fields inherited from class edu.uci.ics.jung.visualization.VisualizationViewer

  `edgeToolTipTransformer, graphMouse, mouseEventToolTipTransformer, requestFocusListener, vertexToolTipTransformer`

  ### Fields inherited from class edu.uci.ics.jung.visualization.BasicVisualizationServer

  `changeSupport, doubleBuffered, model, offscreen, offscreenG2d, pickedEdgeState, pickedVertexState, pickEventListener, postRenderers, preRenderers, renderContext, renderer, renderingHints`

  ### 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`

  ### Fields inherited from class java.awt.Component

  `accessibleContext, 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

  Constructors
  Constructor
  Description
  `GraphViewer(VisualGraphLayout<V,E> layout, Dimension size)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Component`
  `add(Component comp)`
  !!Super Hacky Override!! The code we are overriding blindly calls add(), without first checking to see if it has already been added.
  `protected VisualGraphPathHighlighter<V,E>`
  `createPathHighlighter(PathHighlightListener listener)`
  `VertexMouseInfo<V,E>`
  `createVertexMouseInfo(MouseEvent e, V v, Point2D vertexBasedClickPoint)`
  `protected VisualGraphViewUpdater<V,E>`
  `createViewUpdater()`
  `void`
  `dispose()`
  `Point2D`
  `getCenter()`
  `GPickedState<V>`
  `getGPickedVertexState()`
  `VisualGraphPluggableGraphMouse<V,E>`
  `getGraphMouse()`
  `VisualGraphOptions`
  `getOptions()`
  `VisualGraphPathHighlighter<V,E>`
  `getPathHighlighter()`
  `String`
  `getToolTipText(MouseEvent event)`
  `PathHighlightMode`
  `getVertexFocusPathHighlightMode()`
  `PathHighlightMode`
  `getVertexHoverPathHighlightMode()`
  `VisualGraphViewUpdater<V,E>`
  `getViewUpdater()`
  `VisualGraph<V,E>`
  `getVisualGraph()`
  `VisualGraphLayout<V,E>`
  `getVisualGraphLayout()`
  `void`
  `optionsChanged()`
  `protected void`
  `paintComponent(Graphics g)`
  !!Super Hacky Override!! This is done to make sure that we center the view when we are fully laid-out.
  `void`
  `setGraphLayout(edu.uci.ics.jung.algorithms.layout.Layout<V,E> layout)`
  `void`
  `setGraphMouse(edu.uci.ics.jung.visualization.VisualizationViewer.GraphMouse graphMouse)`
  `void`
  `setGraphOptions(VisualGraphOptions options)`
  `void`
  `setPopupsVisible(boolean visible)`
  `void`
  `setVertexFocusPathHighlightMode(PathHighlightMode focusMode)`
  `void`
  `setVertexHoverPathHighlightMode(PathHighlightMode hoverMode)`
  `void`
  `setVertexTooltipProvider(VertexTooltipProvider<V,E> vertexTooltipProvider)`
  `void`
  `setViewerInitializedListener(Consumer<GraphViewer<V,E>> listener)`
  `boolean`
  `useMouseRelativeZoom()`
  When true (the default), the zoom will center wherever the mouse is positioned.

  ### Methods inherited from class edu.uci.ics.jung.visualization.VisualizationViewer

  `addGraphMouseListener, addKeyListener, setEdgeToolTipTransformer, setMouseEventToolTipTransformer, setVertexToolTipTransformer`

  ### Methods inherited from class edu.uci.ics.jung.visualization.BasicVisualizationServer

  `addChangeListener, addPostRenderPaintable, addPreRenderPaintable, checkOffscreenImage, fireStateChanged, getChangeListeners, getGraphLayout, getModel, getPickedEdgeState, getPickedVertexState, getPickSupport, getRenderContext, getRenderer, getRenderingHints, getSize, isDoubleBuffered, prependPostRenderPaintable, prependPreRenderPaintable, removeChangeListener, removePostRenderPaintable, removePreRenderPaintable, renderGraph, scaleToLayout, setDoubleBuffered, setModel, setPickedEdgeState, setPickedVertexState, setPickSupport, setRenderContext, setRenderer, setRenderingHints, setVisible, stateChanged`

  ### Methods inherited from class javax.swing.JPanel

  `getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update`

  ### Methods inherited from class java.awt.Container

  `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, 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, getPropertyChangeListeners, getPropertyChangeListeners, 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`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface edu.uci.ics.jung.visualization.VisualizationServer

  `repaint`

- ## Field Details

  - ### vgOptions

    protected VisualGraphOptions vgOptions

- ## Constructor Details

  - ### GraphViewer

    public GraphViewer(VisualGraphLayout<V,E> layout, Dimension size)

- ## Method Details

  - ### createPathHighlighter

    protected VisualGraphPathHighlighter<V,E> createPathHighlighter(PathHighlightListener listener)

  - ### createViewUpdater

    protected VisualGraphViewUpdater<V,E> createViewUpdater()

  - ### getVisualGraphLayout

    public VisualGraphLayout<V,E> getVisualGraphLayout()

  - ### setGraphLayout

    public void setGraphLayout(edu.uci.ics.jung.algorithms.layout.Layout<V,E> layout)
    Specified by:
      `setGraphLayout` in interface `edu.uci.ics.jung.visualization.VisualizationServer<V extends VisualVertex,E extends VisualEdge<V>>`
    Overrides:
      `setGraphLayout` in class `edu.uci.ics.jung.visualization.BasicVisualizationServer<V extends VisualVertex,E extends VisualEdge<V>>`

  - ### getVisualGraph

    public VisualGraph<V,E> getVisualGraph()

  - ### getGraphMouse

    public VisualGraphPluggableGraphMouse<V,E> getGraphMouse()
    Overrides:
      `getGraphMouse` in class `edu.uci.ics.jung.visualization.VisualizationViewer<V extends VisualVertex,E extends VisualEdge<V>>`

  - ### setGraphMouse

    public void setGraphMouse(edu.uci.ics.jung.visualization.VisualizationViewer.GraphMouse graphMouse)
    Overrides:
      `setGraphMouse` in class `edu.uci.ics.jung.visualization.VisualizationViewer<V extends VisualVertex,E extends VisualEdge<V>>`

  - ### setGraphOptions

    public void setGraphOptions(VisualGraphOptions options)

  - ### optionsChanged

    public void optionsChanged()

  - ### getOptions

    public VisualGraphOptions getOptions()

  - ### setVertexHoverPathHighlightMode

    public void setVertexHoverPathHighlightMode(PathHighlightMode hoverMode)

  - ### setVertexFocusPathHighlightMode

    public void setVertexFocusPathHighlightMode(PathHighlightMode focusMode)

  - ### getVertexHoverPathHighlightMode

    public PathHighlightMode getVertexHoverPathHighlightMode()

  - ### getVertexFocusPathHighlightMode

    public PathHighlightMode getVertexFocusPathHighlightMode()

  - ### setViewerInitializedListener

    public void setViewerInitializedListener(Consumer<GraphViewer<V,E>> listener)

  - ### getPathHighlighter

    public VisualGraphPathHighlighter<V,E> getPathHighlighter()

  - ### getViewUpdater

    public VisualGraphViewUpdater<V,E> getViewUpdater()

  - ### getGPickedVertexState

    public GPickedState<V> getGPickedVertexState()

  - ### setVertexTooltipProvider

    public void setVertexTooltipProvider(VertexTooltipProvider<V,E> vertexTooltipProvider)

  - ### useMouseRelativeZoom

    public boolean useMouseRelativeZoom()
    When true (the default), the zoom will center wherever the mouse is positioned. False will zoom at the center of the view.
    Returns:
      true if using mouse-relative zoom

  - ### add

    public Component add(Component comp)
    !!Super Hacky Override!! The code we are overriding blindly calls add(), without first checking to see if it has already been added. Java 6 added a method, removeNotify(), that is called when components are removed. When add is called in the overridden method, it triggers a call to remove, which triggers removeNotify(). This call is made during the painting process. The problem therein is that out buttons borders get reset (see AbstractButton.removeNotify()) when we repaint, which means that mouse hovers do not work correctly (SCR 6819).
    Overrides:
      `add` in class `Container`

  - ### paintComponent

    protected void paintComponent(Graphics g)
    !!Super Hacky Override!! This is done to make sure that we center the view when we are fully laid-out. If you know of a better way to do this, then, get rid of this overridden method and do the good thing.
    Overrides:
      `paintComponent` in class `edu.uci.ics.jung.visualization.BasicVisualizationServer<V extends VisualVertex,E extends VisualEdge<V>>`

  - ### getCenter

    public Point2D getCenter()
    Specified by:
      `getCenter` in interface `edu.uci.ics.jung.visualization.VisualizationServer<V extends VisualVertex,E extends VisualEdge<V>>`
    Overrides:
      `getCenter` in class `edu.uci.ics.jung.visualization.BasicVisualizationServer<V extends VisualVertex,E extends VisualEdge<V>>`

  - ### setPopupsVisible

    public void setPopupsVisible(boolean visible)

  - ### getToolTipText

    public String getToolTipText(MouseEvent event)
    Overrides:
      `getToolTipText` in class `edu.uci.ics.jung.visualization.VisualizationViewer<V extends VisualVertex,E extends VisualEdge<V>>`

  - ### createVertexMouseInfo

    public VertexMouseInfo<V,E> createVertexMouseInfo(MouseEvent e, V v, Point2D vertexBasedClickPoint)

  - ### dispose

    public void dispose()