Search this API

y.layout.tree
Class AbstractNodePlacer

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

public abstract class AbstractNodePlacer
extends Object
implements NodePlacer, Cloneable

Utility class that serves as a basis for implementations of the NodePlacer interface. It provides convenience methods for often used sub tasks during a layout. Subclasses need to override the two abstract methods only.


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
 Object clone()
          Overwritten to support cloning.
 Processor createProcessor(GenericTreeLayouter layouter, LayoutGraph graph, Node currentRoot)
          Creates an optional Processor for pre- and post-processing.
protected abstract  byte determineChildConnector(Node child)
          This method must be implemented by subclasses.
 void determineChildConnectors(Node localRoot, DataMap connectorMap)
          This method initializes internal data structures and then uses the abstract method to determine the child node connector directions.
protected  GenericTreeLayouter.SubtreeShape getNodeShape(Node node)
          Convenience method that queries the DataProvider for the shape of a single node as a SubtreeShape instance.
protected  GenericTreeLayouter.SubtreeShape getSubtreeShape(Node node)
          Convenience method that queries the DataProvider for a SubtreeShape.
 GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider, DataProvider subtreeShapeProvider, LayoutGraph graph, Node localRoot, byte parentConnectorDirection)
          This method initializes the local data structures and then delegates the work to the abstract variant.
protected abstract  GenericTreeLayouter.SubtreeShape placeSubtree(Node localRoot, byte parentConnectorDirection)
          The main placeSubtree method that must be implemented by subclasses.
 
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.

Specified by:
createProcessor in interface NodePlacer
Parameters:
layouter -
graph - the actual graph
currentRoot - the actual root node for this node placer
Returns:
a Processor or null

getSubtreeShape

protected GenericTreeLayouter.SubtreeShape getSubtreeShape(Node node)
Convenience method that queries the DataProvider for a SubtreeShape.
This method can be called during the execution of placeSubtree(Node, byte)

Parameters:
node - the root node whose subtree shape will be returned in the form of a SubtreeShape instance
Returns:
an instance that can be modified

getNodeShape

protected GenericTreeLayouter.SubtreeShape getNodeShape(Node node)
Convenience method that queries the DataProvider for the shape of a single node as a SubtreeShape instance. This instance can be used to modify it and return it in the main placeSubtree method.
This method can be called during the execution of placeSubtree(Node, byte)

Parameters:
node - the node whose shape will be returned in the form of a SubtreeShape instance
Returns:
an instance that can be modified

determineChildConnectors

public void determineChildConnectors(Node localRoot,
                                     DataMap connectorMap)
This method initializes internal data structures and then uses the abstract method to determine the child node connector directions.

Specified by:
determineChildConnectors in interface NodePlacer
Parameters:
localRoot - the local root node
connectorMap - the map that will be used to store the values
See Also:
determineChildConnector(Node)

determineChildConnector

protected abstract byte determineChildConnector(Node child)
This method must be implemented by subclasses. It assigns a connector shape direction to each child.

Parameters:
child - the child node
Returns:
a byte constant as defined in the NodePlacer interface

placeSubtree

protected abstract GenericTreeLayouter.SubtreeShape placeSubtree(Node localRoot,
                                                                 byte parentConnectorDirection)
The main placeSubtree method that must be implemented by subclasses.

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

placeSubtree

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

Specified by:
placeSubtree in interface NodePlacer
Parameters:
nodeShapeProvider - this instance can be used to obtain an initial shape of the root node. This shape can then be merged with all the subtrees' shapes and finally be returned by this method.
subtreeShapeProvider - provides access to the pre-calculated shapes of the subtrees. It is guaranteed that at the time of the invocation of this method for every child node the subtree shape has already been calculated
graph - the graph which is to be laid out
localRoot - the root of the subtree that should be laid out by this method
parentConnectorDirection - the direction byte constant as it is defined in this interface, that must be used for initializing the connector of the localRoot node to the parent node of the localRoot node
Returns:
the shape of the whole subtree
See Also:
placeSubtree(Node, byte)

clone

public Object clone()
Overwritten to support cloning.

Overrides:
clone in class Object
Returns:
an exact copy of this instance

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