de.cau.cs.kieler.klay.layered.p5edges
Class OrthogonalRoutingGenerator

java.lang.Object
  extended by de.cau.cs.kieler.klay.layered.p5edges.OrthogonalRoutingGenerator

public class OrthogonalRoutingGenerator
extends Object

Edge routing implementation that creates orthogonal bend points. Inspired by

This is a generic implementation that can be applied to all four routing directions. Usually, edges will be routed from west to east. However, with northern and southern external ports, this changes: edges are routed from south to north and north to south, respectively. To support these different requirements, the routing direction-related code is factored out into routing strategies.

When instantiating a new routing generator, the concrete directional strategy must be specified. Once that is done, #routeEdges(LayeredGraph, List, int, List, double) is called repeatedly to route edges between given lists of nodes.

Rating red

Nested Class Summary
static interface OrthogonalRoutingGenerator.IRoutingDirectionStrategy
          A routing direction strategy adapts the OrthogonalRoutingGenerator to different routing directions.
static class OrthogonalRoutingGenerator.NorthToSouthRoutingStrategy
          Routing strategy for routing layers from north to south.
static class OrthogonalRoutingGenerator.SouthToNorthRoutingStrategy
          Routing strategy for routing layers from south to north.
static class OrthogonalRoutingGenerator.WestToEastRoutingStrategy
          Routing strategy for routing layers from west to east.
 
Constructor Summary
OrthogonalRoutingGenerator(OrthogonalRoutingGenerator.IRoutingDirectionStrategy routingStrategy, double edgeSpacing, String debugPrefix)
          Constructs a new instance.
 
Method Summary
 int routeEdges(LayeredGraph layeredGraph, Iterable<LNode> sourceLayerNodes, int sourceLayerIndex, Iterable<LNode> targetLayerNodes, double startPos)
          Route edges between the given layers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrthogonalRoutingGenerator

public OrthogonalRoutingGenerator(OrthogonalRoutingGenerator.IRoutingDirectionStrategy routingStrategy,
                                  double edgeSpacing,
                                  String debugPrefix)
Constructs a new instance.

Parameters:
routingStrategy - the routing strategy to use. This will usually be one of the strategies defined by this class.
edgeSpacing - the space between edges.
debugPrefix - prefix of debug output files, or null if no debug output should be generated.
Method Detail

routeEdges

public int routeEdges(LayeredGraph layeredGraph,
                      Iterable<LNode> sourceLayerNodes,
                      int sourceLayerIndex,
                      Iterable<LNode> targetLayerNodes,
                      double startPos)
Route edges between the given layers.

Parameters:
layeredGraph - the layered graph.
sourceLayerNodes - the left layer. May be null.
sourceLayerIndex - the source layer's index. Ignored if there is no source layer.
targetLayerNodes - the right layer. May be null.
startPos - horizontal position of the first routing slot
Returns:
the number of routing slots for this layer