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 typeE
- the edge type
- All Implemented Interfaces:
edu.uci.ics.jung.visualization.util.ChangeEventSupport
,edu.uci.ics.jung.visualization.VisualizationServer<V,E>
,java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,java.util.EventListener
,javax.accessibility.Accessible
,javax.swing.event.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
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
-
-
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
-
-
Constructor Summary
Constructors Constructor Description GraphViewer(VisualGraphLayout<V,E> layout, java.awt.Dimension size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.Component
add(java.awt.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(java.awt.event.MouseEvent e, V v, java.awt.geom.Point2D vertexBasedClickPoint)
protected VisualGraphViewUpdater<V,E>
createViewUpdater()
void
dispose()
java.awt.geom.Point2D
getCenter()
GPickedState<V>
getGPickedVertexState()
VisualGraphPluggableGraphMouse<V,E>
getGraphMouse()
VisualGraphOptions
getOptions()
VisualGraphPathHighlighter<V,E>
getPathHighlighter()
java.lang.String
getToolTipText(java.awt.event.MouseEvent event)
PathHighlightMode
getVertexFocusPathHighlightMode()
PathHighlightMode
getVertexHoverPathHighlightMode()
VisualGraphViewUpdater<V,E>
getViewUpdater()
VisualGraph<V,E>
getVisualGraph()
VisualGraphLayout<V,E>
getVisualGraphLayout()
void
optionsChanged()
protected void
paintComponent(java.awt.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(java.util.function.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
-
-
-
-
Field Detail
-
vgOptions
protected VisualGraphOptions vgOptions
-
-
Constructor Detail
-
GraphViewer
public GraphViewer(VisualGraphLayout<V,E> layout, java.awt.Dimension size)
-
-
Method Detail
-
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 interfaceedu.uci.ics.jung.visualization.VisualizationServer<V extends VisualVertex,E extends VisualEdge<V>>
- Overrides:
setGraphLayout
in classedu.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 classedu.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 classedu.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(java.util.function.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 java.awt.Component add(java.awt.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 classjava.awt.Container
-
paintComponent
protected void paintComponent(java.awt.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 classedu.uci.ics.jung.visualization.BasicVisualizationServer<V extends VisualVertex,E extends VisualEdge<V>>
-
getCenter
public java.awt.geom.Point2D getCenter()
- Specified by:
getCenter
in interfaceedu.uci.ics.jung.visualization.VisualizationServer<V extends VisualVertex,E extends VisualEdge<V>>
- Overrides:
getCenter
in classedu.uci.ics.jung.visualization.BasicVisualizationServer<V extends VisualVertex,E extends VisualEdge<V>>
-
setPopupsVisible
public void setPopupsVisible(boolean visible)
-
getToolTipText
public java.lang.String getToolTipText(java.awt.event.MouseEvent event)
- Overrides:
getToolTipText
in classedu.uci.ics.jung.visualization.VisualizationViewer<V extends VisualVertex,E extends VisualEdge<V>>
-
createVertexMouseInfo
public VertexMouseInfo<V,E> createVertexMouseInfo(java.awt.event.MouseEvent e, V v, java.awt.geom.Point2D vertexBasedClickPoint)
-
dispose
public void dispose()
-
-