public class LayeredNodePlacer extends AbstractRotatableNodePlacer
LayeredNodePlacer
arranges the nodes of a subtree respecting layers.
aligned
.
orientation
within the LayeredNodePlacer
is strongly discouraged because it causes problems with the layering.AbstractRotatableNodePlacer.Matrix, AbstractRotatableNodePlacer.RootAlignment
createdChildren, graph, nodeShapeProvider, subtreeShapeProvider
Constructor and Description |
---|
LayeredNodePlacer()
Creates a new
LayeredNodePlacer instance with the default settings. |
LayeredNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix,
Object id)
Creates a new
LayeredNodePlacer instance whose direction is specified by the given modification matrix. |
Modifier and Type | Method and Description |
---|---|
IProcessor |
createProcessor(TreeLayout layouter,
LayoutGraph graph,
Node currentRoot)
Creates a
IProcessor that distributes the nodes over the layers. |
protected ParentConnectorDirection |
determineChildConnector(Node child)
Returns
ParentConnectorDirection.NORTH for every given child node. |
double |
getBusAlignment()
Gets the vertical bus alignment for orthogonally routed edges.
|
Object |
getId()
Gets the ID of this
LayeredNodePlacer . |
double |
getLayerSpacing()
Gets the distance between two adjacent layers.
|
AbstractRotatableNodePlacer.RootAlignment |
getRootAlignment()
Gets the
RootAlginment that defines how the root node is aligned with
its children and their shapes. |
LayeredRoutingStyle |
getRoutingStyle()
Gets the routing style for the edges in the subtree.
|
double |
getVerticalAlignment()
Gets the relative vertical alignment of nodes within their respective layers.
|
boolean |
isDendrogramStyleEnabled()
Gets whether or not the layering is done dendrogram-like.
|
boolean |
isPolylineLabeling()
Gets whether or not straight edges are extended to avoid label overlaps.
|
protected RotatedSubtreeShape |
placeSubtree(Node localRoot,
ParentConnectorDirection parentConnectorDirection)
Places the children of local root in layers.
|
void |
setBusAlignment(double value)
Sets the vertical bus alignment for orthogonally routed edges.
|
void |
setDendrogramStyleEnabled(boolean value)
Sets whether or not the layering is done dendrogram-like.
|
void |
setLayerSpacing(double value)
Sets the distance between two adjacent layers.
|
void |
setPolylineLabeling(boolean value)
Sets whether or not straight edges are extended to avoid label overlaps.
|
void |
setRootAlignment(AbstractRotatableNodePlacer.RootAlignment value)
Sets the
RootAlginment that defines how the root node is aligned with
its children and their shapes. |
void |
setRoutingStyle(LayeredRoutingStyle value)
Sets the routing style for the edges in the subtree.
|
void |
setVerticalAlignment(double value)
Sets the relative vertical alignment of nodes within their respective layers.
|
createComparator, createFromSketchComparator, determineChildConnectors, getModificationMatrix, getNodeShape, getPortConstraint, getSourcePointAbs, getSpacing, getSubtreeShape, placeSubtree, setSpacing, translateDirectionToModel, translateDirectionToReal, translatePoint
public LayeredNodePlacer()
LayeredNodePlacer
instance with the default settings.public LayeredNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix, Object id)
LayeredNodePlacer
instance whose direction is specified by the given modification matrix.
The given ID identifies different LayeredNodePlacer
instances that share the same layer heights.
modificationMatrix
- the transformation matrix for this AbstractRotatableNodePlacer
id
- the LayeredNodePlacer
IDpublic IProcessor createProcessor(TreeLayout layouter, LayoutGraph graph, Node currentRoot)
IProcessor
that distributes the nodes over the layers.
The IProcessor
is chosen depending on the layout style
.
createProcessor
in interface INodePlacer
createProcessor
in class AbstractRotatableNodePlacer
graph
- the input graphcurrentRoot
- the current root node for this node placerlayouter
- the current TreeLayout
instanceIProcessor
or null
if the layer information is already assigned to the current rootsetDendrogramStyleEnabled(boolean)
protected ParentConnectorDirection determineChildConnector(Node child)
ParentConnectorDirection.NORTH
for every given child node.
Edges always connect to the top of the child nodes.
determineChildConnector
in class AbstractRotatableNodePlacer
child
- the child nodeParentConnectorDirection.NORTH
public double getBusAlignment()
The bus alignment determines the relative position of an edge bus in between two subsequent layers of nodes.
Values for a valid vertical alignment are in the range [0..1]
, such that:
0.0
places the bus at the top, right below the parent node.0.5
places the bus in the middle between parent and child nodes.1.0
places the bus at the bottom, right above the child nodes.IllegalArgumentException
- if the specified alignment is outside [0..1]
routing style
is set to
LayeredRoutingStyle.ORTHOGONAL
.setBusAlignment(double)
public Object getId()
LayeredNodePlacer
.
The ID is used for identifying
LayeredNodePlacer
s that share information about the layer height. Using different IDs allows aligned layouts
within different subtrees.
public double getLayerSpacing()
The spacing needs to be non-negative.
IllegalArgumentException
- if the specified spacing is negativesetLayerSpacing(double)
public AbstractRotatableNodePlacer.RootAlignment getRootAlignment()
RootAlginment
that defines how the root node is aligned with
its children and their shapes.AbstractRotatableNodePlacer.RootAlignment.CENTER
AbstractRotatableNodePlacer.RootAlignment
instance specifying the location relative to the subtreessetRootAlignment(AbstractRotatableNodePlacer.RootAlignment)
public LayeredRoutingStyle getRoutingStyle()
IllegalArgumentException
- if the specified routing style specifier is unknownLayeredRoutingStyle.STRAIGHT
setRoutingStyle(LayeredRoutingStyle)
public double getVerticalAlignment()
A value of 0
means that nodes are top-aligned; a value of 0.5
means that nodes are center-aligned; a
value of 1
means that nodes are bottom-aligned;
Values for a valid vertical alignment are in the range [0..1]
.
IllegalArgumentException
- if the specified alignment is outside [0..1]
setVerticalAlignment(double)
public boolean isDendrogramStyleEnabled()
When enabled, leaves are placed in the same layer and remaining tree nodes are assigned to a layer as close to their children as possible.
false
. The nodes are assigned to the topmost layer.true
if the graph is layered as a dendrogram, false
otherwisesetDendrogramStyleEnabled(boolean)
public boolean isPolylineLabeling()
If enabled, polyline connectors between the parent and its children are added to the according subtree shape. Node or edge labels will not be crossed.
routing style
is
LayeredRoutingStyle.STRAIGHT
.false
. Edges are only routed straight.true
if polyline connectors are added, false
otherwisesetPolylineLabeling(boolean)
protected RotatedSubtreeShape placeSubtree(Node localRoot, ParentConnectorDirection parentConnectorDirection)
placeSubtree
in class AbstractRotatableNodePlacer
localRoot
- the local root nodeparentConnectorDirection
- the direction specifier for the connector of the local root node to its parent nodepublic void setBusAlignment(double value)
The bus alignment determines the relative position of an edge bus in between two subsequent layers of nodes.
Values for a valid vertical alignment are in the range [0..1]
, such that:
0.0
places the bus at the top, right below the parent node.0.5
places the bus in the middle between parent and child nodes.1.0
places the bus at the bottom, right above the child nodes.IllegalArgumentException
- if the specified alignment is outside [0..1]
routing style
is set to
LayeredRoutingStyle.ORTHOGONAL
.value
- the relative bus alignmentgetBusAlignment()
public void setDendrogramStyleEnabled(boolean value)
When enabled, leaves are placed in the same layer and remaining tree nodes are assigned to a layer as close to their children as possible.
false
. The nodes are assigned to the topmost layer.value
- true
if the graph is layered as a dendrogram, false
otherwiseisDendrogramStyleEnabled()
public void setLayerSpacing(double value)
The spacing needs to be non-negative.
IllegalArgumentException
- if the specified spacing is negativevalue
- the spacing between two layersgetLayerSpacing()
public void setPolylineLabeling(boolean value)
If enabled, polyline connectors between the parent and its children are added to the according subtree shape. Node or edge labels will not be crossed.
routing style
is
LayeredRoutingStyle.STRAIGHT
.false
. Edges are only routed straight.value
- true
if polyline connectors are added, false
otherwiseisPolylineLabeling()
public void setRootAlignment(AbstractRotatableNodePlacer.RootAlignment value)
RootAlginment
that defines how the root node is aligned with
its children and their shapes.AbstractRotatableNodePlacer.RootAlignment.CENTER
value
- the AbstractRotatableNodePlacer.RootAlignment
instance specifying the location relative to the subtreesgetRootAlignment()
public void setRoutingStyle(LayeredRoutingStyle value)
IllegalArgumentException
- if the specified routing style specifier is unknownLayeredRoutingStyle.STRAIGHT
value
- one of the predefined edge routing stylesgetRoutingStyle()
public void setVerticalAlignment(double value)
A value of 0
means that nodes are top-aligned; a value of 0.5
means that nodes are center-aligned; a
value of 1
means that nodes are bottom-aligned;
Values for a valid vertical alignment are in the range [0..1]
.
IllegalArgumentException
- if the specified alignment is outside [0..1]
value
- the vertical alignment of nodes within their layersgetVerticalAlignment()