org.graffiti.plugins.algorithms.reingoldtilford
Interface EdgeLayoutStrategy

All Known Implementing Classes:
BottomCenterToTopCenterEdgeLayoutStrategy, BusEdgeLayoutStrategy, CenterToCenterEdgeLayoutStrategy

public interface EdgeLayoutStrategy

Defines an interface for classes that know how to lay out edges connecting a node with its subtrees.

To provide a new edge layout, create a class implementing EdgeLayoutStrategy.

 public class MyEdgeLayoutStrategy implements EdgeLayoutStrategy {
     public void calculateContours(Tree tree, ReingoldTilfordAlgorithm algorithm)
     {
         BasicContourNodeList oldLeftContour = tree.getLeftContour();
         BasicContourNodeList oldRightContour = tree.getRightContour();
         BasicContourNodeList newLeftContour = new BasicContourNodeList();
         BasicContourNodeList newRightContour = new BasicContourNodeList();
         
         // Build the contour lines enclosing the root node...
         newLeftContour.addNode(...);
         ...
         
         // Include the contour lines of the combined subtrees.
         newLeftContour.getLast().connectToLeftContour(oldLeftContour, ...);
         newRightContour.getLast().connectToRightContour(oldRightContour, ...);
         
         // Set the new contours.
         tree.setLeftContour(newLeftContour);
         tree.setRightContour(newRightContour);
     }
 
     public void layEdges(Tree tree, double xOrigin, double yOrigin, ReingoldTilfordAlgorithm algorithm)
     {
         Node node = tree.getNode();
         for (Tree child : children)
         {
             Edge edge = child.getEdge();
             
             // Add ports and bends.
             ...
         }
     }
 }
 
and add a new member to the EdgeLayout enumeration.
 enum EdgeLayout
 {
     ...
     BOTTOM_TO_TOP(new CenterToCenterEdgeLayoutStrategy(true, true), "Bottom to top"),
     MY_EDGE_LAYOUT(new MyEdgeLayoutStrategy(), "My edge layout"); //<-- Add this line
     ...
 }
 

Version:
$Revision$ $Date$
Author:
Andreas Gleißner
See Also:
EdgeLayout, Tree

Method Summary
 void calculateContours(Tree tree, ReingoldTilfordAlgorithm algorithm)
          Creates and sets the contours of tree.
 void layEdges(Tree tree, double xOrigin, double yOrigin, ReingoldTilfordAlgorithm algorithm)
          Sets the ports and bends for the edges connecting the root node of tree with its subtrees.
 

Method Detail

calculateContours

void calculateContours(Tree tree,
                       ReingoldTilfordAlgorithm algorithm)
Creates and sets the contours of tree.
Preconditions:
tree must contain at least 1 child.
The children of tree have been combined.

Parameters:
tree - the tree whose contours are set.
algorithm - the Reingold-Tilford algorithm.
See Also:
EdgeLayout.calculateContours(Tree, ReingoldTilfordAlgorithm)

layEdges

void layEdges(Tree tree,
              double xOrigin,
              double yOrigin,
              ReingoldTilfordAlgorithm algorithm)
Sets the ports and bends for the edges connecting the root node of tree with its subtrees. Implementing methods must not directly query or set coordinates but rather use the methods ReingoldTilfordAlgorithm.createPort(String, double, double) and ReingoldTilfordAlgorithm.createCoordinateAttribute(String, double, double) .

Parameters:
tree - the tree layout whose edges are layed out.
xOrigin - the absolute x-coordinate of tree within the coordinate system of Gravisto.
yOrigin - the absolute x-coordinate of tree within the coordinate system of Gravisto.
algorithm - the Reingold-Tilford algorithm.
See Also:
Orientation, EdgeLayout.layEdges(Tree, double, double, ReingoldTilfordAlgorithm)


Generated at 2012-05-30 11:01:25 PM CEST