Package ghidra.graph.viewer.edge

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

java.lang.Object
edu.uci.ics.jung.visualization.renderers.BasicEdgeRenderer<V,E>
ghidra.graph.viewer.edge.VisualEdgeRenderer<V,E>

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

All Implemented Interfaces:
  `edu.uci.ics.jung.visualization.renderers.Renderer.Edge<V,E>`

Direct Known Subclasses:
  `ArticulatedEdgeRenderer`, `VisualGraphEdgeSatelliteRenderer`

public abstract class VisualEdgeRenderer<V extends VisualVertex,E extends VisualEdge<V>> extends edu.uci.ics.jung.visualization.renderers.BasicEdgeRenderer<V,E>
Edge render for the `VisualGraph` system

## Implementation Notes

### Jung Vertex/Edge Rendering

Jung creates shapes for vertices (see `VertexShapeFactory`) that are centered. They do this by getting the width/height of the shape and then creating an x/y value that is half of the width and height, respectively. This has the effect of the vertex appearing centered over its connected edge. We mimic that with our `VisualGraphVertexShapeTransformer` so that our edge rendering code is similar to Jung's.

If we ever decide instead to not center our shapes, then this renderer would have to be updated to itself center the edge shape created herein, like this:

     		Rectangle b1 = s1.getBounds();
    		Rectangle b2 = s2.getBounds();

    		// translate the edge to be centered in the vertex
    		int w1 = b1.width >> 1;
    		int h1 = b1.height >> 1;
    		int w2 = b2.width >> 1;
    		int h2 = b2.height >> 1;

    		float tx1 = x1 + w1;
    		float ty1 = y1 + h1;
    		float tx2 = x2 + w2;
    		float ty2 = y2 + h2;
     		Shape edgeShape = getEdgeShape(rc, graph, e, tx1, ty1, tx2, ty2, isLoop, xs1);

Also, there are other spots in the system where we account for this center that would have to be changed, such as the `AbstractVisualGraphLayout`, which needs the centering offsets to handle vertex clipping.

When painting edges this renderer will paint colors based on the following states: default, emphasized, hovered, focused and selected. A focused edge is one that is part of the path between focused vertices(such as when the vertex is hovered), whereas a selected edge is one that has been selected by the user (see `VisualEdge` for details). An edge is 'emphasized' when the user mouses over the edge (which is when the edge is hovered, not when the vertex is hovered. Each of these states may have a different color that can be changed by calling the various setter methods on this renderer. When painting, these colors are used along with various different strokes to paint in an overlay fashion.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface edu.uci.ics.jung.visualization.renderers.Renderer.Edge

  `edu.uci.ics.jung.visualization.renderers.Renderer.Edge.NOOP`

- ## Field Summary

  ### Fields inherited from class edu.uci.ics.jung.visualization.renderers.BasicEdgeRenderer

  `edgeArrowRenderingSupport`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VisualEdgeRenderer()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `drawSimpleEdge(edu.uci.ics.jung.visualization.RenderContext<V,E> rc, edu.uci.ics.jung.algorithms.layout.Layout<V,E> layout, E e)`
  `protected Shape`
  `getCompactShape(edu.uci.ics.jung.visualization.RenderContext<V,E> rc, edu.uci.ics.jung.algorithms.layout.Layout<V,E> layout, V vertex)`
  Uses the render context to create a compact shape for the given vertex
  `Color`
  `getDrawColor(edu.uci.ics.jung.graph.Graph<V,E> g, E e)`
  Returns the current draw color.
  `abstract Shape`
  `getEdgeShape(edu.uci.ics.jung.visualization.RenderContext<V,E> rc, edu.uci.ics.jung.graph.Graph<V,E> graph, E e, float x1, float y1, float x2, float y2, boolean isLoop, Shape vertexShape)`
  Returns the edge shape for the given points
  `Color`
  `getFocusedColor(edu.uci.ics.jung.graph.Graph<V,E> g, E e)`
  Returns the current color to use when the edge is focused.
  `Shape`
  `getFullShape(edu.uci.ics.jung.visualization.RenderContext<V,E> rc, edu.uci.ics.jung.algorithms.layout.Layout<V,E> layout, V vertex)`
  Uses the render context to create a compact shape for the given vertex
  `Color`
  `getHoveredColor(edu.uci.ics.jung.graph.Graph<V,E> g, E e)`
  Returns the current color to use when the edge is in the hovered path.
  `Color`
  `getSelectedColor(edu.uci.ics.jung.graph.Graph<V,E> g, E e)`
  Returns the current color to use when the edge is selected.
  `protected Shape`
  `getVertexShapeForArrow(edu.uci.ics.jung.visualization.RenderContext<V,E> rc, edu.uci.ics.jung.algorithms.layout.Layout<V,E> layout, V v)`
  `protected boolean`
  `isEmphasiszed(E e)`
  `protected boolean`
  `isInFocusedVertexPath(E e)`
  `protected boolean`
  `isInHoveredVertexPath(E e)`
  `protected boolean`
  `isSelected(E e)`
  `void`
  `setDashingPatternOffset(float dashingPatterOffset)`
  Sets the offset value for painting dashed lines.
  `void`
  `setDrawColorTransformer(com.google.common.base.Function<E,Color> transformer)`
  Sets the color provider to use when drawing this edge.
  `void`
  `setFocusedColorTransformer(com.google.common.base.Function<E,Color> transformer)`
  Sets the color provider to use when drawing this edge when the edge is focused.
  `void`
  `setHoveredColorTransformer(com.google.common.base.Function<E,Color> transformer)`
  Sets the color provider to use when drawing this edge when the edge is in the hovered path.
  `void`
  `setSelectedColorTransformer(com.google.common.base.Function<E,Color> transformer)`
  Sets the color provider to use when drawing this edge when the edge is selected.
  `protected Shape`
  `transformFromLayoutToView(edu.uci.ics.jung.visualization.RenderContext<V,E> rc, edu.uci.ics.jung.algorithms.layout.Layout<V,E> layout, V vertex, Shape shape)`

  ### Methods inherited from class edu.uci.ics.jung.visualization.renderers.BasicEdgeRenderer

  `getEdgeArrowRenderingSupport, paintEdge, prepareFinalEdgeShape, setEdgeArrowRenderingSupport`

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

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

- ## Constructor Details

  - ### VisualEdgeRenderer

    public VisualEdgeRenderer()

- ## Method Details

  - ### setDashingPatternOffset

    public void setDashingPatternOffset(float dashingPatterOffset)
    Sets the offset value for painting dashed lines. This allows clients to animate the lines being drawn for edges in the edge direction.
    Parameters:
      `dashingPatterOffset` - the offset value

  - ### setDrawColorTransformer

    public void setDrawColorTransformer(com.google.common.base.Function<E,Color> transformer)
    Sets the color provider to use when drawing this edge. This is also the color used to paint an 'emphasized' edge.
    Parameters:
      `transformer` - the color provider

  - ### getDrawColor

    public Color getDrawColor(edu.uci.ics.jung.graph.Graph<V,E> g, E e)
    Returns the current draw color. This is also the color used to paint an 'emphasized' edge.
    Parameters:
      `g` - the graph
      `e` - the edge
    Returns:
      the color

  - ### setFocusedColorTransformer

    public void setFocusedColorTransformer(com.google.common.base.Function<E,Color> transformer)
    Sets the color provider to use when drawing this edge when the edge is focused.
    Parameters:
      `transformer` - the color provider

  - ### getFocusedColor

    public Color getFocusedColor(edu.uci.ics.jung.graph.Graph<V,E> g, E e)
    Returns the current color to use when the edge is focused.
    Parameters:
      `g` - the graph
      `e` - the edge
    Returns:
      the color

  - ### setSelectedColorTransformer

    public void setSelectedColorTransformer(com.google.common.base.Function<E,Color> transformer)
    Sets the color provider to use when drawing this edge when the edge is selected.
    Parameters:
      `transformer` - the color provider

  - ### getSelectedColor

    public Color getSelectedColor(edu.uci.ics.jung.graph.Graph<V,E> g, E e)
    Returns the current color to use when the edge is selected.
    Parameters:
      `g` - the graph
      `e` - the edge
    Returns:
      the color

  - ### setHoveredColorTransformer

    public void setHoveredColorTransformer(com.google.common.base.Function<E,Color> transformer)
    Sets the color provider to use when drawing this edge when the edge is in the hovered path.
    Parameters:
      `transformer` - the color provider

  - ### getHoveredColor

    public Color getHoveredColor(edu.uci.ics.jung.graph.Graph<V,E> g, E e)
    Returns the current color to use when the edge is in the hovered path.
    Parameters:
      `g` - the graph
      `e` - the edge
    Returns:
      the color

  - ### isInHoveredVertexPath

    protected boolean isInHoveredVertexPath(E e)

  - ### isInFocusedVertexPath

    protected boolean isInFocusedVertexPath(E e)

  - ### isSelected

    protected boolean isSelected(E e)

  - ### isEmphasiszed

    protected boolean isEmphasiszed(E e)

  - ### drawSimpleEdge

    public void drawSimpleEdge(edu.uci.ics.jung.visualization.RenderContext<V,E> rc, edu.uci.ics.jung.algorithms.layout.Layout<V,E> layout, E e)
    Overrides:
      `drawSimpleEdge` in class `edu.uci.ics.jung.visualization.renderers.BasicEdgeRenderer<V extends VisualVertex,E extends VisualEdge<V>>`

  - ### getVertexShapeForArrow

    protected Shape getVertexShapeForArrow(edu.uci.ics.jung.visualization.RenderContext<V,E> rc, edu.uci.ics.jung.algorithms.layout.Layout<V,E> layout, V v)

  - ### getEdgeShape

    public abstract Shape getEdgeShape(edu.uci.ics.jung.visualization.RenderContext<V,E> rc, edu.uci.ics.jung.graph.Graph<V,E> graph, E e, float x1, float y1, float x2, float y2, boolean isLoop, Shape vertexShape)
    Returns the edge shape for the given points
    Parameters:
      `rc` - the render context for the graph
      `graph` - the graph
      `e` - the edge to shape
      `x1` - the start vertex point x; layout space
      `y1` - the start vertex point y; layout space
      `x2` - the end vertex point x; layout space
      `y2` - the end vertex point y; layout space
      `isLoop` - true if the start == end, which is a self-loop
      `vertexShape` - the vertex shape (used in the case of a loop to draw a circle from the shape to itself)
    Returns:
      the edge shape

  - ### getFullShape

    public Shape getFullShape(edu.uci.ics.jung.visualization.RenderContext<V,E> rc, edu.uci.ics.jung.algorithms.layout.Layout<V,E> layout, V vertex)
    Uses the render context to create a compact shape for the given vertex
    Parameters:
      `rc` - the render context
      `layout` - the layout
      `vertex` - the vertex
    Returns:
      the vertex shape
    See Also:
      - `VertexShapeProvider.getFullShape()`

  - ### getCompactShape

    protected Shape getCompactShape(edu.uci.ics.jung.visualization.RenderContext<V,E> rc, edu.uci.ics.jung.algorithms.layout.Layout<V,E> layout, V vertex)
    Uses the render context to create a compact shape for the given vertex
    Parameters:
      `rc` - the render context
      `layout` - the layout
      `vertex` - the vertex
    Returns:
      the vertex shape
    See Also:
      - `VertexShapeProvider.getCompactShape()`

  - ### transformFromLayoutToView

    protected Shape transformFromLayoutToView(edu.uci.ics.jung.visualization.RenderContext<V,E> rc, edu.uci.ics.jung.algorithms.layout.Layout<V,E> layout, V vertex, Shape shape)