Search this API

y.layout.tree
Class AbstractNodePlacer

java.lang.Object
  extended by y.layout.tree.AbstractNodePlacer
All Implemented Interfaces:
java.lang.Cloneable, NodePlacer
Direct Known Subclasses:
ARNodePlacer, CompactNodePlacer, DefaultNodePlacer, TreeDrawer.HierarchicTreePlacer

public abstract class AbstractNodePlacer
extends java.lang.Object
implements NodePlacer, java.lang.Cloneable

Abstract base class for implementations of the NodePlacer 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 NodePlacer interface.

Subclasses just need to override the following two abstract methods: placeSubtree(Node, byte) and determineChildConnectors(Node, DataMap).

 

Field Summary
protected  LayoutGraph graph
          The graph instance this class is working on.
 
Fields inherited from interface y.layout.tree.NodePlacer
DIRECTION_ANY, DIRECTION_EAST, DIRECTION_NONE, DIRECTION_NORTH, DIRECTION_SOUTH, DIRECTION_WEST
 
Constructor Summary
AbstractNodePlacer()
          Creates a new instance of AbstractNodePlacer.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this NodePlacer instance.
 Processor createProcessor(GenericTreeLayouter layouter, LayoutGraph graph, Node currentRoot)
          Creates an optional Processor for pre- and post-processing.
protected abstract  byte determineChildConnector(Node child)
          Determines a connector direction for the given child node.
 void determineChildConnectors(Node localRoot, DataMap connectorMap)
          Provides the direction of the connector to the SubtreeShape for each child node.
protected  GenericTreeLayouter.SubtreeShape getNodeShape(Node node)
          Returns the GenericTreeLayouter.SubtreeShape for the given node.
protected  GenericTreeLayouter.SubtreeShape getSubtreeShape(Node node)
          Returns the GenericTreeLayouter.SubtreeShape for the subtree rooted at the given node.
 GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider, DataProvider subtreeShapeProvider, LayoutGraph graph, Node localRoot, byte parentConnectorDirection)
          Initializes the local data structures and then delegates the work to the abstract variant of this method (placeSubtree(Node, byte))
protected abstract  GenericTreeLayouter.SubtreeShape placeSubtree(Node localRoot, byte parentConnectorDirection)
          Arranges the local root relative to the GenericTreeLayouter.SubtreeShape of its children.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graph

protected LayoutGraph graph
The graph instance this class is working on.

Constructor Detail

AbstractNodePlacer

public AbstractNodePlacer()
Creates a new instance of AbstractNodePlacer.

Method Detail

createProcessor

public Processor createProcessor(GenericTreeLayouter layouter,
                                 LayoutGraph graph,
                                 Node currentRoot)
Creates an optional Processor for pre- and post-processing.

This implementation returns null. Hence, no pre- or post-processing will be done.

Specified by:
createProcessor in interface NodePlacer
Parameters:
layouter - the current GenericTreeLayouter instance
graph - the input graph
currentRoot - the root node handled by this NodePlacer
Returns:
null

getSubtreeShape

protected GenericTreeLayouter.SubtreeShape getSubtreeShape(Node node)
Returns the GenericTreeLayouter.SubtreeShape for the subtree rooted at the given node.

This is a convenience method that retrieves a GenericTreeLayouter.SubtreeShape of a complete subtree from the corresponding DataProvider.

This method is used in placeSubtree(Node, byte) for retrieving the GenericTreeLayouter.SubtreeShapes for the subtrees that are arranged. It may be overridden to return a custom implementation of GenericTreeLayouter.SubtreeShape.

 
This method can first be called during the execution of placeSubtree(Node, byte). Before, the DataProvider for querying results will not have been initialized yet.
Parameters:
node - the local root node
Returns:
the GenericTreeLayouter.SubtreeShape of the subtree rooted at the given local root node

getNodeShape

protected GenericTreeLayouter.SubtreeShape getNodeShape(Node node)
Returns the GenericTreeLayouter.SubtreeShape for the given node.

This is a convenience method that retrieves a GenericTreeLayouter.SubtreeShape for a single node from the corresponding DataProvider.

This method is used in placeSubtree(Node, byte) for retrieving the GenericTreeLayouter.SubtreeShapes for the local root nodes. It may be overridden to return a custom implementation of GenericTreeLayouter.SubtreeShape.

 
This method can first be called during the execution of placeSubtree(Node, byte). Otherwise, the DataProvider for querying results will not have been initialized yet.
Parameters:
node - the node
Returns:
the GenericTreeLayouter.SubtreeShape for the given node

determineChildConnectors

public void determineChildConnectors(Node localRoot,
                                     DataMap connectorMap)
Provides the direction of the connector to the SubtreeShape for each child node.

This implementation uses determineChildConnector(Node) to retrieve the direction for the connectors.

Specified by:
determineChildConnectors in interface NodePlacer
Parameters:
localRoot - the local root node
connectorMap - the map that must be used for storing the direction specifiers of the child nodes

determineChildConnector

protected abstract byte determineChildConnector(Node child)
Determines a connector direction for the given child node.

This method is used in determineChildConnectors(Node, DataMap) and must be implemented by subclasses.

Parameters:
child - the child node
Returns:
a direction specifier as defined in the NodePlacer interface

placeSubtree

protected abstract GenericTreeLayouter.SubtreeShape placeSubtree(Node localRoot,
                                                                 byte parentConnectorDirection)
Arranges the local root relative to the GenericTreeLayouter.SubtreeShape of its children.

This is the main method that must be implemented by subclasses. It is called by placeSubtree(DataProvider, DataProvider, LayoutGraph, Node, byte).

Parameters:
localRoot - the local root node
parentConnectorDirection - the direction of the connector
Returns:
a GenericTreeLayouter.SubtreeShape instance that describes the shape of the whole subtree rooted at the given local root

placeSubtree

public GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider,
                                                     DataProvider subtreeShapeProvider,
                                                     LayoutGraph graph,
                                                     Node localRoot,
                                                     byte parentConnectorDirection)
Initializes the local data structures and then delegates the work to the abstract variant of this method (placeSubtree(Node, byte))

Specified by:
placeSubtree in interface NodePlacer
Parameters:
nodeShapeProvider - the DataProvider for obtaining an initial shape of the root node
subtreeShapeProvider - the DataProvider for accessing the pre-calculated shapes of the subtrees
graph - the input graph
localRoot - the root of the subtree that should be arranged by this method
parentConnectorDirection - the direction specifier for the connector of the local root node to its parent node
Returns:
the merged GenericTreeLayouter.SubtreeShape for the subtree rooted at the local root node
See Also:
placeSubtree(Node, byte)

clone

public java.lang.Object clone()
Returns a clone of this NodePlacer instance.

Overrides:
clone in class java.lang.Object
Returns:
an exact copy of this NodePlacer instance

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.