Search this API

y.layout.tree
Class AssistantPlacer

java.lang.Object
  extended by y.layout.tree.AbstractRotatableNodePlacer
      extended by y.layout.tree.AssistantPlacer
All Implemented Interfaces:
FromSketchNodePlacer, 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 boolean values. 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()
          Creates a comparator that compares edges of two assistant nodes with the comparator created by LeftRightPlacer and all other edges with the sketch comparator created by this placer's childNodePlacer.
static Comparator createCompoundComparator(Comparator assistantComparator, Comparator childComparator)
          Creates a comparator that compares edges connecting to assistant nodes with the given assistantComparator and all other edges with the given childComparator.
 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()
          Returns the child node placer for the non-assistant children.
protected  GenericTreeLayouter.SubtreeShape getNodeShape(Node node)
          Returns the subtree shape for the given child 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)
          Specifies the spacing between subtrees this NodePlacer is arranging.
 
Methods inherited from class y.layout.tree.AbstractRotatableNodePlacer
createFromSketchComparator, 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)
Returns the subtree shape for the given child node.

Parameters:
node - the child node the subtree shape is returned for.
Returns:
the subtree shape for the given 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
Specifies the spacing between subtrees this NodePlacer is arranging.

Overrides:
setSpacing in class AbstractRotatableNodePlacer

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 laying out the non-assistant children.

getChildNodePlacer

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

Returns:
the child node placer for the non-assistant children.

createComparator

public Comparator createComparator()
Creates a comparator that compares edges of two assistant nodes with the comparator created by LeftRightPlacer and all other edges with the sketch comparator created by this placer's childNodePlacer.

Overrides:
createComparator in class AbstractRotatableNodePlacer
Returns:
a comparator to compare two edges.
See Also:
setChildNodePlacer(NodePlacer), FromSketchNodePlacer.createFromSketchComparator()

createCompoundComparator

public static Comparator createCompoundComparator(Comparator assistantComparator,
                                                  Comparator childComparator)
Creates a comparator that compares edges connecting to assistant nodes with the given assistantComparator and all other edges with the given childComparator.

Parameters:
assistantComparator - the comparator for assistant edges
childComparator - the comparator for non-assistants edges
Returns:
a comparator that compares edges connecting to assistant nodes with the given assistantComparator and all other edges with the given childComparator.

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