Search this API

y.layout.tree
Class TreeReductionStage

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

public class TreeReductionStage
extends AbstractLayoutStage

This stage can be used to layout non-tree structures with a tree layout algorithm. First this stage transforms a graph into a tree or forest by removing some edges. Then it invokes the core layout algorithm on the reduced graph. Finally, it reinserts the hidden non-tree edges to the graph again and optionally routes these edges.

Typical usage:

 TreeLayouter tl = new TreeLayouter();
 TreeReductionStage trs = new TreeReductionStage();
 
 trs.setNonTreeEdgeRouter(new OrganicEdgeRouter());
 trs.setNonTreeEdgeSelectionKey(OrganicEdgeRouter.ROUTE_EDGE_DPKEY);
 
 tl.appendStage(trs);
 new BufferedLayouter(tl).doLayout(graph);
 tl.removeStage(trs);
 

See Also:
OrganicEdgeRouter, OrthogonalEdgeRouter

Field Summary
static Object NON_TREE_EDGES_DPKEY
          DataProvider key that can be used to explicitly mark (some) edges that should not be considered to belong to a tree.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
TreeReductionStage()
           
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Returns true.
 Layouter createStraightlineRouter()
          Creates a layouter that can be used to route all non-tree edges as a single straight-line segment.
 void doLayout(LayoutGraph graph)
          Main layout routine that assigns new layout information to the given graph.
 Layouter getNonTreeEdgeRouter()
          Returns the currently set edge router for non-tree edges.
 Object getNonTreeEdgeSelectionKey()
          Returns the currently set non-tree edge selection key.
protected  void routeNonTreeEdges(LayoutGraph graph, EdgeMap nonTreeEdgeMap)
          Routes the non-tree edges.
 void setNonTreeEdgeRouter(Layouter nonTreeEdgeRouter)
          Sets the edge router for non-tree edges.
 void setNonTreeEdgeSelectionKey(Object nonTreeEdgeSelectionKey)
          Sets the DataProvider key that will be used by the non-tree edge router to determine the set of edges that should be routed.
 
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

NON_TREE_EDGES_DPKEY

public static final Object NON_TREE_EDGES_DPKEY
DataProvider key that can be used to explicitly mark (some) edges that should not be considered to belong to a tree.

Constructor Detail

TreeReductionStage

public TreeReductionStage()
Method Detail

canLayout

public boolean canLayout(LayoutGraph graph)
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.


routeNonTreeEdges

protected void routeNonTreeEdges(LayoutGraph graph,
                                 EdgeMap nonTreeEdgeMap)
Routes the non-tree edges.

Parameters:
graph - graph that can contain tree and non-tree edges.
nonTreeEdgeMap - an edge map that marks all non-tree edges in the graph with boolean value true.

getNonTreeEdgeRouter

public Layouter getNonTreeEdgeRouter()
Returns the currently set edge router for non-tree edges.


setNonTreeEdgeRouter

public void setNonTreeEdgeRouter(Layouter nonTreeEdgeRouter)
Sets the edge router for non-tree edges. Very often, this method should be used in conjunction with setNonTreeEdgeSelectionKey(Object) to control the set of edges that should be handled by the edge router.


getNonTreeEdgeSelectionKey

public Object getNonTreeEdgeSelectionKey()
Returns the currently set non-tree edge selection key.


setNonTreeEdgeSelectionKey

public void setNonTreeEdgeSelectionKey(Object nonTreeEdgeSelectionKey)
Sets the DataProvider key that will be used by the non-tree edge router to determine the set of edges that should be routed.

See Also:
Graph.addDataProvider(Object, DataProvider), setNonTreeEdgeRouter(Layouter)

createStraightlineRouter

public Layouter createStraightlineRouter()
Creates a layouter that can be used to route all non-tree edges as a single straight-line segment.

See Also:
setNonTreeEdgeRouter(Layouter)

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