Search this API

y.layout.tree
Class DoubleLinePlacer

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

public class DoubleLinePlacer
extends AbstractRotatableNodePlacer

The DoubleLinePlacer arranges the children of a local root alternating in two lines.

Layout Style

This NodePlacer arranges nodes from top to bottom. It places the subtrees in two horizontal lines below the root. They are distributed in an alternating fashion, i.e., adjacent subtrees are in different lines.

This node placer is especially useful for leaves with a large width.

 

Nested Class Summary
 
Nested classes/interfaces inherited from class y.layout.tree.AbstractRotatableNodePlacer
AbstractRotatableNodePlacer.Matrix, AbstractRotatableNodePlacer.RootAlignment
 
Field Summary
 
Fields inherited from class y.layout.tree.AbstractRotatableNodePlacer
createdChildren, graph, modificationMatrix, nodeShapeProvider, spacing, subtreeShapeProvider
 
Fields inherited from interface y.layout.tree.NodePlacer
DIRECTION_ANY, DIRECTION_EAST, DIRECTION_NONE, DIRECTION_NORTH, DIRECTION_SOUTH, DIRECTION_WEST
 
Constructor Summary
DoubleLinePlacer()
          Creates a new DoubleLinePlacer instance with the default settings.
DoubleLinePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
          Creates a new DoubleLinePlacer instance whose direction is specified by the given modification matrix.
 
Method Summary
protected  byte determineChildConnector(Node child)
          Returns NodePlacer.DIRECTION_NORTH for every given child node.
 double getDoubleLineSpacingRatio()
          Returns the ratio of the spacing between the root and the children in the upper line and the spacing between the two lines of subtrees.
 AbstractRotatableNodePlacer.RootAlignment getRootAlignment()
          Returns the RootAlginment that defines how the root node is aligned with its children and their shapes.
protected  y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot, byte parentConnectorDirection)
          Places the children of the given local root alternating in two horizontal lines.
 void setDoubleLineSpacingRatio(double ratio)
          Specifies the ratio of the spacing between the root and the children in the upper line and the spacing between the two lines of subtrees.
 void setRootAlignment(AbstractRotatableNodePlacer.RootAlignment rootAlignment)
          Specifies the RootAlginment that defines how the root node is aligned with its children and their shapes.
 
Methods inherited from class y.layout.tree.AbstractRotatableNodePlacer
createComparator, createFromSketchComparator, createProcessor, createRootNodeShape, createSubtreeShape, determineChildConnectors, getModificationMatrix, getPortConstraint, getSourcePointAbs, getSpacing, placeSubtree, setSpacing, translateDirectionToModel, translateDirectionToReal, translatePoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DoubleLinePlacer

public DoubleLinePlacer()
Creates a new DoubleLinePlacer instance with the default settings.


DoubleLinePlacer

public DoubleLinePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
Creates a new DoubleLinePlacer instance whose direction is specified by the given modification matrix.

Parameters:
modificationMatrix - the transformation matrix for this AbstractRotatableNodePlacer
Throws:
java.lang.IllegalArgumentException - if the given transformation matrix is null
Method Detail

determineChildConnector

protected byte determineChildConnector(Node child)
Returns NodePlacer.DIRECTION_NORTH for every given child node. Edges always connect to the top of the child nodes.

Specified by:
determineChildConnector in class AbstractRotatableNodePlacer
Parameters:
child - the child node
Returns:
NodePlacer.DIRECTION_NORTH

placeSubtree

protected y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot,
                                                         byte parentConnectorDirection)
Places the children of the given local root alternating in two horizontal lines.

Specified by:
placeSubtree in class AbstractRotatableNodePlacer
Parameters:
localRoot - the local root node
parentConnectorDirection - the direction specifier for the connector of the local root node to its parent node
Returns:
the merged subtree shape that contains the local root node and all its children

getRootAlignment

public AbstractRotatableNodePlacer.RootAlignment getRootAlignment()
Returns the RootAlginment that defines how the root node is aligned with its children and their shapes.

Returns:
the AbstractRotatableNodePlacer.RootAlignment instance specifying the location relative to the subtrees
See Also:
setRootAlignment(AbstractRotatableNodePlacer.RootAlignment)

setRootAlignment

public void setRootAlignment(AbstractRotatableNodePlacer.RootAlignment rootAlignment)
Specifies the RootAlginment that defines how the root node is aligned with its children and their shapes.

Default Value:
The default value is AbstractRotatableNodePlacer.RootAlignment.CENTER
Parameters:
rootAlignment - the AbstractRotatableNodePlacer.RootAlignment instance specifying the location relative to the subtrees
Throws:
java.lang.IllegalArgumentException - if the given root alignment is null

getDoubleLineSpacingRatio

public double getDoubleLineSpacingRatio()
Returns the ratio of the spacing between the root and the children in the upper line and the spacing between the two lines of subtrees.

 
Negative ratios will lead to node overlaps.
Returns:
the ratio to determine the spacing between the two lines of subtrees
See Also:
setDoubleLineSpacingRatio(double)

setDoubleLineSpacingRatio

public void setDoubleLineSpacingRatio(double ratio)
Specifies the ratio of the spacing between the root and the children in the upper line and the spacing between the two lines of subtrees.

 
Negative ratios will lead to node overlaps.
Default Value:
The default value is 0.33. The distance between the two lines of subtrees is a third of the distance between the root and the upper line.
Parameters:
ratio - the ratio to determine the spacing between the two lines of subtrees
Sample Graphs:

0.33

When the ratio is 1, all nodes have equal horizontal distances

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