public abstract class AbstractNodePlacer extends Object implements INodePlacer, ICloneable, Cloneable
INodePlacer
interface.
This class provides convenience methods for sub-tasks that are often used during the arrangement of a local root and its
children. It also offers prepared implementations for the methods of the INodePlacer
interface.
Subclasses just need to override the following two abstract methods: placeSubtree(Node, ParentConnectorDirection)
and determineChildConnectors(Node, IDataMap)
.
Modifier and Type | Field and Description |
---|---|
protected LayoutGraph |
graph
The graph instance this class is working on.
|
Constructor and Description |
---|
AbstractNodePlacer()
Creates a new instance of
AbstractNodePlacer . |
Modifier and Type | Method and Description |
---|---|
AbstractNodePlacer |
clone()
Returns a clone of this
INodePlacer instance. |
IProcessor |
createProcessor(TreeLayout layouter,
LayoutGraph graph,
Node currentRoot)
Creates an optional
IProcessor for pre- and post-processing. |
protected abstract ParentConnectorDirection |
determineChildConnector(Node child)
Determines a connector direction for the given child node.
|
void |
determineChildConnectors(Node localRoot,
IDataMap connectorMap)
Provides the direction of the connector to the
SubtreeShape for each child node. |
protected TreeLayout.SubtreeShape |
getNodeShape(Node node)
Returns the
TreeLayout.SubtreeShape for the given node. |
protected TreeLayout.SubtreeShape |
getSubtreeShape(Node node)
Returns the
TreeLayout.SubtreeShape for the subtree rooted at the given node. |
TreeLayout.SubtreeShape |
placeSubtree(IDataProvider nodeShapeProvider,
IDataProvider subtreeShapeProvider,
LayoutGraph graph,
Node localRoot,
ParentConnectorDirection parentConnectorDirection)
Initializes the local data structures and then delegates the work to the abstract variant of this method
(
placeSubtree(Node, ParentConnectorDirection) ). |
protected abstract TreeLayout.SubtreeShape |
placeSubtree(Node localRoot,
ParentConnectorDirection parentConnectorDirection)
Arranges the local root relative to the
TreeLayout.SubtreeShape of its children. |
protected LayoutGraph graph
public AbstractNodePlacer()
AbstractNodePlacer
.public AbstractNodePlacer clone()
INodePlacer
instance.clone
in interface ICloneable
clone
in class Object
INodePlacer
instanceObject.clone()
public IProcessor createProcessor(TreeLayout layouter, LayoutGraph graph, Node currentRoot)
IProcessor
for pre- and post-processing.
This implementation returns null
. Hence, no pre- or post-processing will be done.
createProcessor
in interface INodePlacer
layouter
- the current TreeLayout
instancegraph
- the input graphcurrentRoot
- the root node handled by this INodePlacer
null
protected abstract ParentConnectorDirection determineChildConnector(Node child)
This method is used in determineChildConnectors(Node, IDataMap)
and must be implemented by subclasses.
child
- the child nodeINodePlacer
interfacepublic void determineChildConnectors(Node localRoot, IDataMap connectorMap)
SubtreeShape
for each child node.
This implementation uses determineChildConnector(Node)
to retrieve the direction for the connectors.
determineChildConnectors
in interface INodePlacer
localRoot
- the local root nodeconnectorMap
- the map that must be used for storing the direction specifiers of the child nodesprotected TreeLayout.SubtreeShape getNodeShape(Node node)
TreeLayout.SubtreeShape
for the given node.
This is a convenience method that retrieves a TreeLayout.SubtreeShape
for a single node from the corresponding
IDataProvider
.
This method is used in placeSubtree(Node, ParentConnectorDirection)
for retrieving the
TreeLayout.SubtreeShape
s for the local root nodes. It may be overridden to return a custom implementation of
TreeLayout.SubtreeShape
.
placeSubtree(Node, ParentConnectorDirection)
.
Otherwise, the IDataProvider
for querying results will not have been initialized yet.node
- the nodeTreeLayout.SubtreeShape
for the given nodeprotected TreeLayout.SubtreeShape getSubtreeShape(Node node)
TreeLayout.SubtreeShape
for the subtree rooted at the given node.
This is a convenience method that retrieves a TreeLayout.SubtreeShape
of a complete subtree from the
corresponding IDataProvider
.
This method is used in placeSubtree(Node, ParentConnectorDirection)
for retrieving the
TreeLayout.SubtreeShape
s for the subtrees that are arranged. It may be overridden to return a custom
implementation of TreeLayout.SubtreeShape
.
placeSubtree(Node, ParentConnectorDirection)
. Before,
the IDataProvider
for querying results will not have been initialized yet.node
- the local root nodeTreeLayout.SubtreeShape
of the subtree rooted at the given local root nodepublic TreeLayout.SubtreeShape placeSubtree(IDataProvider nodeShapeProvider, IDataProvider subtreeShapeProvider, LayoutGraph graph, Node localRoot, ParentConnectorDirection parentConnectorDirection)
placeSubtree(Node, ParentConnectorDirection)
).placeSubtree
in interface INodePlacer
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 nodeplaceSubtree(Node, ParentConnectorDirection)
protected abstract TreeLayout.SubtreeShape placeSubtree(Node localRoot, ParentConnectorDirection parentConnectorDirection)
TreeLayout.SubtreeShape
of its children.
This is the main method that must be implemented by subclasses. It is called by
placeSubtree(IDataProvider, IDataProvider, LayoutGraph, Node, ParentConnectorDirection)
.
localRoot
- the local root nodeparentConnectorDirection
- the direction of the connectorTreeLayout.SubtreeShape
instance that describes the shape of the whole subtree rooted at the given local root