Search this API

y.layout
Class EdgeReversalStage

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.EdgeReversalStage
All Implemented Interfaces:
Layouter, LayoutStage

public class EdgeReversalStage
extends AbstractLayoutStage

EdgeReversalStage selectively reverses edges in a graph, while keeping the layout and label positions of the reversed edges as close to the pre-reversal layout and positions as possible.

 

Field Summary
static java.lang.Object REVERSE_EDGES_DPKEY
          A DataProvider key for selecting edges for reversal
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
EdgeReversalStage()
          Creates a new EdgeReversalStage instance with default settings.
EdgeReversalStage(Layouter coreLayouter)
          Creates a new EdgeReversalStage instance using the given algorithm as core layout algorithm.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Accepts all graphs that can be handled by the core layout algorithm.
 void doLayout(LayoutGraph graph)
          Reverses all selected edges before calling the core layout algorithm and restores the original edge direction after the core layout algorithm has finished.
static void findReversedTreeEdges(LayoutGraph graph, Node root, DataAcceptor reversedEdges)
          Marks edges in a tree-structured graph component that need to be reversed to make the specified node the root of the tree component.
 void reverseEdge(LayoutGraph graph, Edge edge)
          Reverses the specified edge in the specified graph.
 void reverseEdges(LayoutGraph graph)
          Reverses selected edges in the specified graph.
 
Methods inherited from class y.layout.AbstractLayoutStage
canLayoutCore, doLayoutCore, getCoreLayouter, setCoreLayouter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVERSE_EDGES_DPKEY

public static final java.lang.Object REVERSE_EDGES_DPKEY
A DataProvider key for selecting edges for reversal

 
If there is no DataProvider registered with this key, all edges are reversed.
Constructor Detail

EdgeReversalStage

public EdgeReversalStage()
Creates a new EdgeReversalStage instance with default settings.


EdgeReversalStage

public EdgeReversalStage(Layouter coreLayouter)
Creates a new EdgeReversalStage instance using the given algorithm as core layout algorithm.

Parameters:
coreLayouter - the core layout algorithm
See Also:
AbstractLayoutStage.setCoreLayouter(Layouter)
Method Detail

canLayout

public boolean canLayout(LayoutGraph graph)
Accepts all graphs that can be handled by the core layout algorithm.

If there is no core layout algorithm, all graphs are accepted.

Parameters:
graph - the input graph
Returns:
true if there is no core layout algorithm or the core layout algorithm accepts the graph, false otherwise
See Also:
Layouter.doLayout(LayoutGraph)

doLayout

public void doLayout(LayoutGraph graph)
Reverses all selected edges before calling the core layout algorithm and restores the original edge direction after the core layout algorithm has finished.

Parameters:
graph - the input graph
See Also:
Layouter.canLayout(LayoutGraph)

reverseEdges

public void reverseEdges(LayoutGraph graph)
Reverses selected edges in the specified graph. Selected edges are marked in a DataProvider registered with REVERSE_EDGES_DPKEY.

Implementation detail: This method calls reverseEdge(LayoutGraph, Edge) in order to reverse a selected edge.

Parameters:
graph - the graph in which to reverse edges.
See Also:
REVERSE_EDGES_DPKEY, reverseEdge(LayoutGraph, Edge)

reverseEdge

public void reverseEdge(LayoutGraph graph,
                        Edge edge)
Reverses the specified edge in the specified graph. The layout of the specified edge is reversed as specified in LayoutTool.reverseEdgeLayout(EdgeLayout). Moreover, the positions of all labels associated with the specified edge are adjusted to match the pre-reversal position as closely as possible. (Depending on a label's model it might not always be possible to achieve an exact match.)

Parameters:
graph - the graph to which the specified edge belongs
edge - the edge to be reversed
See Also:
LayoutTool.reverseEdgeLayout(EdgeLayout)

findReversedTreeEdges

public static void findReversedTreeEdges(LayoutGraph graph,
                                         Node root,
                                         DataAcceptor reversedEdges)
Marks edges in a tree-structured graph component that need to be reversed to make the specified node the root of the tree component. Only edges in the graph component to which the specified node belongs will be marked.

Parameters:
graph - the graph to which the specified node belongs
root - the node to be considered the root of its tree component
reversedEdges - a DataAcceptor to mark edges for reversal
Throws:
java.lang.IllegalArgumentException - if the specified root node is null or does not belong to the specified graph
See Also:
REVERSE_EDGES_DPKEY

© Copyright 2000-2021,
yWorks GmbH.
All rights reserved.