y.layout.tree
Class AssistantPlacer

java.lang.Object
  extended by y.layout.tree.AbstractRotatableNodePlacer
      extended by y.layout.tree.AssistantPlacer
All Implemented Interfaces:
NodePlacer

public class AssistantPlacer
extends AbstractRotatableNodePlacer

The assistant placer is a NodePlacer that delegates the node placement to two different node placers depending on the type of the children.
The type of a child is recognized using a DataProvider providing booleans. The data provider is registered using the key ASSISTANT_DPKEY.
Assistant placer uses a LeftRightPlacer for those nodes the DataProvider returns true (they are understood as "assistants").
Below the assistants the other children are arranged using the childNodePlacer (settable using setChildNodePlacer(NodePlacer)).

 

Nested Class Summary
 
Nested classes/interfaces inherited from class y.layout.tree.AbstractRotatableNodePlacer
AbstractRotatableNodePlacer.Matrix, AbstractRotatableNodePlacer.RootAlignment
 
Field Summary
static Object ASSISTANT_DPKEY
          Contains a boolean for each node whether it is an assistant or not.
 
Fields inherited from class y.layout.tree.AbstractRotatableNodePlacer
createdChildren, graph, modificationMatrix, nodeShapeProvider, spacing, subtreeShapeProvider
 
Fields inherited from interface y.layout.tree.NodePlacer
DIRECTION_ANY, DIRECTION_EAST, DIRECTION_NONE, DIRECTION_NORTH, DIRECTION_SOUTH, DIRECTION_WEST
 
Constructor Summary
AssistantPlacer()
          Creates a default instance with horizontal orientation.
AssistantPlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
          Creates an AssistantPlacer for the given modification matrix.
 
Method Summary
 Comparator createComparator()
           
 Processor createProcessor(GenericTreeLayouter layouter, LayoutGraph graph, Node currentRoot)
          Creates a processor that creates a dummy node and changes the edges for the non-assistant children.
protected  byte determineChildConnector(Node child)
          This method must be implemented by subclasses.
 void determineChildConnectors(Node localRoot, DataMap connectorMap)
          Delegates to the the left right placer.
 NodePlacer getChildNodePlacer()
           
protected  GenericTreeLayouter.SubtreeShape getNodeShape(Node node)
           
 GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider, DataProvider subtreeShapeProvider, LayoutGraph graph, Node localRoot, byte parentConnectorDirection)
          Places the shapes.
protected  y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot, byte parentConnectorDirection)
          This method must be implemented by subclasses.
 void setChildNodePlacer(NodePlacer childNodePlacer)
          Sets the child node placer.
 void setSpacing(double spacing)
          Sets the spacing.
 
Methods inherited from class y.layout.tree.AbstractRotatableNodePlacer
createRootNodeShape, createSubtreeShape, getModificationMatrix, getPortConstraint, getSourcePointAbs, getSpacing, translateDirectionToModel, translateDirectionToReal, translatePoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASSISTANT_DPKEY

public static final Object ASSISTANT_DPKEY
Contains a boolean for each node whether it is an assistant or not.
True: Is assistant
False: Is not an assistant

Constructor Detail

AssistantPlacer

public AssistantPlacer()
Creates a default instance with horizontal orientation. Call to this(Matrix.DEFAULT)


AssistantPlacer

public AssistantPlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
Creates an AssistantPlacer for the given modification matrix.

Parameters:
modificationMatrix - the modification matrix that is used as translation matrix.
Method Detail

determineChildConnector

protected byte determineChildConnector(Node child)
Description copied from class: AbstractRotatableNodePlacer
This method must be implemented by subclasses. It is used to assigns a connector shape direction to each child.

Specified by:
determineChildConnector in class AbstractRotatableNodePlacer
Parameters:
child - the child node
Returns:
should not be called and throws a IllegalStateException

determineChildConnectors

public void determineChildConnectors(Node localRoot,
                                     DataMap connectorMap)
Delegates to the the left right placer.

Specified by:
determineChildConnectors in interface NodePlacer
Overrides:
determineChildConnectors in class AbstractRotatableNodePlacer
Parameters:
localRoot -
connectorMap -
See Also:
AbstractRotatableNodePlacer.determineChildConnector(Node)

getNodeShape

protected GenericTreeLayouter.SubtreeShape getNodeShape(Node node)
Parameters:
node - the child node the subtree shape is returned for
Returns:
the subtree shape for the child node

createProcessor

public Processor createProcessor(GenericTreeLayouter layouter,
                                 LayoutGraph graph,
                                 Node currentRoot)
Creates a processor that creates a dummy node and changes the edges for the non-assistant children.

Specified by:
createProcessor in interface NodePlacer
Overrides:
createProcessor in class AbstractRotatableNodePlacer
Parameters:
layouter -
graph -
currentRoot -
Returns:
the processor that changes the graph structure suitable for the AssistantPlacer

setSpacing

public void setSpacing(double spacing)
Description copied from class: AbstractRotatableNodePlacer
Sets the spacing. The spacing represents the space between the parts the NodePlacer is arranging

Overrides:
setSpacing in class AbstractRotatableNodePlacer
Parameters:
spacing - the spacing to be set

placeSubtree

public GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider,
                                                     DataProvider subtreeShapeProvider,
                                                     LayoutGraph graph,
                                                     Node localRoot,
                                                     byte parentConnectorDirection)
Places the shapes.

Specified by:
placeSubtree in interface NodePlacer
Overrides:
placeSubtree in class AbstractRotatableNodePlacer
Parameters:
nodeShapeProvider -
subtreeShapeProvider -
graph -
localRoot -
parentConnectorDirection -
Returns:
the shape of the whole subtree
See Also:
AbstractRotatableNodePlacer.placeSubtree(Node, byte)

placeSubtree

protected y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot,
                                                         byte parentConnectorDirection)
Description copied from class: AbstractRotatableNodePlacer
This method must be implemented by subclasses.

Specified by:
placeSubtree in class AbstractRotatableNodePlacer
Parameters:
localRoot - the local root node
parentConnectorDirection - the direction of the connector shape
Returns:
Should not be called - throws IllegalStateException

setChildNodePlacer

public void setChildNodePlacer(NodePlacer childNodePlacer)
Sets the child node placer. The child node placer is used to arrange the nodes that are not assistants. ASSISTANT_DPKEY

Parameters:
childNodePlacer - the node placer that will be used for layouting the non-assistant children

getChildNodePlacer

public NodePlacer getChildNodePlacer()
Returns:
the child node placer for the non-assistant children

createComparator

public Comparator createComparator()
Overrides:
createComparator in class AbstractRotatableNodePlacer
Returns:
null, because no suitable comparator exists for this node placer

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