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 java.lang.Object
implements FromSketchNodePlacer

The DendrogramPlacer arranges subtrees as dendrograms.

Layout Style

This NodePlacer arranges nodes from top to bottom. It arranges subtrees in such a way that all subtrees of a single local root are aligned with their bottom border.

Note: 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()
          Creates a new DendrogramPlacer instance with default settings.
 
Method Summary
 java.util.Comparator createComparator()
          Creates a Comparator that sorts outgoing edges according to the x-coordinate of their target nodes.
 java.util.Comparator createFromSketchComparator()
          Creates a Comparator for the edges which takes the initial x-coordinates of the nodes into account.
 Processor createProcessor(GenericTreeLayouter layouter, LayoutGraph graph, Node currentRoot)
          Creates an optional Processor for pre- and post-processing.
 void determineChildConnectors(Node localRoot, DataMap connectorMap)
          Provides NodePlacer.DIRECTION_NORTH for all children.
 double getMinimumRootDistance()
          Returns the minimum distance between the GenericTreeLayouter.SubtreeShape of a root node and the bus connecting to all of its children.
 double getMinimumSubtreeDistance()
          Returns the minimum horizontal distance between adjacent SubtreeShapes.
 GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider, DataProvider subtreeShapeProvider, LayoutGraph graph, Node localRoot, byte parentConnectorDirection)
          Arranges the SubtreeShapes of the local root and its children as a dendrogram.
 void setMinimumRootDistance(double minimumRootDistance)
          Specifies the minimum distance between the GenericTreeLayouter.SubtreeShape of a root node and the bus connecting to all of its children.
 void setMinimumSubtreeDistance(double minimumSubtreeDistance)
          Specifies the minimum horizontal distance between adjacent SubtreeShapes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DendrogramPlacer

public DendrogramPlacer()
Creates a new DendrogramPlacer instance with default settings.

Method Detail

getMinimumRootDistance

public double getMinimumRootDistance()
Returns the minimum distance between the GenericTreeLayouter.SubtreeShape of a root node and the bus connecting to all of its children.

The distance needs to be non-negative.

Returns:
the minimum distance between the root and the bus
See Also:
setMinimumRootDistance(double)

setMinimumRootDistance

public void setMinimumRootDistance(double minimumRootDistance)
Specifies the minimum distance between the GenericTreeLayouter.SubtreeShape of a root node and the bus connecting to all of its children.

The distance needs to be non-negative.

Default Value:
The default value is 30.
Parameters:
minimumRootDistance - the minimum distance between the root and the bus
Throws:
java.lang.IllegalArgumentException - if the specified distance is negative
Sample Graphs:

30

60

getMinimumSubtreeDistance

public double getMinimumSubtreeDistance()
Returns the minimum horizontal distance between adjacent SubtreeShapes.

The distance needs to be non-negative.

Returns:
the minimum distance between two adjacent GenericTreeLayouter.SubtreeShapes
See Also:
setMinimumSubtreeDistance(double)

setMinimumSubtreeDistance

public void setMinimumSubtreeDistance(double minimumSubtreeDistance)
Specifies the minimum horizontal distance between adjacent SubtreeShapes.

The distance needs to be non-negative.

Default Value:
The default value is 30.
Parameters:
minimumSubtreeDistance - the minimum distance between two adjacent GenericTreeLayouter.SubtreeShapes
Throws:
java.lang.IllegalArgumentException - if the specified distance is negative
Sample Graphs:

30

60

determineChildConnectors

public void determineChildConnectors(Node localRoot,
                                     DataMap connectorMap)
Provides NodePlacer.DIRECTION_NORTH for all children. Edges will always connect to the top of the child nodes.

Specified by:
determineChildConnectors in interface NodePlacer
Parameters:
localRoot - the local root node
connectorMap - the map that is used for storing the direction specifiers of the child nodes

createComparator

public java.util.Comparator createComparator()
Creates a Comparator that sorts outgoing edges according to the x-coordinate of their target nodes. This Comparator can be used for achieving a From Sketch layout.

Returns:
the Comparator
See Also:
createFromSketchComparator()

placeSubtree

public GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider,
                                                     DataProvider subtreeShapeProvider,
                                                     LayoutGraph graph,
                                                     Node localRoot,
                                                     byte parentConnectorDirection)
Arranges the SubtreeShapes of the local root and its children as a dendrogram.

Specified by:
placeSubtree in interface NodePlacer
Parameters:
nodeShapeProvider - the DataProvider for obtaining an initial shape of the root node
subtreeShapeProvider - the DataProvider for accessing the pre-calculated shapes of the subtrees
graph - the input graph
localRoot - the root of the subtree that should be arranged by this method
parentConnectorDirection - the direction specifier for the connector of the local root node to its parent node
Returns:
the combined shape of the whole subtree rooted at the given local root node

createProcessor

public Processor createProcessor(GenericTreeLayouter layouter,
                                 LayoutGraph graph,
                                 Node currentRoot)
Creates an optional Processor for pre- and post-processing.

This implementation returns null. Hence, no pre- or post-processing is done.

Specified by:
createProcessor in interface NodePlacer
Parameters:
layouter - the current GenericTreeLayouter instance
graph - the input graph
currentRoot - the root node handled by this NodePlacer
Returns:
null

createFromSketchComparator

public java.util.Comparator createFromSketchComparator()
Creates a Comparator for the edges which takes the initial x-coordinates of the nodes into account.

This implementation delegates to createComparator().

Specified by:
createFromSketchComparator in interface FromSketchNodePlacer
Returns:
the Comparator for the edges
See Also:
createComparator()

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