Search this API

y.layout.tree
Class SimpleNodePlacer

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

public class SimpleNodePlacer
extends AbstractRotatableNodePlacer

The SimpleNodePlacer arranges all children of a local root in a single row.

Layout Style

 

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
SimpleNodePlacer()
          Creates a new SimpleNodePlacer instance with default settings.
SimpleNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
          Creates a new SimpleNodePlacer instance that uses the given modification matrix.
SimpleNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix, AbstractRotatableNodePlacer.RootAlignment rootAlignment)
          Creates a new SimpleNodePlacer instance that uses the given modification matrix and root alignment.
 
Method Summary
protected  byte determineChildConnector(Node child)
          Provides NodePlacer.DIRECTION_NORTH as connector direction for the child nodes.
 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.
 AbstractRotatableNodePlacer.RootAlignment getRootAlignment()
          Returns the RootAlignment that defines how the root node is aligned with its children and their shapes.
 double getVerticalAlignment()
          Returns the relative vertical alignment of nodes with the same parent.
 boolean isCreateBus()
          Returns whether or not a bus is created in the space between the parent and its children.
protected  y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot, byte parentConnectorDirection)
          Places the children of the local root node in a single row.
 void setCreateBus(boolean createBus)
          Specifies whether or not a bus is created in the space between the parent and its children.
 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.
 void setRootAlignment(AbstractRotatableNodePlacer.RootAlignment rootAlignment)
          Specifies the RootAlignment that defines how the root node is aligned with its children and their shapes.
 void setVerticalAlignment(double verticalAlignment)
          Specifies the relative vertical alignment of nodes with the same parent.
 
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

SimpleNodePlacer

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


SimpleNodePlacer

public SimpleNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
Creates a new SimpleNodePlacer instance that uses the given modification matrix.

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

SimpleNodePlacer

public SimpleNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix,
                        AbstractRotatableNodePlacer.RootAlignment rootAlignment)
Creates a new SimpleNodePlacer instance that uses the given modification matrix and root alignment.

Parameters:
modificationMatrix - the transformation matrix for this AbstractRotatableNodePlacer
rootAlignment - the alignment for the local root in relation to its subtrees
Throws:
java.lang.IllegalArgumentException - if the given transformation matrix or the given root alignment is null
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. If this distance is set to 0, all segments are routed in a bus-like style.

 
The specified distance is only considered if setCreateBus(boolean) is enabled.
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. If this distance is set to 0, all segments are routed in a bus-like style.

 
The specified distance is only considered if setCreateBus(boolean) is enabled.
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

getRootAlignment

public AbstractRotatableNodePlacer.RootAlignment getRootAlignment()
Returns the RootAlignment 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 RootAlignment that defines how the root node is aligned with its children and their shapes.

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

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] may result in a more compact node placement with unaligned nodes, especially when labels are considered.

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] may result in a more compact node placement with unaligned nodes, especially when labels are considered.

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)
Provides NodePlacer.DIRECTION_NORTH as connector direction for the child nodes.

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

isCreateBus

public boolean isCreateBus()
Returns whether or not a bus is created in the space between the parent and its children.

Returns:
true if the bus is created, false otherwise
See Also:
setCreateBus(boolean)

setCreateBus

public void setCreateBus(boolean createBus)
Specifies whether or not a bus is created in the space between the parent and its children.

Default Value:
The default value is false. The edges leave the local root on the left or right side.
Parameters:
createBus - true if the bus should be created, false otherwise
Sample Graphs:

false

true

placeSubtree

protected y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot,
                                                         byte parentConnectorDirection)
Places the children of the local root node in a single row.

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 containing the local root node and all its children

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