public class AssistantNodePlacer extends AbstractRotatableNodePlacer
AssistantNodePlacer
places nodes that are marked as assistants left and right of their parents and all other
nodes below the assistant nodes.
Assistants are marked
INodePlacer
delegates the placement of all assistant nodes to an instance of
LeftRightNodePlacer
. The non-assistant nodes are handled by another
node placer
. To be able to do this, AssistantNodePlacer
uses a IProcessor
which prepares the graph for node placing.
A IDataProvider
that is registered using ASSISTANT_NODE_DPKEY
returns true
for assistant nodes
and false
for all other nodes.
IPortAssignment
that starts all edges at the same port.
If the ports are distributed along the border, edge crossings may occur.AbstractRotatableNodePlacer.Matrix, AbstractRotatableNodePlacer.RootAlignment
Modifier and Type | Field and Description |
---|---|
static NodeDpKey<Boolean> |
ASSISTANT_NODE_DPKEY
A
DataProvider key for marking which nodes are placed as assistants
|
createdChildren, graph, nodeShapeProvider, subtreeShapeProvider
Constructor and Description |
---|
AssistantNodePlacer()
Creates a new
AssistantNodePlacer instance with default settings. |
AssistantNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
Creates a new
AssistantNodePlacer instance that uses the transformation defined by the given matrix. |
Modifier and Type | Method and Description |
---|---|
Comparator<Object> |
createComparator()
Delegates the creation of
from-sketch comparators to
the two INodePlacer s handling assistant and non-assistant nodes. |
static Comparator<Object> |
createCompoundComparator(Comparator<Object> assistantComparator,
Comparator<Object> childComparator)
Creates a
Comparator that compares outgoing edges connecting to assistant nodes and edges connecting to
non-assistant nodes separately. |
IProcessor |
createProcessor(TreeLayout layouter,
LayoutGraph graph,
Node currentRoot)
Creates a
IProcessor that prepares the graph for placing assistant node. |
protected ParentConnectorDirection |
determineChildConnector(Node child)
Determines a connector direction for the given child node.
|
void |
determineChildConnectors(Node localRoot,
IDataMap connectorMap)
Delegates the calculation of the child connectors to the
LeftRightNodePlacer which arranges the assistant
nodes. |
INodePlacer |
getChildNodePlacer()
Gets the
INodePlacer instance that places the non-assistant children. |
double |
getSpacing()
Gets the spacing between subtrees for the delegate
INodePlacer . |
TreeLayout.SubtreeShape |
placeSubtree(IDataProvider nodeShapeProvider,
IDataProvider subtreeShapeProvider,
LayoutGraph graph,
Node localRoot,
ParentConnectorDirection parentConnectorDirection)
Delegates the arrangement of
TreeLayout.SubtreeShape s to an instance of LeftRightNodePlacer . |
protected RotatedSubtreeShape |
placeSubtree(Node localRoot,
ParentConnectorDirection parentConnectorDirection)
Arranges the local root relative to the subtree shape of its children.
|
void |
setChildNodePlacer(INodePlacer value)
Sets the
INodePlacer instance that places the non-assistant children. |
void |
setSpacing(double value)
Sets the spacing between subtrees for the delegate
INodePlacer . |
createFromSketchComparator, getModificationMatrix, getNodeShape, getPortConstraint, getSourcePointAbs, getSubtreeShape, translateDirectionToModel, translateDirectionToReal, translatePoint
public AssistantNodePlacer()
AssistantNodePlacer
instance with default settings.public AssistantNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
AssistantNodePlacer
instance that uses the transformation defined by the given matrix.modificationMatrix
- the transformation matrixpublic Comparator<Object> createComparator()
from-sketch comparators
to
the two INodePlacer
s handling assistant and non-assistant nodes.
The from-sketch Comparator
s are combined
into a
compound comparator. The one for the edges connecting to assistant nodes is retrieved from a LeftRightNodePlacer
while the other one is provided by the child placer
.
createComparator
in class AbstractRotatableNodePlacer
Comparator
to compare edges, considering the initial locations of their target nodessetChildNodePlacer(INodePlacer)
,
createCompoundComparator(Comparator, Comparator)
,
IFromSketchNodePlacer.createFromSketchComparator()
public static final Comparator<Object> createCompoundComparator(Comparator<Object> assistantComparator, Comparator<Object> childComparator)
Comparator
that compares outgoing edges connecting to assistant nodes and edges connecting to
non-assistant nodes separately.assistantComparator
- the Comparator
for edges connecting to assistant nodeschildComparator
- the Comparator
for edges connecting to non-assistant nodesComparator
that compares edges to assistant nodes separately from edges to non-assistant nodespublic IProcessor createProcessor(TreeLayout layouter, LayoutGraph graph, Node currentRoot)
IProcessor
that prepares the graph for placing assistant node.
The pre-processing step adds a dummy node as a child to the current root and changes all edges of non-assistant children
such that they start at this dummy node. That way, AssistantNodePlacer
is able to delegate the assistant nodes
to a INodePlacer
different from the one used for placing non-assistant nodes. The child node placer
is assigned to the dummy node. So the non-assistant children are placed by this delegate placer.
All changes will be cleaned up during 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
IProcessor
instance that prepares the graph for AssistantNodePlacer
protected ParentConnectorDirection determineChildConnector(Node child)
determineChildConnector
in class AbstractRotatableNodePlacer
IllegalStateException
- if this method is calledINodePlacer
for
the assistant nodes by determineChildConnectors(Node, IDataMap)
.child
- the child nodeINodePlacer
interfacepublic void determineChildConnectors(Node localRoot, IDataMap connectorMap)
LeftRightNodePlacer
which arranges the assistant
nodes.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 getChildNodePlacer()
INodePlacer
instance that places the non-assistant children.
These non-assistant child nodes will be placed below the assistant child nodes and are arranged by the given
INodePlacer
. Non-assistant child nodes are the ones that are not marked in the IDataProvider
registered with ASSISTANT_NODE_DPKEY
.
SimpleNodePlacer
. A SimpleNodePlacer
with centered
local roots is used.ASSISTANT_NODE_DPKEY
,
setChildNodePlacer(INodePlacer)
public double getSpacing()
INodePlacer
.
The spacing needs to be non-negative.
getSpacing
in class AbstractRotatableNodePlacer
IllegalArgumentException
- if the given spacing is negativesetSpacing(double)
public TreeLayout.SubtreeShape placeSubtree(IDataProvider nodeShapeProvider, IDataProvider subtreeShapeProvider, LayoutGraph graph, Node localRoot, ParentConnectorDirection parentConnectorDirection)
TreeLayout.SubtreeShape
s to an instance of LeftRightNodePlacer
.
The LeftRightNodePlacer
places all assistant nodes left and right of the local root node. The TreeLayout.SubtreeShape
associated with the dummy node which contains
TreeLayout.SubtreeShape
s of the non-assistant nodes is placed below the assistant nodes, center-aligned with
respect to the local root node.
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
containing the local root and all assistant nodes and non-assistant nodesAbstractRotatableNodePlacer.placeSubtree(Node, ParentConnectorDirection)
protected RotatedSubtreeShape placeSubtree(Node localRoot, ParentConnectorDirection parentConnectorDirection)
placeSubtree
in class AbstractRotatableNodePlacer
IllegalStateException
- if this method is calledINodePlacer
for the assistant nodes and
the placer for non-assistant nodes
by method
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 nodepublic void setChildNodePlacer(INodePlacer value)
INodePlacer
instance that places the non-assistant children.
These non-assistant child nodes will be placed below the assistant child nodes and are arranged by the given
INodePlacer
. Non-assistant child nodes are the ones that are not marked in the IDataProvider
registered with ASSISTANT_NODE_DPKEY
.
SimpleNodePlacer
. A SimpleNodePlacer
with centered
local roots is used.value
- the child node placer for the non-assistant childrenASSISTANT_NODE_DPKEY
,
getChildNodePlacer()
public void setSpacing(double value)
INodePlacer
.
The spacing needs to be non-negative.
setSpacing
in class AbstractRotatableNodePlacer
IllegalArgumentException
- if the given spacing is negativevalue
- the distance between subtreesgetSpacing()