Search this API

y.layout.tree
Class GridNodePlacer

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

public class GridNodePlacer
extends AbstractRotatableNodePlacer

This NodePlacer arranges nodes into a grid. The grid consists of a number of columns. Rows are filled automatically by the placer. Each row is filled from left to right. When all columns in a row are filled, the next row is created.


Nested Class Summary
 
Nested classes/interfaces inherited from class y.layout.tree.AbstractRotatableNodePlacer
AbstractRotatableNodePlacer.Matrix, AbstractRotatableNodePlacer.RootAlignment
 
Field Summary
static Object GRID_DPKEY
          Key which can be used to register a data provider that tells the placer in which row a given node should be put into.
 
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
GridNodePlacer()
          Creates a grid placer with the modification matrix AbstractRotatableNodePlacer.Matrix.DEFAULT
GridNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
          Creates grid placer with a given modification matrix.
GridNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix, AbstractRotatableNodePlacer.RootAlignment rootAlignment)
          Creates grid placer with a given modification matrix and the horizontal alignment of the root.
 
Method Summary
 Comparator createFromSketchComparator()
          Creates a comparator that uses the positions of the target nodes to order edges.
protected  byte determineChildConnector(Node child)
          Returns NodePlacer.DIRECTION_NORTH.
 AbstractRotatableNodePlacer.RootAlignment getRootAlignment()
          Returns the horizontal alignment of the root node.
protected  y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot, byte parentConnectorDirection)
          Places the children in a grid.
 void setRootAlignment(AbstractRotatableNodePlacer.RootAlignment rootAlignment)
          Sets the horizontal alignment of the root node.
 
Methods inherited from class y.layout.tree.AbstractRotatableNodePlacer
createComparator, createProcessor, createRootNodeShape, createSubtreeShape, determineChildConnectors, getModificationMatrix, getPortConstraint, getSourcePointAbs, getSpacing, placeSubtree, setSpacing, translateDirectionToModel, translateDirectionToReal, translatePoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GRID_DPKEY

public static final Object GRID_DPKEY
Key which can be used to register a data provider that tells the placer in which row a given node should be put into. For each node, the row is determined using the data provider's getInt method. If no provider is specified, all nodes will be placed in one row.

Constructor Detail

GridNodePlacer

public GridNodePlacer()
Creates a grid placer with the modification matrix AbstractRotatableNodePlacer.Matrix.DEFAULT


GridNodePlacer

public GridNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
Creates grid placer with a given modification matrix.


GridNodePlacer

public GridNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix,
                      AbstractRotatableNodePlacer.RootAlignment rootAlignment)
Creates grid placer with a given modification matrix and the horizontal alignment of the root.

Method Detail

determineChildConnector

protected byte determineChildConnector(Node child)
Returns NodePlacer.DIRECTION_NORTH.

Specified by:
determineChildConnector in class AbstractRotatableNodePlacer
Parameters:
child - the child node
Returns:
NodePlacer.DIRECTION_NORTH.

placeSubtree

protected y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot,
                                                         byte parentConnectorDirection)
Places the children in a grid.

Specified by:
placeSubtree in class AbstractRotatableNodePlacer
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

createFromSketchComparator

public Comparator createFromSketchComparator()
Creates a comparator that uses the positions of the target nodes to order edges. For two edges e1=(s,t1) and e2=(s,t2), e1 is considered to be less than e2, if t1's row is less than t2's row. If both t1 and t2 lie in the same row, then the nodes' x-coordinates are compared.

Specified by:
createFromSketchComparator in interface FromSketchNodePlacer
Overrides:
createFromSketchComparator in class AbstractRotatableNodePlacer
Returns:
a comparator that orders edges lexicographically by row and x-coordinate of their target nodes.
See Also:
GRID_DPKEY

getRootAlignment

public AbstractRotatableNodePlacer.RootAlignment getRootAlignment()
Returns the horizontal alignment of the root node.

Returns:
the horizontal alignment of the root node.

setRootAlignment

public void setRootAlignment(AbstractRotatableNodePlacer.RootAlignment rootAlignment)
Sets the horizontal alignment of the root node.


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