public class LeftRightNodePlacer extends AbstractRotatableNodePlacer
LeftRightNodePlacer
arranges the children in a subtree on the left and the right of a vertical bus.
AbstractRotatableNodePlacer.Matrix, AbstractRotatableNodePlacer.RootAlignment
Modifier and Type | Field and Description |
---|---|
static NodeDpKey<Boolean> |
LEFT_RIGHT_DPKEY
A
DataProvider key for assigning nodes to the left or the right side of the bus
If no IDataProvider is specified using this key, the nodes will be placed alternating from left to right. |
createdChildren, graph, nodeShapeProvider, subtreeShapeProvider
Constructor and Description |
---|
LeftRightNodePlacer()
Creates a new
LeftRightNodePlacer instance with default settings. |
LeftRightNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
Creates a new
LeftRightNodePlacer instance using the given modification matrix. |
Modifier and Type | Method and Description |
---|---|
Comparator<Object> |
createComparator()
Returns a
Comparator for outgoing edges that considers the locations of the target nodes. |
static IDataProvider |
createLeftRightDataProvider(IDataProvider nodePlacerMap)
Creates a special
IDataProvider that determines whether a given node is placed left or right of the parent
node. |
protected ParentConnectorDirection |
determineChildConnector(Node child)
Determines a connector direction for the given child node.
|
void |
determineChildConnectors(Node localRoot,
IDataMap connectorMap)
Determines the direction of the child connectors according to which side of the bus the child is assigned.
|
double |
getHorizontalDistance()
Gets the horizontal distance between nodes or subtrees.
|
double |
getVerticalDistance()
Gets the vertical distance between nodes or subtrees.
|
boolean |
isLastOnBottomPlacementEnabled()
Gets whether or not the last child is placed centered, aligned with the bus and below the other child nodes.
|
protected RotatedSubtreeShape |
placeSubtree(Node localRoot,
ParentConnectorDirection parentConnectorDirection)
Places the subtree shapes of the children left and right of a common vertical bus.
|
void |
setHorizontalDistance(double value)
Sets the horizontal distance between nodes or subtrees.
|
void |
setLastOnBottomPlacementEnabled(boolean value)
Sets whether or not the last child is placed centered, aligned with the bus and below the other child nodes.
|
void |
setSpacing(double value)
Sets a uniform horizontal and vertical spacing between subtrees.
|
void |
setVerticalDistance(double value)
Sets the vertical distance between nodes or subtrees.
|
createFromSketchComparator, createProcessor, getModificationMatrix, getNodeShape, getPortConstraint, getSourcePointAbs, getSpacing, getSubtreeShape, placeSubtree, translateDirectionToModel, translateDirectionToReal, translatePoint
public static final NodeDpKey<Boolean> LEFT_RIGHT_DPKEY
DataProvider
key for assigning nodes to the left or the right side of the bus
If no IDataProvider
is specified using this key, the nodes will be placed alternating from left to right.
public LeftRightNodePlacer()
LeftRightNodePlacer
instance with default settings.public LeftRightNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
LeftRightNodePlacer
instance using the given modification matrix.modificationMatrix
- the transformation matrix for this AbstractRotatableNodePlacer
public Comparator<Object> createComparator()
Comparator
for outgoing edges that considers the locations of the target nodes.
The Comparator
applies the modification matrix
of
this LeftRightNodePlacer
and then compares the y-coordinates of the target nodes.
createComparator
in class AbstractRotatableNodePlacer
Comparator
that compares outgoing edges according to the locations of their target nodespublic static final IDataProvider createLeftRightDataProvider(IDataProvider nodePlacerMap)
IDataProvider
that determines whether a given node is placed left or right of the parent
node.
This IDataProvider
can be registered with the graph with key
LEFT_RIGHT_DPKEY
. It calculates the side with respect to the initial coordinates of the nodes in the graph,
considering the orientation of the subtree.
If a node is assigned to the left side, this IDataProvider
will return true
. For the right side, it will
return false
.
LeftRightDataProvider
provides a convenient way to determine the side of a node from the initial graph.INodePlacer
, LeftRightDataProvider
demands a IDataProvider
containing the INodePlacer
instances that are used
for the layout calculation.nodePlacerMap
- a IDataProvider
containing the corresponding INodePlacer
s for the nodeprotected ParentConnectorDirection determineChildConnector(Node child)
Since the connector directions are already determined by
determineChildConnectors(Node, IDataMap)
, this method doesn't need to be called.
determineChildConnector
in class AbstractRotatableNodePlacer
IllegalStateException
- if this method is calledchild
- the child nodeINodePlacer
interfacepublic void determineChildConnectors(Node localRoot, IDataMap connectorMap)
Children on the left will get a connector to the ParentConnectorDirection.EAST
. Children on the right will get
one to the ParentConnectorDirection.WEST
. A connector to the ParentConnectorDirection.NORTH
is assigned
for the bottom child.
determineChildConnectors
in interface INodePlacer
determineChildConnectors
in class AbstractRotatableNodePlacer
localRoot
- the local root nodeconnectorMap
- the map that must be used for storing the direction specifiers of the child nodessetLastOnBottomPlacementEnabled(boolean)
public double getHorizontalDistance()
The distance needs to be non-negative.
IllegalArgumentException
- if the specified distance is negativesetHorizontalDistance(double)
public double getVerticalDistance()
The distance needs to be non-negative.
IllegalArgumentException
- if the specified distance is negativesetVerticalDistance(double)
public boolean isLastOnBottomPlacementEnabled()
When enabled, the last child will always be centered independent of the number of siblings.
true
. The last child is centered below its siblingstrue
if the last child is separated, false
otherwisesetLastOnBottomPlacementEnabled(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 setHorizontalDistance(double value)
The distance needs to be non-negative.
IllegalArgumentException
- if the specified distance is negativevalue
- the non-negative horizontal distancegetHorizontalDistance()
public void setLastOnBottomPlacementEnabled(boolean value)
When enabled, the last child will always be centered independent of the number of siblings.
true
. The last child is centered below its siblingsvalue
- true
if the last child is separated, false
otherwiseisLastOnBottomPlacementEnabled()
public void setSpacing(double value)
This method sets the given distance value for the horizontal spacing
and for the
vertical spacing
.
setSpacing
in class AbstractRotatableNodePlacer
IllegalArgumentException
- if the specified spacing value is negativevalue
- The Spacing to set.setHorizontalDistance(double)
,
setVerticalDistance(double)
public void setVerticalDistance(double value)
The distance needs to be non-negative.
IllegalArgumentException
- if the specified distance is negativevalue
- the non-negative vertical distancegetVerticalDistance()