Search this API

y.layout.tree
Class DendrogramPlacer

java.lang.Object
  extended by y.layout.tree.DendrogramPlacer
All Implemented Interfaces:
FromSketchNodePlacer, NodePlacer

public class DendrogramPlacer
extends Object
implements FromSketchNodePlacer

This is an implementation of the NodePlacer interface that can be used to create dendrogram-like tree layouts. This placer arranges nodes from top to bottom. It arranges subtrees in such a way that all subtrees of a single local root align at their bottom border. This implementation does not support PortConstraints.


Field Summary
 
Fields inherited from interface y.layout.tree.NodePlacer
DIRECTION_ANY, DIRECTION_EAST, DIRECTION_NONE, DIRECTION_NORTH, DIRECTION_SOUTH, DIRECTION_WEST
 
Constructor Summary
DendrogramPlacer()
           
 
Method Summary
 Comparator createComparator()
          Creates a comparator that can be used to do a from sketch layout.
 Comparator createFromSketchComparator()
          Creates a comparator for edges.
 Processor createProcessor(GenericTreeLayouter layouter, LayoutGraph graph, Node currentRoot)
          Creates an optional Processor for pre- and post-processing.
 void determineChildConnectors(Node localRoot, DataMap connectorMap)
          This method is called by GenericTreeLayouter before the subtree shapes of this local root node's children are calculated.
 double getMinimumRootDistance()
          Returns the distance between the root shape and the bus connecting all of its subtrees.
 double getMinimumSubtreeDistance()
          Returns the distance between two adjacent subtree shapes.
 GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider, DataProvider subtreeShapeProvider, LayoutGraph graph, Node localRoot, byte parentConnectorDirection)
          The main method of the tree layout algorithm.
 void setMinimumRootDistance(double minimumRootDistance)
          Sets the distance between the root shape and the bus connecting all of its subtrees.
 void setMinimumSubtreeDistance(double minimumSubtreeDistance)
          Sets the distance between two adjacent subtree shapes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DendrogramPlacer

public DendrogramPlacer()
Method Detail

getMinimumRootDistance

public double getMinimumRootDistance()
Returns the distance between the root shape and the bus connecting all of its subtrees. The default is 30.

Returns:
the distance between the root and the subtree bus.

setMinimumRootDistance

public void setMinimumRootDistance(double minimumRootDistance)
Sets the distance between the root shape and the bus connecting all of its subtrees. The default is 30.

Parameters:
minimumRootDistance - the distance between the root and the subtree bus.

getMinimumSubtreeDistance

public double getMinimumSubtreeDistance()
Returns the distance between two adjacent subtree shapes. The default is 30.

Returns:
the horizontal distance between two subtree shapes.

setMinimumSubtreeDistance

public void setMinimumSubtreeDistance(double minimumSubtreeDistance)
Sets the distance between two adjacent subtree shapes. The default is 30.

Parameters:
minimumSubtreeDistance - the horizontal distance between two subtree shapes.

determineChildConnectors

public void determineChildConnectors(Node localRoot,
                                     DataMap connectorMap)
Description copied from interface: NodePlacer
This method is called by GenericTreeLayouter before the subtree shapes of this local root node's children are calculated. This method must provide for each child node a byte constant indicating the preferred direction of the connector to the subtree shape.

Specified by:
determineChildConnectors in interface NodePlacer
Parameters:
localRoot - the local root node whose child nodes will be provided with a byte constant indicating the direction of the connector
connectorMap - the map that should be used for storing the byte constant with the child nodes.

createComparator

public Comparator createComparator()
Creates a comparator that can be used to do a from sketch layout. If this instance is used for the root node's GenericTreeLayouter.CHILD_COMPARATOR_DPKEY this implementation will do a from sketch layout.

Returns:
the comparator implementation to use to simulate from sketch layout

placeSubtree

public GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider,
                                                     DataProvider subtreeShapeProvider,
                                                     LayoutGraph graph,
                                                     Node localRoot,
                                                     byte parentConnectorDirection)
Description copied from interface: NodePlacer
The main method of the tree layout algorithm. This method arranges the SubtreeShapes and the shape of the local root, routes the edges to the SubtreeShapes, calculates the resulting SubtreeShape and returns it.

Specified by:
placeSubtree in interface NodePlacer
Parameters:
nodeShapeProvider - this instance can be used to obtain an initial shape of the root node. This shape can then be merged with all the subtrees' shapes and finally be returned by this method.
subtreeShapeProvider - provides access to the pre-calculated shapes of the subtrees. It is guaranteed that at the time of the invocation of this method for every child node the subtree shape has already been calculated
graph - the graph which is to be laid out
localRoot - the root of the subtree that should be laid out by this method
parentConnectorDirection - the direction byte constant as it is defined in this interface, that must be used for initializing the connector of the localRoot node to the parent node of the localRoot node
Returns:
the shape of the whole subtree

createProcessor

public Processor createProcessor(GenericTreeLayouter layouter,
                                 LayoutGraph graph,
                                 Node currentRoot)
Description copied from interface: NodePlacer
Creates an optional Processor for pre- and post-processing.

Specified by:
createProcessor in interface NodePlacer
graph - the actual graph
currentRoot - the actual root node for this node placer
Returns:
a Processor or null

createFromSketchComparator

public Comparator createFromSketchComparator()
Description copied from interface: FromSketchNodePlacer
Creates a comparator for edges. This comparator is used to sort the outgoing edges of a node before the placement of the node's subtree is calculated.

Specified by:
createFromSketchComparator in interface FromSketchNodePlacer
Returns:
a comparator for edges.

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