Class VisualGraphPathHighlighter<V extends VisualVertex,​E extends VisualEdge<V>>

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

    public class VisualGraphPathHighlighter<V extends VisualVertex,​E extends VisualEdge<V>>
    extends java.lang.Object
    A class that calculates flow between vertices and then triggers that flow to be painted in the UI.

    Threading Policy: Some operations use algorithms that slow down, depending upon the graph size. Further, some of these algorithms may not even complete. To keep the graph responsive, this class will perform its work in the future. The work we wish to do is further complicated by these requirements:

    • Some data should be calculated only as needed, to avoid excessive work
    • Many tasks depend on data to be calculated before they can perform their algorithm
    • Results must be cached for speed, but may cleared as the graph is mutated
    • Algorithms must not block the UI thread
    • Related actions (i.e., hover vs. selection) should cancel any pending action, but not unrelated actions (e.g., a new hover request should cancel a pending hover update)
    Based on these requirements, we need to use multi-threading. Further complicating the need for multi-threading is that some operations depending on lazy-loaded data. Finally, we have different types of actions, hovering vs. selecting a vertex, which should override previous related requests. To accomplish this we use:
    • CompletableFuture - to lazy-load and cache required algorithm data
    • RunManagers - to queue requests so that new requests cancel old ones. A different Run Manager is used for each type of request.

    Naming Conventions: There are many methods in this class, called from different threads. For simplicity, we use the following conventions:

    • fooAsync - methods ending in Async indicate that they are to be called from a background thread.
    • fooSwing - methods ending in Swing indicate that they are to be called from the Swing thread.
    • *All public methods are assumed to be called on the Swing thread
    • Method Detail

      • setWorkPauser

        public void setWorkPauser​(PathHighlighterWorkPauser pauser)
        Sets the callback that signals when this path highlighter should not be performing any work
        Parameters:
        pauser - the callback that returns a boolean of true when this class should pause its work.
      • stop

        public void stop()
        Signals to this path highlighter that it should stop all background jobs
      • dispose

        public void dispose()
      • isBusy

        public boolean isBusy()
      • getVertexHoverPathHighlightMode

        public PathHighlightMode getVertexHoverPathHighlightMode()
      • getVertexFocusPathHighlightMode

        public PathHighlightMode getVertexFocusPathHighlightMode()
      • setHoveredVertex

        public void setHoveredVertex​(V hoveredVertex)
      • setFocusedVertex

        public void setFocusedVertex​(V focusedVertex)
      • clearEdgeCache

        public void clearEdgeCache()