Search this API

y.layout.tree
Class LeftRightPlacer

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

public class LeftRightPlacer
extends AbstractRotatableNodePlacer

The LeftRightPlacer is a NodePlacer that arranges the Nodes on the left and right side of a vertical bus.


Nested Class Summary
static class LeftRightPlacer.LeftRightDataProvider
          Utility class providing a method to determine if a given node is aligned left (true) or right (false) to the parent node.
 
Nested classes/interfaces inherited from class y.layout.tree.AbstractRotatableNodePlacer
AbstractRotatableNodePlacer.Matrix, AbstractRotatableNodePlacer.RootAlignment
 
Field Summary
static Object LEFT_RIGHT_DPKEY
          Key which can be used to register a data provider that tells the node placer whether the node shall be placed on the left or right side.
 
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
LeftRightPlacer()
          Creates a LeftRightPlacer with the default modificationMatrix.
LeftRightPlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
          Creates a LeftRightPlacer with the given modificationMatrix.
 
Method Summary
 Comparator createComparator()
          Returns a comparator for edges.
protected  byte determineChildConnector(Node child)
          Throws IllegalStateException, should not be reached.
 void determineChildConnectors(Node localRoot, DataMap connectorMap)
          Determines the direction the children should place their connectors.
 double getHorizontalDistance()
          Returns the horizontal distance/spacing between subtree shapes.
 double getVerticalDistance()
          Returns the vertical distance/spacing between subtree shapes.
 boolean isPlaceLastOnBottom()
          Returns whether or not the last child is placed at the bottom of the other.
protected  y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot, byte parentConnectorDirection)
          Places the shapes of the children on the left and right side of a vertical bus.
 void setHorizontalDistance(double distance)
          Specifies the horizontal distance/spacing between subtree shapes.
 void setPlaceLastOnBottom(boolean placeLastOnBottom)
          Specifies whether or not the last child is placed at the bottom of the other.
 void setSpacing(double spacing)
          Specifies the spacing between subtrees this NodePlacer is arranging.
 void setVerticalDistance(double distance)
          Specifies the vertical distance/spacing between subtree shapes.
 
Methods inherited from class y.layout.tree.AbstractRotatableNodePlacer
createFromSketchComparator, createProcessor, createRootNodeShape, createSubtreeShape, getModificationMatrix, getPortConstraint, getSourcePointAbs, getSpacing, placeSubtree, translateDirectionToModel, translateDirectionToReal, translatePoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT_RIGHT_DPKEY

public static final Object LEFT_RIGHT_DPKEY
Key which can be used to register a data provider that tells the node placer whether the node shall be placed on the left or right side. If no provider is specified, the nodes will be placed alternating from left to right. The provider should return true if the node shall be placed on the left side.

Constructor Detail

LeftRightPlacer

public LeftRightPlacer()
Creates a LeftRightPlacer with the default modificationMatrix.


LeftRightPlacer

public LeftRightPlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
Creates a LeftRightPlacer with the given modificationMatrix.

Method Detail

getHorizontalDistance

public double getHorizontalDistance()
Returns the horizontal distance/spacing between subtree shapes.

By default, a value of 20 is used.

Returns:
the horizontal distance/spacing between subtree shapes.
See Also:
setHorizontalDistance(double), getVerticalDistance(), setVerticalDistance(double)

setHorizontalDistance

public void setHorizontalDistance(double distance)
Specifies the horizontal distance/spacing between subtree shapes.

By default, a value of 20 is used.

Parameters:
distance - the horizontal distance/spacing between subtree shapes.
See Also:
getHorizontalDistance(), getVerticalDistance(), setVerticalDistance(double)

getVerticalDistance

public double getVerticalDistance()
Returns the vertical distance/spacing between subtree shapes.

By default, a value of 20 is used.

Returns:
the vertical distance/spacing between subtree shapes.
See Also:
setVerticalDistance(double), getHorizontalDistance(), setHorizontalDistance(double)

setVerticalDistance

public void setVerticalDistance(double distance)
Specifies the vertical distance/spacing between subtree shapes.

By default, a value of 20 is used.

Parameters:
distance - the vertical distance/spacing between subtree shapes.
See Also:
getVerticalDistance(), getHorizontalDistance(), setHorizontalDistance(double)

setSpacing

public void setSpacing(double spacing)
Specifies the spacing between subtrees this NodePlacer is arranging. Calls
setHorizontalDistance(spacing);
setVerticalDistance(spacing);

Overrides:
setSpacing in class AbstractRotatableNodePlacer
See Also:
setHorizontalDistance(double), setVerticalDistance(double)

determineChildConnectors

public void determineChildConnectors(Node localRoot,
                                     DataMap connectorMap)
Determines the direction the children should place their connectors.

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

determineChildConnector

protected byte determineChildConnector(Node child)
Throws IllegalStateException, should not be reached.

Specified by:
determineChildConnector in class AbstractRotatableNodePlacer
Throws:
IllegalStateException - always.
Parameters:
child - the child node
Returns:
a byte constant as defined in the NodePlacer interface

placeSubtree

protected y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot,
                                                         byte parentConnectorDirection)
Places the shapes of the children on the left and right side of a vertical bus.

Specified by:
placeSubtree in class AbstractRotatableNodePlacer
Parameters:
localRoot - the local root node
parentConnectorDirection - the direction of the connector shape
Returns:
the new subtree shape

isPlaceLastOnBottom

public boolean isPlaceLastOnBottom()
Returns whether or not the last child is placed at the bottom of the other.

By default, this feature is enabled.

Returns:
true if the last child is placed at the bottom of the other; false otherwise.

setPlaceLastOnBottom

public void setPlaceLastOnBottom(boolean placeLastOnBottom)
Specifies whether or not the last child is placed at the bottom of the other.

By default, this feature is enabled.

Parameters:
placeLastOnBottom - true if enabled; false otherwise.

createComparator

public Comparator createComparator()
Returns a comparator for edges. The comparator applies the modification matrix of the LeftRightPlacer and returns

Overrides:
createComparator in class AbstractRotatableNodePlacer

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