Package ghidra.graph

Interface VisualGraph<V extends VisualVertex,​E extends VisualEdge<V>>

  • Type Parameters:
    V - the vertex type
    E - the edge type
    All Superinterfaces:
    GDirectedGraph<V,​E>, GImplicitDirectedGraph<V,​E>
    All Known Implementing Classes:
    DefaultVisualGraph, FilteringVisualGraph, GroupingVisualGraph, JungDirectedVisualGraph

    public interface VisualGraph<V extends VisualVertex,​E extends VisualEdge<V>>
    extends GDirectedGraph<V,​E>
    The primary interface for graphs that are to be rendered. This class defines methods commonly used in the GUI while extending the primary non-visual graph interface.

    The Visual Graph API will typically provide services for taking a Visual Graph and creating a UI that handles basic user interaction elements (similar to how complex Java widgets handle user interaction for the developer). The Visual Graph is the model of the UI components. A typical Visual Graph UI will render developer-defined components, handling mouse event translations for the developer.

    Some features found in Visual Graphs:

    • Mouse event translation - the JComponent being rendered in the graph will be handed mouse events that are relative to its coordinate space, not that of the graph.
    • Hover and Selection - vertex hover and selection events are handled by the API
    • Zooming - zoom level and related events (when zoomed too far, mouse events are not passed-through to the component) and handled by the API
    • Method Detail

      • vertexLocationChanged

        void vertexLocationChanged​(V v,
                                   java.awt.Point point,
                                   LayoutListener.ChangeType changeType)
        A callback notifying this graph that the given vertex's location has changed
        Parameters:
        v - the vertex
        point - the new location
        changeType - the type of change
      • getFocusedVertex

        V getFocusedVertex()
        Returns the focused vertex; null if no vertex has focus. Focus is equivalent to being selected, but further distinguishes the vertex as being the only selected vertex. This is useful for key event processing.
        Returns:
        the focused vertex
      • setVertexFocused

        void setVertexFocused​(V v,
                              boolean b)
        Sets the given vertex to be focused or not

        Note: this method is called by other APIs to ensure that the graph's notion of the focused vertex matches what is happening externally (e.g., from the user clicking the screen). If you wish to programmatically focus a vertex, then you should not be calling this API directly, but you should instead be using the GPickedState or one of the APIs that uses that, such as the GraphComponent.

        Parameters:
        v - the focused vertex
        b - true for focused; false for not focused
      • clearSelectedVertices

        void clearSelectedVertices()
        Clears any selected vertices as well as the focused vertex
      • setSelectedVertices

        void setSelectedVertices​(java.util.Set<V> vertices)
        Selects the given vertices

        Note: this method is called by other APIs to ensure that the graph's notion of the focused vertex matches what is happening externally (e.g., from the user clicking the screen). If you wish to programmatically select a vertex, then you should not be calling this API directly, but you should instead be using the GPickedState or one of the APIs that uses that, such as the GraphComponent.

        Parameters:
        vertices - the vertices
      • getSelectedVertices

        java.util.Set<V> getSelectedVertices()
        Returns the selected vertices.
        Returns:
        the selected vertices
      • addGraphChangeListener

        void addGraphChangeListener​(VisualGraphChangeListener<V,​E> l)
        Adds the given listener to this graph
        Parameters:
        l - the listener
      • removeGraphChangeListener

        void removeGraphChangeListener​(VisualGraphChangeListener<V,​E> l)
        Removes the given listener from this graph
        Parameters:
        l - the listener
      • getLayout

        VisualGraphLayout<V,​E> getLayout()
        Returns the layout that has been applied to the graph. The graph does not need its layout to function, but rather it is convenient for the visual graph system to be able to get the layout from the graph, rather than passing the layout everywhere it is needed.
        Returns:
        the layout applied to the graph