Class DefaultVisualGraph<V extends VisualVertex,E extends VisualEdge<V>>

java.lang.Object
edu.uci.ics.jung.graph.AbstractGraph<V,E>
edu.uci.ics.jung.graph.AbstractTypedGraph<V,E>
edu.uci.ics.jung.graph.DirectedSparseGraph<V,E>
ghidra.graph.jung.JungDirectedGraph<V,E>
ghidra.graph.graphs.JungDirectedVisualGraph<V,E>
ghidra.graph.graphs.DefaultVisualGraph<V,E>
Type Parameters:
V - the vertex type
E - the edge type
All Implemented Interfaces:
edu.uci.ics.jung.graph.DirectedGraph<V,E>, edu.uci.ics.jung.graph.Graph<V,E>, edu.uci.ics.jung.graph.Hypergraph<V,E>, GDirectedGraph<V,E>, GImplicitDirectedGraph<V,E>, VisualGraph<V,E>, Serializable
Direct Known Subclasses:
FilteringVisualGraph, GroupingVisualGraph

public abstract class DefaultVisualGraph<V extends VisualVertex,E extends VisualEdge<V>> extends JungDirectedVisualGraph<V,E>
A default VisualGraph that implements basic setup for things like event processing.

Notes:

  • Selected Vertices and the Focused Vertex - there can be multiple selected vertices, but only a single focused vertex. getSelectedVertices() will return both the selected vertices or the focused vertex if there are no vertices selected.
  • Clicking a single vertex will focus it. Control-clicking multiple vertices will cause them all to be selected, with no focused vertex.
  • Rendering Edges - edges are rendered with or without articulations if they have them. This is built-in to the default graphing edge renderer. Some layouts require custom edge rendering and will provide their own renderer as needed.
See Also:
  • Field Details

  • Constructor Details

    • DefaultVisualGraph

      public DefaultVisualGraph()
  • Method Details

    • copy

      public abstract DefaultVisualGraph<V,E> copy()
      Description copied from interface: GDirectedGraph
      Copy this graph.

      Note: the vertices and edges in the copy may be the same instances in the new graph and not themselves copies.

      Specified by:
      copy in interface GDirectedGraph<V extends VisualVertex,E extends VisualEdge<V>>
      Specified by:
      copy in interface GImplicitDirectedGraph<V extends VisualVertex,E extends VisualEdge<V>>
      Specified by:
      copy in interface VisualGraph<V extends VisualVertex,E extends VisualEdge<V>>
      Specified by:
      copy in class JungDirectedVisualGraph<V extends VisualVertex,E extends VisualEdge<V>>
      Returns:
      the new copy
    • setSelectedVertices

      public void setSelectedVertices(Set<V> selectedVertices)
      Description copied from interface: VisualGraph
      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:
      selectedVertices - the vertices
    • setVertexFocused

      public void setVertexFocused(V vertex, boolean focused)
      Description copied from interface: VisualGraph
      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:
      vertex - the focused vertex
      focused - true for focused; false for not focused
    • getFocusedVertex

      public V getFocusedVertex()
      Description copied from interface: VisualGraph
      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
    • clearSelectedVertices

      public void clearSelectedVertices()
      Description copied from interface: VisualGraph
      Clears any selected vertices as well as the focused vertex
    • getSelectedVertices

      public Set<V> getSelectedVertices()
      Description copied from interface: VisualGraph
      Returns the selected vertices.
      Returns:
      the selected vertices
    • vertexLocationChanged

      public void vertexLocationChanged(V v, Point point, LayoutListener.ChangeType type)
      Description copied from interface: VisualGraph
      A callback notifying this graph that the given vertex's location has changed
      Parameters:
      v - the vertex
      point - the new location
      type - the type of change
    • dispose

      public void dispose()
    • initializeLocation

      protected void initializeLocation(V v)
    • getAllEdges

      public Iterable<E> getAllEdges(V v)
      A convenience method to combine retrieval of in and out edges for the given vertex
      Parameters:
      v - the vertex
      Returns:
      the edges
    • getEdges

      public Iterable<E> getEdges(V start, V end)
      Returns all edges shared between the two given vertices
      Parameters:
      start - the start vertex
      end - the end vertex
      Returns:
      the edges
    • addVertex

      public boolean addVertex(V v)
      Description copied from interface: GDirectedGraph
      Add a vertex
      Specified by:
      addVertex in interface GDirectedGraph<V extends VisualVertex,E extends VisualEdge<V>>
      Specified by:
      addVertex in interface edu.uci.ics.jung.graph.Hypergraph<V extends VisualVertex,E extends VisualEdge<V>>
      Overrides:
      addVertex in class edu.uci.ics.jung.graph.DirectedSparseGraph<V extends VisualVertex,E extends VisualEdge<V>>
      Parameters:
      v - the vertex
      Returns:
      true if the add was successful, false otherwise
    • addEdge

      public boolean addEdge(E edge, edu.uci.ics.jung.graph.util.Pair<? extends V> endpoints, edu.uci.ics.jung.graph.util.EdgeType edgeType)
      Overrides:
      addEdge in class edu.uci.ics.jung.graph.DirectedSparseGraph<V extends VisualVertex,E extends VisualEdge<V>>
    • removeVertex

      public boolean removeVertex(V v)
      Description copied from interface: GDirectedGraph
      Remove a vertex
      Specified by:
      removeVertex in interface GDirectedGraph<V extends VisualVertex,E extends VisualEdge<V>>
      Specified by:
      removeVertex in interface edu.uci.ics.jung.graph.Hypergraph<V extends VisualVertex,E extends VisualEdge<V>>
      Overrides:
      removeVertex in class edu.uci.ics.jung.graph.DirectedSparseGraph<V extends VisualVertex,E extends VisualEdge<V>>
      Parameters:
      v - the vertex
      Returns:
      true
    • removeVertices

      public void removeVertices(Iterable<V> toRemove)
      Description copied from interface: GDirectedGraph
      Removes the given vertices from the graph
      Specified by:
      removeVertices in interface GDirectedGraph<V extends VisualVertex,E extends VisualEdge<V>>
      Overrides:
      removeVertices in class JungDirectedGraph<V extends VisualVertex,E extends VisualEdge<V>>
      Parameters:
      toRemove - the vertices to remove
    • removeEdge

      public boolean removeEdge(E edge)
      Description copied from interface: GDirectedGraph
      Removes an edge
      Specified by:
      removeEdge in interface GDirectedGraph<V extends VisualVertex,E extends VisualEdge<V>>
      Specified by:
      removeEdge in interface edu.uci.ics.jung.graph.Hypergraph<V extends VisualVertex,E extends VisualEdge<V>>
      Overrides:
      removeEdge in class edu.uci.ics.jung.graph.DirectedSparseGraph<V extends VisualVertex,E extends VisualEdge<V>>
      Parameters:
      edge - the edge
      Returns:
      true if the graph contained the given edge
    • verticesAdded

      protected void verticesAdded(Collection<V> added)
      Called after one or more vertices have been added. The callback will happen after all additions have taken place. This is an extension point for subclasses.
      Parameters:
      added - the added vertices
    • verticesRemoved

      protected void verticesRemoved(Collection<V> removed)
      Called after one or more vertices have been removed. The callback will happen after all removals have taken place. This is an extension point for subclasses.
      Parameters:
      removed - the removed vertices
    • fireVerticesRemoved

      protected void fireVerticesRemoved(Collection<V> removed)
    • fireVerticesAdded

      protected void fireVerticesAdded(Collection<V> added)
    • fireEdgesRemoved

      protected void fireEdgesRemoved(Iterable<E> removed)
    • fireEdgesAdded

      protected void fireEdgesAdded(Iterable<E> added)
    • addGraphChangeListener

      public void addGraphChangeListener(VisualGraphChangeListener<V,E> l)
      Description copied from interface: VisualGraph
      Adds the given listener to this graph
      Parameters:
      l - the listener
    • removeGraphChangeListener

      public void removeGraphChangeListener(VisualGraphChangeListener<V,E> l)
      Description copied from interface: VisualGraph
      Removes the given listener from this graph
      Parameters:
      l - the listener