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

A layout stage that can be used to (selectively) reverse 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 Object REVERSE_EDGES_DPKEY
          This key can be used to select specific edges for reversal.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
EdgeReversalStage()
           
EdgeReversalStage(Layouter core)
           
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Returns true iff the given graph can be laid out by this algorithm.
 void doLayout(LayoutGraph graph)
          Main layout routine that assigns new layout information to the given graph.
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)
          Reverse 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 Object REVERSE_EDGES_DPKEY
This key can be used to select specific edges for reversal. An edge is considered selected in this context, if the corresponding DataProvider returns true for said edge.

Note: If there is no DataProvider for this key, all edges are considered selected.

Constructor Detail

EdgeReversalStage

public EdgeReversalStage()

EdgeReversalStage

public EdgeReversalStage(Layouter core)
Method Detail

canLayout

public boolean canLayout(LayoutGraph graph)
Description copied from interface: Layouter
Returns true iff the given graph can be laid out by this algorithm. Calling doLayout with the given graph as its argument will only success if this method returns true.


doLayout

public void doLayout(LayoutGraph graph)
Description copied from interface: Layouter
Main layout routine that assigns new layout information to the given graph.


reverseEdges

public void reverseEdges(LayoutGraph graph)
Reverses selected edges in the specified graph. An edge is considered selected in this context according to the criteria described for REVERSE_EDGES_DPKEY.

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

Parameters:
graph - the graph in which to reverse edges.
See Also:
REVERSE_EDGES_DPKEY

reverseEdge

public void reverseEdge(LayoutGraph graph,
                        Edge edge)
Reverse 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 to 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.

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. Edges are marked with a boolean true flag.

Throws:
IllegalArgumentException - if the specified node does not belong to the specified graph.
Parameters:
graph - the graph to which the specified node belongs.
root - the node to be considered the root of its tree component.
reversedEdges - a data acceptor that is used to mark edges for reversal.
See Also:
REVERSE_EDGES_DPKEY

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