public class DelegatingNodePlacer extends AbstractRotatableNodePlacer
DelegatingNodePlacer
delegates the arrangement of the children to two different INodePlacer
s.
INodePlacer
can, for example, be used for creating mind maps or a playing schedule of
a sports competition.
There are two subtrees that are placed above and below the root; Both subtrees consist of two subtrees that are placed left and right of their local root
AbstractRotatableNodePlacer.Matrix, AbstractRotatableNodePlacer.RootAlignment
Modifier and Type | Field and Description |
---|---|
static NodeDpKey<Boolean> |
PRIMARY_NODES_DPKEY
A
DataProvider key for dividing the children into two sets
If there is no IDataProvider registered with this key, half of the nodes are placed left of the root and the
remaining nodes are placed right of the root. |
createdChildren, graph, nodeShapeProvider, subtreeShapeProvider
Constructor and Description |
---|
DelegatingNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix,
INodePlacer placerUpperLeft,
INodePlacer placerLowerRight)
Creates a new
DefaultNodePlacer instance with default settings using the given
modification matrix and the given node placers as delegates. |
Modifier and Type | Method and Description |
---|---|
IProcessor |
createProcessor(TreeLayout layouter,
LayoutGraph graph,
Node currentRoot)
Creates a
IProcessor that partitions child nodes of the current root node into two subsets. |
protected ParentConnectorDirection |
determineChildConnector(Node child)
Determines a connector direction for the given child node.
|
void |
determineChildConnectors(Node localRoot,
IDataMap connectorMap)
Does nothing.
|
INodePlacer |
getPrimaryPlacer()
Gets the
INodePlacer instance that will arrange the upper-left part of the graph. |
INodePlacer |
getSecondaryPlacer()
Gets the
INodePlacer instance that will arrange the lower-right part of the graph. |
TreeLayout.SubtreeShape |
placeSubtree(IDataProvider nodeShapeProvider,
IDataProvider subtreeShapeProvider,
LayoutGraph graph,
Node localRoot,
ParentConnectorDirection parentConnectorDirection)
Places the
TreeLayout.SubtreeShape s of the child nodes using the two delegate node placers retrieved with PrimaryPlacer
and SecondaryPlacer . |
protected RotatedSubtreeShape |
placeSubtree(Node localRoot,
ParentConnectorDirection parentConnectorDirection)
Arranges the local root relative to the subtree shape of its children.
|
protected NodeList |
primaryChildren(Node localRoot,
LayoutGraph graph)
Returns all upper-left children of the local root node.
|
protected NodeList |
secondaryChildren(Node localRoot,
LayoutGraph graph)
Returns all lower-right children of the local root node.
|
createComparator, createFromSketchComparator, getModificationMatrix, getNodeShape, getPortConstraint, getSourcePointAbs, getSpacing, getSubtreeShape, setSpacing, translateDirectionToModel, translateDirectionToReal, translatePoint
public static final NodeDpKey<Boolean> PRIMARY_NODES_DPKEY
DataProvider
key for dividing the children into two sets
If there is no IDataProvider
registered with this key, half of the nodes are placed left of the root and the
remaining nodes are placed right of the root.
public DelegatingNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix, INodePlacer placerUpperLeft, INodePlacer placerLowerRight)
DefaultNodePlacer
instance with default settings using the given
modification matrix and the given node placers as delegates.modificationMatrix
- the transformation matrixplacerUpperLeft
- the first delegate INodePlacer
which places the left subtreesplacerLowerRight
- the second delegate INodePlacer
which places the right subtreesPRIMARY_NODES_DPKEY
public IProcessor createProcessor(TreeLayout layouter, LayoutGraph graph, Node currentRoot)
IProcessor
that partitions child nodes of the current root node into two subsets.
In a pre-processing step the child nodes are divided into an upper-left and a lower-right subset. The first set is
arranged using the first delegate
, the second set is arranged using
the second delegate
. To be able to delegate to different INodePlacer
s this IProcessor
adds dummy nodes to which it assigns the according INodePlacer
s.
The changes to the graph are restored in the post-processing step.
createProcessor
in interface INodePlacer
createProcessor
in class AbstractRotatableNodePlacer
layouter
- the current TreeLayout
instancegraph
- the input graphcurrentRoot
- the root node handled by this INodePlacer
null
getSecondaryPlacer()
,
getPrimaryPlacer()
protected ParentConnectorDirection determineChildConnector(Node child)
determineChildConnector
in class AbstractRotatableNodePlacer
IllegalStateException
- if this method is calleddetermineChildConnectors(Node, IDataMap)
, it does not call this method.child
- the child nodeINodePlacer
interfacepublic void determineChildConnectors(Node localRoot, IDataMap connectorMap)
Since the DelegatingNodePlacer
always places one part of the tree on one side and the remaining tree on the
opposite side, it doesn't need to calculate the directions of the connectors.
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 nodesAbstractRotatableNodePlacer.determineChildConnector(Node)
public INodePlacer getPrimaryPlacer()
INodePlacer
instance that will arrange the upper-left part of the graph.INodePlacer
getSecondaryPlacer()
,
primaryChildren(Node, LayoutGraph)
public INodePlacer getSecondaryPlacer()
INodePlacer
instance that will arrange the lower-right part of the graph.INodePlacer
getPrimaryPlacer()
,
secondaryChildren(Node, LayoutGraph)
public TreeLayout.SubtreeShape placeSubtree(IDataProvider nodeShapeProvider, IDataProvider subtreeShapeProvider, LayoutGraph graph, Node localRoot, ParentConnectorDirection parentConnectorDirection)
TreeLayout.SubtreeShape
s of the child nodes using the two delegate node placers retrieved with PrimaryPlacer
and SecondaryPlacer
.placeSubtree
in interface INodePlacer
placeSubtree
in class AbstractRotatableNodePlacer
nodeShapeProvider
- the IDataProvider
for obtaining an initial shape of the root nodesubtreeShapeProvider
- the IDataProvider
for accessing the pre-calculated shapes of the subtreesgraph
- the input graphlocalRoot
- the root of the subtree that should be arranged by this methodparentConnectorDirection
- the direction specifier for the connector of the local root node to its parent nodeTreeLayout.SubtreeShape
for the subtree rooted at the local root nodeAbstractRotatableNodePlacer.placeSubtree(Node, ParentConnectorDirection)
protected RotatedSubtreeShape placeSubtree(Node localRoot, ParentConnectorDirection parentConnectorDirection)
placeSubtree
in class AbstractRotatableNodePlacer
IllegalStateException
- if this method is calledupper-left
and the lower-right node placer
placeSubtree(IDataProvider, IDataProvider, LayoutGraph, Node, ParentConnectorDirection)
.localRoot
- the local root nodeparentConnectorDirection
- the direction specifier for the connector of the local root node to its parent nodeprotected NodeList primaryChildren(Node localRoot, LayoutGraph graph)
Which children belong to this list is determined using the IDataProvider
registered with
PRIMARY_NODES_DPKEY
. If no such IDataProvider
is registered, the first half of the children is
returned.
These children are placed using the INodePlacer
returned by PrimaryPlacer
.
localRoot
- the local root nodegraph
- the input graphNode
sPRIMARY_NODES_DPKEY
protected NodeList secondaryChildren(Node localRoot, LayoutGraph graph)
Which children belong to this list is determined using the IDataProvider
registered with
PRIMARY_NODES_DPKEY
. If no such IDataProvider
is registered, the second half of the children is
returned.
These children are placed using the INodePlacer
returned by SecondaryPlacer
.
localRoot
- the local root nodegraph
- the input graphNode
sPRIMARY_NODES_DPKEY