Search this API

y.layout.tree
Class DefaultNodePlacer

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

public class DefaultNodePlacer
extends AbstractNodePlacer
implements FromSketchNodePlacer, java.lang.Cloneable

DefaultNodePlacer is the default implementation of interface NodePlacer.

Layout Style

With its default settings, this placer generates tree layouts with orthogonal edge routes and child nodes that are placed next to each other and below their parent node.


Example layout using default settings

The layout style can be customized in several ways. Subtrees sharing the same local root node are either placed above or below each other.


Example using customized settings: each layer in the tree uses different configurations of DefaultNodePlacer

Features

GenericTreeLayouter.SubtreeShapes can be arranged in each main direction specified in setChildPlacement(byte). That way, the subtrees of the same graph can have different directions.

This node placer aligns the local root node according to a chosen alignment.

There are various routing styles that result in different edge routes.

 

Field Summary
static byte ALIGNMENT_CENTER
          Alignment specifier which defines that the root node is placed aligned with the center of its subtrees.
static byte ALIGNMENT_LEADING
          Alignment specifier which defines that the root node is placed aligned with its first subtree.
static byte ALIGNMENT_LEADING_OFFSET
          Alignment specifier which defines that the root node is placed ahead of all its child subtrees.
static byte ALIGNMENT_LEADING_ON_BUS
          Alignment specifier which defines that the root is placed ahead of all its subtrees, centered on the bus.
static byte ALIGNMENT_MEDIAN
          Alignment specifier which defines that the root node is placed at the median of the connection points to its subtrees.
static byte ALIGNMENT_TRAILING
          Alignment specifier which defines that the root node is placed aligned with its last subtree.
static byte ALIGNMENT_TRAILING_OFFSET
          Alignment specifier which defines that the root is placed after all its subtree.
static byte ALIGNMENT_TRAILING_ON_BUS
          Alignment specifier which defines that the root is placed after all its subtrees, centered on the bus.
static byte PLACEMENT_HORIZONTAL_DOWNWARD
          Placement specifier which defines that subtrees are placed horizontally next to each other and below the root node.
static byte PLACEMENT_HORIZONTAL_UPWARD
          Placement specifier which defines that subtrees are placed horizontally next to each other and above the root node.
static byte PLACEMENT_VERTICAL_TO_LEFT
          Placement specifier which defines that subtrees are placed one below the other and left of the root node.
static byte PLACEMENT_VERTICAL_TO_RIGHT
          Placement specifier which defines that subtrees are placed one below the other and right of the root node.
static byte ROUTING_FORK
          Routing style specifier which defines that edge paths are routed orthogonally with the bends located in the channel between the root node and the child nodes.
static byte ROUTING_FORK_AT_ROOT
          Routing style specifier which defines that edge paths are routed orthogonally with just one bend.
static byte ROUTING_POLY_LINE
          Routing style constant which defines that edge paths are routed with a straight segment to the connector of the GenericTreeLayouter.SubtreeShape of the child nodes.
static byte ROUTING_STRAIGHT
          Routing style specifier which defines that edge paths are routed with a straight segment to the center of the child nodes.
 
Fields inherited from class y.layout.tree.AbstractNodePlacer
graph
 
Fields inherited from interface y.layout.tree.NodePlacer
DIRECTION_ANY, DIRECTION_EAST, DIRECTION_NONE, DIRECTION_NORTH, DIRECTION_SOUTH, DIRECTION_WEST
 
Constructor Summary
DefaultNodePlacer()
          Creates a new DefaultNodePlacer instance with default settings.
DefaultNodePlacer(byte childPlacement, byte rootAlignment, byte routingStyle, double verticalDistance, double horizontalDistance)
          Creates a new DefaultNodePlacer instance with customized child placement, root alignment, routing style, vertical and horizontal distance.
DefaultNodePlacer(byte childPlacement, byte rootAlignment, byte routingStyle, double verticalDistance, double horizontalDistance, double minFirstSegmentLength, double minLastSegmentLength, double minSlope, double minSlopeHeight)
          Creates a new DefaultNodePlacer instance with custom settings.
DefaultNodePlacer(byte childPlacement, byte rootAlignment, double verticalDistance, double horizontalDistance)
          Creates a new DefaultNodePlacer instance with customized child placement, root alignment, vertical and horizontal distance.
DefaultNodePlacer(byte childPlacement, double verticalDistance, double horizontalDistance)
          Creates a new DefaultNodePlacer instance with customized child placement, vertical and horizontal distance.
 
Method Summary
protected  void calcParentConnector(LayoutGraph graph, Node localRoot, NodeLayout rootLayout, GenericTreeLayouter.SubtreeShape subtreeShape, Edge parentEdge, EdgeLayout parentEdgeLayout, byte direction)
          Calculates the bends for the connector to the parent node.
protected  void calcSlopedSourceEdgeLayout(NodeLayout rootLayout, GenericTreeLayouter.SubtreeShape childShape, Edge edge, double childForkCoordinate, double rootForkCoordinate)
          Calculates the routing of the source side of the edge to the given child node.
protected  void calcSourceEdgeLayout(NodeLayout rootLayout, GenericTreeLayouter.SubtreeShape childShape, Edge edge)
          Calculates the routing of the source side of the edge to the given child node.
protected  void calcTargetEdgeLayout(NodeLayout rootLayout, GenericTreeLayouter.SubtreeShape childShape, Edge edge)
          Calculates the routing of the target side of the edge to the given child node.
 java.util.Comparator createComparator()
          Creates a Comparator for outgoing edges which takes the initial coordinates of the edges' targets into account.
 java.util.Comparator createFromSketchComparator()
          Delegates to createComparator().
protected  byte determineChildConnector(Node child)
          Determines a connector direction for the given child node depending on the selected child placement.
 byte getChildPlacement()
          Returns the direction in which the child nodes are placed with respect to their parent node.
 double getHorizontalDistance()
          Returns the horizontal distance between nodes or GenericTreeLayouter.SubtreeShapes.
 double getMinFirstSegmentLength()
          Returns the minimum length for the first segment of an edge.
 double getMinimumChannelSegmentDistance()
          Returns the minimum (non-negative) distance between edge segments that are routed orthogonally in the channel between the root node and the child nodes (see ROUTING_FORK).
 double getMinLastSegmentLength()
          Returns the minimum length for the last segment of an edge.
 double getMinSlope()
          Returns the minimum slope of the edge segments.
 double getMinSlopeHeight()
          Returns the minimum height for sloped edge segments.
 byte getRootAlignment()
          Returns how the root node is aligned with its children and their GenericTreeLayouter.SubtreeShapes.
 byte getRoutingStyle()
          Returns the style in which edge paths are routed.
 double getVerticalAlignment()
          Returns the relative vertical alignment of nodes with the same parent.
 double getVerticalDistance()
          Returns the vertical distance between nodes or GenericTreeLayouter.SubtreeShapes.
protected  GenericTreeLayouter.SubtreeShape placeSubtree(Node localRoot, byte parentConnectorDirection)
          Arranges the root node and its children.
 void setChildPlacement(byte childPlacement)
          Specifies the direction in which the child nodes are placed with respect to their parent node.
 void setHorizontalDistance(double horizontalDistance)
          Specifies the horizontal distance between nodes or GenericTreeLayouter.SubtreeShapes.
 void setMinFirstSegmentLength(double minFirstSegmentLength)
          Specifies the minimum length for the first segment of an edge.
 void setMinimumChannelSegmentDistance(double minimumChannelSegmentDistance)
          Specifies the minimum (non-negative) distance between edge segments that are routed orthogonally in the channel between the root node and the child nodes (see ROUTING_FORK).
 void setMinLastSegmentLength(double minLastSegmentLength)
          Specifies the minimum length for the last segment of an edge.
 void setMinSlope(double minSlope)
          Specifies the minimum slope of the edge segments.
 void setMinSlopeHeight(double minSlopeHeight)
          Specifies the minimum height for sloped edge segments.
 void setRootAlignment(byte rootAlignment)
          Specifies how the root node is aligned with its children and their GenericTreeLayouter.SubtreeShapes.
 void setRoutingStyle(byte routingStyle)
          Specifies the style in which edge paths are routed.
 void setVerticalAlignment(double verticalAlignment)
          Specifies the relative vertical alignment of nodes with the same parent.
 void setVerticalDistance(double verticalDistance)
          Specifies the vertical distance between nodes or GenericTreeLayouter.SubtreeShapes.
 
Methods inherited from class y.layout.tree.AbstractNodePlacer
clone, createProcessor, determineChildConnectors, getNodeShape, getSubtreeShape, placeSubtree
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface y.layout.tree.NodePlacer
createProcessor, determineChildConnectors, placeSubtree
 

Field Detail

PLACEMENT_VERTICAL_TO_LEFT

public static final byte PLACEMENT_VERTICAL_TO_LEFT
Placement specifier which defines that subtrees are placed one below the other and left of the root node.

See Also:
setChildPlacement(byte), Constant Field Values
Sample Graph:

Child placement left of the root node

PLACEMENT_VERTICAL_TO_RIGHT

public static final byte PLACEMENT_VERTICAL_TO_RIGHT
Placement specifier which defines that subtrees are placed one below the other and right of the root node.

See Also:
setChildPlacement(byte), Constant Field Values
Sample Graph:

Child placement right of the root node

PLACEMENT_HORIZONTAL_UPWARD

public static final byte PLACEMENT_HORIZONTAL_UPWARD
Placement specifier which defines that subtrees are placed horizontally next to each other and above the root node.

See Also:
setChildPlacement(byte), Constant Field Values
Sample Graph:

Child placement above the root node

PLACEMENT_HORIZONTAL_DOWNWARD

public static final byte PLACEMENT_HORIZONTAL_DOWNWARD
Placement specifier which defines that subtrees are placed horizontally next to each other and below the root node.

See Also:
setChildPlacement(byte), Constant Field Values
Sample Graph:

Child placement below the root node

ALIGNMENT_LEADING_OFFSET

public static final byte ALIGNMENT_LEADING_OFFSET
Alignment specifier which defines that the root node is placed ahead of all its child subtrees.

Depending on the child placement, the root node is placed ahead (e.g. PLACEMENT_HORIZONTAL_DOWNWARD: left) of the combined bounding box of all subtrees without labels.

See Also:
setRootAlignment(byte), Constant Field Values
Sample Graph:

Root node is placed left of its children

ALIGNMENT_LEADING

public static final byte ALIGNMENT_LEADING
Alignment specifier which defines that the root node is placed aligned with its first subtree.

Depending on the child placement, the root node is placed aligned with the bounding box of its first (e.g. PLACEMENT_HORIZONTAL_DOWNWARD: left) subtree.

See Also:
setRootAlignment(byte), Constant Field Values
Sample Graph:

Root node is left-aligned with the leftmost node

ALIGNMENT_CENTER

public static final byte ALIGNMENT_CENTER
Alignment specifier which defines that the root node is placed aligned with the center of its subtrees.

See Also:
setRootAlignment(byte), Constant Field Values
Sample Graph:

Root node is center-aligned

ALIGNMENT_MEDIAN

public static final byte ALIGNMENT_MEDIAN
Alignment specifier which defines that the root node is placed at the median of the connection points to its subtrees.

See Also:
setRootAlignment(byte), Constant Field Values
Sample Graph:

Root node is aligned with the median child

ALIGNMENT_TRAILING

public static final byte ALIGNMENT_TRAILING
Alignment specifier which defines that the root node is placed aligned with its last subtree.

Depending on the child placement, the root node is placed aligned with the bounding box of its last (e.g. PLACEMENT_HORIZONTAL_DOWNWARD: right) subtree.

See Also:
setRootAlignment(byte), Constant Field Values
Sample Graph:

Root node is right-aligned with the leftmost node

ALIGNMENT_TRAILING_OFFSET

public static final byte ALIGNMENT_TRAILING_OFFSET
Alignment specifier which defines that the root is placed after all its subtree.

Depending on the child placement, the root node is placed after (e.g. PLACEMENT_HORIZONTAL_DOWNWARD: right) of the combined bounding box of all subtrees without labels.

See Also:
setRootAlignment(byte), Constant Field Values
Sample Graph:

Root node is placed right of its children

ALIGNMENT_TRAILING_ON_BUS

public static final byte ALIGNMENT_TRAILING_ON_BUS
Alignment specifier which defines that the root is placed after all its subtrees, centered on the bus.

Depending on the child placement, the root node is placed after (e.g. PLACEMENT_HORIZONTAL_DOWNWARD: right) of the combined bounding box of all subtrees without labels. The bus leaves directly from the root node.

 
If there are PortConstraints at source, the edge may bend inside the node to connect to the bus.
See Also:
setRootAlignment(byte), Constant Field Values
Sample Graph:

Root node is placed on the bus and right of its children

ALIGNMENT_LEADING_ON_BUS

public static final byte ALIGNMENT_LEADING_ON_BUS
Alignment specifier which defines that the root is placed ahead of all its subtrees, centered on the bus.

Depending on the child placement, the root node is placed ahead (e.g. PLACEMENT_HORIZONTAL_DOWNWARD: left) of the combined bounding box of all subtrees without labels. The bus leaves directly from the root node.

 
If there are PortConstraints at source, the edge may bend inside the node to connect to the bus.
See Also:
setRootAlignment(byte), Constant Field Values
Sample Graph:

Root node is placed on the bus and left of its children

ROUTING_FORK

public static final byte ROUTING_FORK
Routing style specifier which defines that edge paths are routed orthogonally with the bends located in the channel between the root node and the child nodes.

See Also:
setRoutingStyle(byte), Constant Field Values
Sample Graph:

Edges are forked between the root node and its children

ROUTING_FORK_AT_ROOT

public static final byte ROUTING_FORK_AT_ROOT
Routing style specifier which defines that edge paths are routed orthogonally with just one bend.

Edges will leave the root node at its sides and bend exactly above the according child node. If the child node is placed directly below the root node, the edge will bend inside of the root node and leave it at the bottom.

See Also:
setRoutingStyle(byte), Constant Field Values
Sample Graph:

Edges bend just once

ROUTING_STRAIGHT

public static final byte ROUTING_STRAIGHT
Routing style specifier which defines that edge paths are routed with a straight segment to the center of the child nodes.

 
Edges may overlap with nodes when using this style.
See Also:
setRoutingStyle(byte), Constant Field Values
Sample Graph:

Edge routes are straight

ROUTING_POLY_LINE

public static final byte ROUTING_POLY_LINE
Routing style constant which defines that edge paths are routed with a straight segment to the connector of the GenericTreeLayouter.SubtreeShape of the child nodes.

See Also:
setRoutingStyle(byte), Constant Field Values
Sample Graph:

Edges connect straight to the connector of the GenericTreeLayouter.SubtreeShape
Constructor Detail

DefaultNodePlacer

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


DefaultNodePlacer

public DefaultNodePlacer(byte childPlacement,
                         double verticalDistance,
                         double horizontalDistance)
Creates a new DefaultNodePlacer instance with customized child placement, vertical and horizontal distance.

Parameters:
childPlacement - the child placement specifier describing the style of the arrangement
verticalDistance - the vertical distance between the GenericTreeLayouter.SubtreeShapes
horizontalDistance - the horizontal distance between the GenericTreeLayouter.SubtreeShapes
Throws:
java.lang.IllegalArgumentException - if the placement specifier is unknown or if the horizontal/vertical distance is negative
See Also:
setChildPlacement(byte), setVerticalDistance(double), setHorizontalDistance(double)

DefaultNodePlacer

public DefaultNodePlacer(byte childPlacement,
                         byte rootAlignment,
                         double verticalDistance,
                         double horizontalDistance)
Creates a new DefaultNodePlacer instance with customized child placement, root alignment, vertical and horizontal distance.

Parameters:
childPlacement - the child placement specifier describing the style of the arrangement
rootAlignment - the alignment specifier describing how the root node is aligned with its child nodes
verticalDistance - the vertical distance between the GenericTreeLayouter.SubtreeShapes
horizontalDistance - the horizontal distance between the GenericTreeLayouter.SubtreeShapes
Throws:
java.lang.IllegalArgumentException - if the placement specifier or the root alignment specifier is unknown or if the horizontal/vertical distance is negative
See Also:
setChildPlacement(byte), setRootAlignment(byte), setVerticalDistance(double), setHorizontalDistance(double)

DefaultNodePlacer

public DefaultNodePlacer(byte childPlacement,
                         byte rootAlignment,
                         byte routingStyle,
                         double verticalDistance,
                         double horizontalDistance)
Creates a new DefaultNodePlacer instance with customized child placement, root alignment, routing style, vertical and horizontal distance.

Parameters:
childPlacement - the child placement specifier describing the style of the arrangement
rootAlignment - the alignment specifier describing how the root node is aligned with its child nodes
routingStyle - the routing style specifier
verticalDistance - the vertical distance between the GenericTreeLayouter.SubtreeShapes
horizontalDistance - the horizontal distance between the GenericTreeLayouter.SubtreeShapes
Throws:
java.lang.IllegalArgumentException - if the placement specifier or the root alignment or the routing style is unknown or if the horizontal/vertical distance is negative
See Also:
setChildPlacement(byte), setRootAlignment(byte), setRoutingStyle(byte), setVerticalDistance(double), setHorizontalDistance(double)

DefaultNodePlacer

public DefaultNodePlacer(byte childPlacement,
                         byte rootAlignment,
                         byte routingStyle,
                         double verticalDistance,
                         double horizontalDistance,
                         double minFirstSegmentLength,
                         double minLastSegmentLength,
                         double minSlope,
                         double minSlopeHeight)
Creates a new DefaultNodePlacer instance with custom settings.

Parameters:
childPlacement - the child placement specifier describing the style of the arrangement
rootAlignment - the alignment specifier describing how the root node is aligned with its child nodes
routingStyle - the routing style specifier
verticalDistance - the vertical distance between the GenericTreeLayouter.SubtreeShapes
horizontalDistance - the horizontal distance between the GenericTreeLayouter.SubtreeShapes
minFirstSegmentLength - the minimum length of the first edge segment (connected to the root node)
minLastSegmentLength - the minimum length of the last edge segment (connected to the child node)
minSlope - the minimum slope between the root node and the GenericTreeLayouter.SubtreeShapes
minSlopeHeight - the minimum vertical height of sloped edge segments
Throws:
java.lang.IllegalArgumentException - if the placement specifier or the root alignment or the routing style is unknown or if the horizontal/vertical distance or the minimum first/last segment length or the minimum slope or the minimum vertical height is negative
See Also:
setChildPlacement(byte), setRootAlignment(byte), setRoutingStyle(byte), setVerticalDistance(double), setHorizontalDistance(double), setMinFirstSegmentLength(double), setMinLastSegmentLength(double), setMinSlope(double), setMinSlopeHeight(double)
Method Detail

getMinimumChannelSegmentDistance

public double getMinimumChannelSegmentDistance()
Returns the minimum (non-negative) distance between edge segments that are routed orthogonally in the channel between the root node and the child nodes (see ROUTING_FORK). If this distance is set to 0, all segments are routed in a bus-like style.

 
The specified distance is only considered if setMinSlope(double) is equal to 0, setMinSlopeHeight(double) is equal to 0, setRoutingStyle(byte) is ROUTING_FORK and setRootAlignment(byte) is not equal to ALIGNMENT_LEADING_ON_BUS or ALIGNMENT_TRAILING_ON_BUS.
Returns:
the minimum distance between edge segments
See Also:
setMinimumChannelSegmentDistance(double)

setMinimumChannelSegmentDistance

public void setMinimumChannelSegmentDistance(double minimumChannelSegmentDistance)
Specifies the minimum (non-negative) distance between edge segments that are routed orthogonally in the channel between the root node and the child nodes (see ROUTING_FORK). If this distance is set to 0, all segments are routed in a bus-like style.

 
The specified distance is only considered if setMinSlope(double) is equal to 0, setMinSlopeHeight(double) is equal to 0, setRoutingStyle(byte) is ROUTING_FORK and setRootAlignment(byte) is not equal to ALIGNMENT_LEADING_ON_BUS or ALIGNMENT_TRAILING_ON_BUS.
Default Value:
The default value is 0.
Parameters:
minimumChannelSegmentDistance - the minimum distance between edge segments
Throws:
java.lang.IllegalArgumentException - if the specified distance is smaller than 0
Sample Graphs:

Minimum edge distance 0 with centered ports

Minimum edge distance 0 with border-distributed ports

Minimum edge distance 5 with centered ports

Minimum edge distance 5 with border-distributed ports

placeSubtree

protected GenericTreeLayouter.SubtreeShape placeSubtree(Node localRoot,
                                                        byte parentConnectorDirection)
Arranges the root node and its children.

Specified by:
placeSubtree in class AbstractNodePlacer
Parameters:
localRoot - the local root node
parentConnectorDirection - the direction of the connector
Returns:
the merged GenericTreeLayouter.SubtreeShape containing the local root and all its subtrees

calcParentConnector

protected void calcParentConnector(LayoutGraph graph,
                                   Node localRoot,
                                   NodeLayout rootLayout,
                                   GenericTreeLayouter.SubtreeShape subtreeShape,
                                   Edge parentEdge,
                                   EdgeLayout parentEdgeLayout,
                                   byte direction)
Calculates the bends for the connector to the parent node.

This implementation adds bends to the connector for edges that route the edges around the child node in case there are PortConstraints that conflict with the direction of the child placement.

This method is called in placeSubtree(Node, byte) to route the edges after the GenericTreeLayouter.SubtreeShapes are arranged. It may be overridden to customize the routing style.

Parameters:
graph - the input graph
localRoot - the local root node whose connector is calculated and stored in the given subtree shape
rootLayout - the NodeLayout of the root node
subtreeShape - the shape of the whole subtree of the local root
parentEdge - the incoming edge of the local root node that will be the connector for the given subtree shape
parentEdgeLayout - the current EdgeLayout of the connector edge
direction - the direction specifier as defined in the NodePlacer interface which should be used for the connector
See Also:
AbstractNodePlacer.determineChildConnectors(Node, DataMap)

calcTargetEdgeLayout

protected void calcTargetEdgeLayout(NodeLayout rootLayout,
                                    GenericTreeLayouter.SubtreeShape childShape,
                                    Edge edge)
Calculates the routing of the target side of the edge to the given child node.

This implementation just resets the current EdgeLayout.

This method is called by placeSubtree(Node, byte) after the shapes of the local root's children are placed. It may be overridden to add some target points to the edge.

Parameters:
rootLayout - the NodeLayout of the local root node
childShape - the GenericTreeLayouter.SubtreeShape of the child's subtree that is connected through the given edge
edge - the edge

calcSlopedSourceEdgeLayout

protected void calcSlopedSourceEdgeLayout(NodeLayout rootLayout,
                                          GenericTreeLayouter.SubtreeShape childShape,
                                          Edge edge,
                                          double childForkCoordinate,
                                          double rootForkCoordinate)
Calculates the routing of the source side of the edge to the given child node.

This method delegates to calcSourceEdgeLayout(NodeLayout, GenericTreeLayouter.SubtreeShape, Edge) if the routing style is not ROUTING_FORK. It may be overridden to implement a custom routing style.

Parameters:
rootLayout - the NodeLayout of the local root node
childShape - the GenericTreeLayouter.SubtreeShape instance of the corresponding child's subtree
edge - the edge
rootForkCoordinate - the y-coordinate of the first bend of the edge if the placement is horizontal, the x-coordinate otherwise
childForkCoordinate - the y-coordinate of the second (= last) bend of the edge if the placement is horizontal, the x-coordinate otherwise

calcSourceEdgeLayout

protected void calcSourceEdgeLayout(NodeLayout rootLayout,
                                    GenericTreeLayouter.SubtreeShape childShape,
                                    Edge edge)
Calculates the routing of the source side of the edge to the given child node.

This implementation adds bends to the EdgeLayout of the given edge according to the specified routing style and child placement. It also updates the target points in the GenericTreeLayouter.SubtreeShape.

This method is called by calcSlopedSourceEdgeLayout(NodeLayout, GenericTreeLayouter.SubtreeShape, Edge, double, double) to route the edges. It may be overridden to implement a custom edge routing style.

Parameters:
rootLayout - the NodeLayout of the local root node
childShape - the GenericTreeLayouter.SubtreeShape of the child's subtree that is connected through the given edge
edge - the edge

getChildPlacement

public byte getChildPlacement()
Returns the direction in which the child nodes are placed with respect to their parent node.

Subtrees can be placed below, above, left or right of their roots.

Returns:
one of the valid placement specifiers
See Also:
setChildPlacement(byte)

setChildPlacement

public void setChildPlacement(byte childPlacement)
Specifies the direction in which the child nodes are placed with respect to their parent node.

Subtrees can be placed below, above, left or right of their roots.

Default Value:
The default value is PLACEMENT_HORIZONTAL_DOWNWARD
Parameters:
childPlacement - one of the valid placement specifiers
Throws:
java.lang.IllegalArgumentException - if an unknown placement specifier is set

getRootAlignment

public byte getRootAlignment()
Returns how the root node is aligned with its children and their GenericTreeLayouter.SubtreeShapes.

Returns:
one of the valid root alignment specifiers
See Also:
setRootAlignment(byte)

setRootAlignment

public void setRootAlignment(byte rootAlignment)
Specifies how the root node is aligned with its children and their GenericTreeLayouter.SubtreeShapes.

Default Value:
The default value is ALIGNMENT_CENTER
Parameters:
rootAlignment - one of the valid root alignment specifiers
Throws:
java.lang.IllegalArgumentException - if an unknown root alignment specifier is set

getVerticalAlignment

public double getVerticalAlignment()
Returns the relative vertical alignment of nodes with the same parent. All values between 0 and 1 result in a valid alignment. Values outside the interval [0,1] will result in a more compact node placement with unaligned nodes.

Returns:
the relative vertical alignment of nodes that have the same parent node
See Also:
setVerticalAlignment(double)

setVerticalAlignment

public void setVerticalAlignment(double verticalAlignment)
Specifies the relative vertical alignment of nodes with the same parent. All values between 0 and 1 result in a valid alignment. Values outside the interval [0,1] will result in a more compact node placement with unaligned nodes.

Default Value:
The default value is -1. Nodes are not aligned.
Parameters:
verticalAlignment - the relative vertical alignment of nodes that have the same parent node
Sample Graphs:

0

0.5

1

determineChildConnector

protected byte determineChildConnector(Node child)
Determines a connector direction for the given child node depending on the selected child placement.

If the child nodes are placed below the root node, the edge should connect north. If they are placed above the root node it should connect south. The vertical placements are handled analogous.

Specified by:
determineChildConnector in class AbstractNodePlacer
Parameters:
child - the child node
Returns:
the connector direction depending on the child placement
See Also:
getChildPlacement()

getRoutingStyle

public byte getRoutingStyle()
Returns the style in which edge paths are routed.

Returns:
the routing style specifier
See Also:
setRoutingStyle(byte)

setRoutingStyle

public void setRoutingStyle(byte routingStyle)
Specifies the style in which edge paths are routed.

Default Value:
The default value is ROUTING_FORK
Parameters:
routingStyle - the routing style specifier
Throws:
java.lang.IllegalArgumentException - if the specified routing style is unknown

getVerticalDistance

public double getVerticalDistance()
Returns the vertical distance between nodes or GenericTreeLayouter.SubtreeShapes.

The distance needs to be non-negative.

Returns:
the non-negative vertical distance
See Also:
setVerticalDistance(double)

setVerticalDistance

public void setVerticalDistance(double verticalDistance)
Specifies the vertical distance between nodes or GenericTreeLayouter.SubtreeShapes.

The distance needs to be non-negative.

Default Value:
The default value is 40.
Parameters:
verticalDistance - the non-negative vertical distance
Throws:
java.lang.IllegalArgumentException - if the specified distance is negative
Sample Graphs:

40

80

getMinFirstSegmentLength

public double getMinFirstSegmentLength()
Returns the minimum length for the first segment of an edge.

During layout calculation, the edges of the tree are directed. Hence, the first segment is always the segment that is attached to the source, which is the local root node.

The length needs to be non-negative.

 
The specified length is only considered if the routing style is set to ROUTING_FORK.
Returns:
the non-negative minimum segment length
See Also:
setMinFirstSegmentLength(double)

setMinFirstSegmentLength

public void setMinFirstSegmentLength(double minFirstSegmentLength)
Specifies the minimum length for the first segment of an edge.

During layout calculation, the edges of the tree are directed. Hence, the first segment is always the segment that is attached to the source, which is the local root node.

The length needs to be non-negative.

 
The specified length is only considered if the routing style is set to ROUTING_FORK.
Default Value:
The default value is 0.
Parameters:
minFirstSegmentLength - the non-negative minimum segment length
Throws:
java.lang.IllegalArgumentException - if the minimum segment length is negative
Sample Graphs:

15

30

getMinLastSegmentLength

public double getMinLastSegmentLength()
Returns the minimum length for the last segment of an edge.

During layout calculation, the edges of the tree are directed. Hence, the last segment is always the segment that is attached to the target, which is a child node.

The length needs to be non-negative.

 
The specified length is only considered if the routing style is set to ROUTING_FORK.
Returns:
the non-negative minimum segment length
See Also:
setMinLastSegmentLength(double)

setMinLastSegmentLength

public void setMinLastSegmentLength(double minLastSegmentLength)
Specifies the minimum length for the last segment of an edge.

During layout calculation, the edges of the tree are directed. Hence, the last segment is always the segment that is attached to the target, which is a child node.

The length needs to be non-negative.

 
The specified length is only considered if the routing style is set to ROUTING_FORK.
Default Value:
The default value is 0.
Parameters:
minLastSegmentLength - the non-negative minimum segment length
Throws:
java.lang.IllegalArgumentException - if the minimum segment length is negative
Sample Graphs:

15

30

getMinSlope

public double getMinSlope()
Returns the minimum slope of the edge segments.

These sloped segments are between the vertical first and last segment of the edge.

The segments may become steeper but they will have at least the specified slope. Negative minimum slopes can lead to edge routes looking like spider legs.

 
The actual slopes also depend on the vertical distance slope segments can have.
Returns:
the minimum slope
See Also:
setMinSlope(double), setMinSlopeHeight(double)

setMinSlope

public void setMinSlope(double minSlope)
Specifies the minimum slope of the edge segments.

These sloped segments are between the vertical first and last segment of the edge.

The segments may become steeper but they will have at least the specified slope. Negative minimum slopes can lead to edge routes looking like spider legs.

 
The actual slopes also depend on the vertical distance slope segments can have.
Default Value:
The default value is 0.
Parameters:
minSlope - the minimum slope
See Also:
setMinSlopeHeight(double)
Sample Graphs:

0

0.5

getMinSlopeHeight

public double getMinSlopeHeight()
Returns the minimum height for sloped edge segments.

These sloped segments are between the vertical first and last segment of the edge.

The segments may become steeper to reach the specified height.

 
The actual slopes also depend on the setMinSlope(double) minimum slope} segments can have.
Returns:
the minimum height for sloped segments
See Also:
setMinSlopeHeight(double), setMinSlope(double)

setMinSlopeHeight

public void setMinSlopeHeight(double minSlopeHeight)
Specifies the minimum height for sloped edge segments.

These sloped segments are between the vertical first and last segment of the edge.

The segments may become steeper to reach the specified height.

 
The actual slopes also depend on the setMinSlope(double) minimum slope} segments can have.
Default Value:
The default value is 0.
Parameters:
minSlopeHeight - the minimum height for sloped segments
See Also:
setMinSlope(double)
Sample Graphs:

0

10

getHorizontalDistance

public double getHorizontalDistance()
Returns the horizontal distance between nodes or GenericTreeLayouter.SubtreeShapes.

The distance needs to be non-negative.

Returns:
the non-negative horizontal distance
See Also:
setHorizontalDistance(double)

setHorizontalDistance

public void setHorizontalDistance(double horizontalDistance)
Specifies the horizontal distance between nodes or GenericTreeLayouter.SubtreeShapes.

The distance needs to be non-negative.

Default Value:
The default value is 40.
Parameters:
horizontalDistance - the non-negative horizontal distance
Throws:
java.lang.IllegalArgumentException - if the specified distance is negative
Sample Graphs:

40

80

createComparator

public java.util.Comparator createComparator()
Creates a Comparator for outgoing edges which takes the initial coordinates of the edges' targets into account.

Child nodes are sorted in a way that the layout will resemble the current arrangement of the nodes. This is especially useful for interactive or incremental layout calculation.

Returns:
a Comparator that considers the initial coordinates of the nodes

createFromSketchComparator

public java.util.Comparator createFromSketchComparator()
Delegates to createComparator().

Specified by:
createFromSketchComparator in interface FromSketchNodePlacer
Returns:
the From Sketch Comparator
See Also:
createComparator()

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