Search this API

y.layout.tree
Class DelegatingNodePlacer

java.lang.Object
  extended by y.layout.tree.AbstractRotatableNodePlacer
      extended by y.layout.tree.DelegatingNodePlacer
All Implemented Interfaces:
FromSketchNodePlacer, NodePlacer

public class DelegatingNodePlacer
extends AbstractRotatableNodePlacer

DelegatingNodePlacer delegates the arrangement of the children to two different NodePlacers.

Layout Style

This NodePlacer can, for example, be used for creating mind maps or a playing schedule of a sports competition.


There are two subtrees that are placed above and below the root; Both subtrees consist of two subtrees that are placed left and right of their local root

 

Nested Class Summary
 
Nested classes/interfaces inherited from class y.layout.tree.AbstractRotatableNodePlacer
AbstractRotatableNodePlacer.Matrix, AbstractRotatableNodePlacer.RootAlignment
 
Field Summary
static byte HORIZONTAL
          Deprecated.  
static java.lang.Object LEFT_RIGHT_DPKEY
          A DataProvider key for dividing the children into two sets If there is no DataProvider registered with this key, half of the nodes are placed left of the root and the remaining nodes are placed right of the root.
static byte VERTICAL
          Deprecated.  
 
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
DelegatingNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix, NodePlacer placerUpperLeft, NodePlacer placerLowerRight)
          Creates a new DefaultNodePlacer instance with default settings using the given modification matrix and the given node placers as delegates.
 
Method Summary
 Processor createProcessor(GenericTreeLayouter layouter, LayoutGraph graph, Node currentRoot)
          Creates a Processor that partitions child nodes of the current root node into two subsets.
protected  byte determineChildConnector(Node child)
          Determines a connector direction for the given child node.
 void determineChildConnectors(Node localRoot, DataMap connectorMap)
          Does nothing.
protected  NodeList getLowerRightChildren(Node localRoot, LayoutGraph graph)
          Returns all lower-right children of the local root node.
 byte getOrientation()
          Deprecated.  
 NodePlacer getPlacerLowerRight()
          Returns the NodePlacer instance that will arrange the lower-right part of the graph.
 NodePlacer getPlacerUpperLeft()
          Returns the NodePlacer instance that will arrange the upper-left part of the graph.
protected  NodeList getUpperLeftChildren(Node localRoot, LayoutGraph graph)
          Returns all upper-left children of the local root node.
 GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider, DataProvider subtreeShapeProvider, LayoutGraph graph, Node localRoot, byte parentConnectorDirection)
          Places the GenericTreeLayouter.SubtreeShapes of the child nodes using the two delegate node placers retrieved with getPlacerUpperLeft() and getPlacerLowerRight().
protected  y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot, byte parentConnectorDirection)
          Arranges the local root relative to the subtree shape of its children.
 void setOrientation(byte orientation)
          Deprecated.  
 
Methods inherited from class y.layout.tree.AbstractRotatableNodePlacer
createComparator, createFromSketchComparator, createRootNodeShape, createSubtreeShape, getModificationMatrix, getPortConstraint, getSourcePointAbs, getSpacing, setSpacing, translateDirectionToModel, translateDirectionToReal, translatePoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HORIZONTAL

public static final byte HORIZONTAL
Deprecated. 
Orientation specifier that defines that node shapes are aligned with the x-axis.

See Also:
setOrientation(byte), Constant Field Values

VERTICAL

public static final byte VERTICAL
Deprecated. 
Orientation specifier that defines that node shapes are aligned with the y-axis.

See Also:
setOrientation(byte), Constant Field Values

LEFT_RIGHT_DPKEY

public static final java.lang.Object LEFT_RIGHT_DPKEY
A DataProvider key for dividing the children into two sets

If there is no DataProvider registered with this key, half of the nodes are placed left of the root and the remaining nodes are placed right of the root.

Constructor Detail

DelegatingNodePlacer

public DelegatingNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix,
                            NodePlacer placerUpperLeft,
                            NodePlacer placerLowerRight)
Creates a new DefaultNodePlacer instance with default settings using the given modification matrix and the given node placers as delegates.

Parameters:
modificationMatrix - the transformation matrix
placerUpperLeft - the first delegate NodePlacer which places the left subtrees
placerLowerRight - the second delegate NodePlacer which places the right subtrees
See Also:
LEFT_RIGHT_DPKEY
Method Detail

createProcessor

public Processor createProcessor(GenericTreeLayouter layouter,
                                 LayoutGraph graph,
                                 Node currentRoot)
Creates a Processor that partitions child nodes of the current root node into two subsets.

In a pre-processing step the child nodes are divided into an upper-left and a lower-right subset. The first set is arranged using the first delegate, the second set is arranged using the second delegate. To be able to delegate to different NodePlacers this Processor adds dummy nodes to which it assigns the according NodePlacers.

The changes to the graph are restored in the post-processing step.

Specified by:
createProcessor in interface NodePlacer
Overrides:
createProcessor in class AbstractRotatableNodePlacer
Parameters:
layouter - the current GenericTreeLayouter instance
graph - the input graph
currentRoot - the root node handled by this NodePlacer
Returns:
null
See Also:
getPlacerLowerRight(), getPlacerUpperLeft()

determineChildConnectors

public void determineChildConnectors(Node localRoot,
                                     DataMap connectorMap)
Does nothing. Since the DelegatingNodePlacer always places one part of the tree on one side and the remaining tree on the opposite side, it doesn't need to calculate the directions of the connectors.

Specified by:
determineChildConnectors in interface NodePlacer
Overrides:
determineChildConnectors in class AbstractRotatableNodePlacer
Parameters:
localRoot - the local root node
connectorMap - the map that must be used for storing the direction specifiers of the child nodes
See Also:
AbstractRotatableNodePlacer.determineChildConnector(Node)

placeSubtree

public GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider,
                                                     DataProvider subtreeShapeProvider,
                                                     LayoutGraph graph,
                                                     Node localRoot,
                                                     byte parentConnectorDirection)
Places the GenericTreeLayouter.SubtreeShapes of the child nodes using the two delegate node placers retrieved with getPlacerUpperLeft() and getPlacerLowerRight().

Specified by:
placeSubtree in interface NodePlacer
Overrides:
placeSubtree in class AbstractRotatableNodePlacer
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:
AbstractRotatableNodePlacer.placeSubtree(Node, byte)

getLowerRightChildren

protected NodeList getLowerRightChildren(Node localRoot,
                                         LayoutGraph graph)
Returns all lower-right children of the local root node.

Which children belong to this list is determined using the DataProvider registered with LEFT_RIGHT_DPKEY. If no such DataProvider is registered, the second half of the children is returned.

These children are placed using the NodePlacer returned by getPlacerLowerRight().

Parameters:
localRoot - the local root node
graph - the input graph
Returns:
the list of lower-right child Nodes
See Also:
LEFT_RIGHT_DPKEY

getUpperLeftChildren

protected NodeList getUpperLeftChildren(Node localRoot,
                                        LayoutGraph graph)
Returns all upper-left children of the local root node.

Which children belong to this list is determined using the DataProvider registered with LEFT_RIGHT_DPKEY. If no such DataProvider is registered, the first half of the children is returned.

These children are placed using the NodePlacer returned by getPlacerUpperLeft().

Parameters:
localRoot - the local root node
graph - the input graph
Returns:
the list of upper-left child Nodes
See Also:
LEFT_RIGHT_DPKEY

determineChildConnector

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

Specified by:
determineChildConnector in class AbstractRotatableNodePlacer
 
This method should not be called! Since the direction of the connectors is not used by determineChildConnectors(Node, DataMap), it does not call this method.
Parameters:
child - the child node
Returns:
a direction specifier as defined in the NodePlacer interface
Throws:
java.lang.IllegalStateException - if this method is called

placeSubtree

protected y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot,
                                                         byte parentConnectorDirection)
Arranges the local root relative to the subtree shape of its children.

Specified by:
placeSubtree in class AbstractRotatableNodePlacer
 
This method should not be called! Placing subtrees is delegated to the upper-left and the lower-right node placer placeSubtree(DataProvider, DataProvider, LayoutGraph, Node, byte).
Parameters:
localRoot - the local root node
parentConnectorDirection - the direction specifier for the connector of the local root node to its parent node
Returns:
the merged subtree shape that contains the local root node and all its children
Throws:
java.lang.IllegalStateException - if this method is called

setOrientation

public void setOrientation(byte orientation)
Deprecated. 

Specifies the orientation according to which node shapes are aligned. Depending on the orientation, the shapes are aligned with the x-axis or y-axis.

Default Value:
The default value is HORIZONTAL
Parameters:
orientation - one of the valid orientation specifiers
Throws:
java.lang.IllegalArgumentException - if the orientation specifier is unknown

getOrientation

public byte getOrientation()
Deprecated. 

Returns the orientation according to which node shapes are aligned. Depending on the orientation, the shapes are aligned with the x-axis or y-axis.

Returns:
one of the valid orientation specifiers
See Also:
setOrientation(byte)

getPlacerLowerRight

public NodePlacer getPlacerLowerRight()
Returns the NodePlacer instance that will arrange the lower-right part of the graph.

Returns:
the lower-right NodePlacer
See Also:
getPlacerUpperLeft(), getLowerRightChildren(Node, LayoutGraph)

getPlacerUpperLeft

public NodePlacer getPlacerUpperLeft()
Returns the NodePlacer instance that will arrange the upper-left part of the graph.

Returns:
the upper-left NodePlacer
See Also:
getPlacerLowerRight(), getUpperLeftChildren(Node, LayoutGraph)

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