Search this API

y.layout.tree
Class LayeredNodePlacer

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

public class LayeredNodePlacer
extends AbstractRotatableNodePlacer

This NodePlacer calculates and respects layers.

Warning: Changing the orientation within the LayeredNodePlacers will result in dubious problems.


Nested Class Summary
 
Nested classes/interfaces inherited from class y.layout.tree.AbstractRotatableNodePlacer
AbstractRotatableNodePlacer.Matrix, AbstractRotatableNodePlacer.RootAlignment
 
Field Summary
static Object DP_KEY_DISTANCE_TO_PARENT_MAP
          References a NodeMap that contains double values.
static int ORTHOGONAL_STYLE
          Layout style constant.
static int PLAIN_STYLE
          Layout style constant.
 
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
LayeredNodePlacer()
           
LayeredNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix, Object id)
          Default constructor.
 
Method Summary
 Processor createProcessor(GenericTreeLayouter layouter, LayoutGraph graph, Node currentRoot)
          Creates an processor that distributes the LayerRoot
protected  byte determineChildConnector(Node child)
          This method must be implemented by subclasses.
 double getBusAlignment()
          Returns the actual set bus alignment.
 Object getId()
          Returns the ID.
 double getLayerSpacing()
          Returns the spacing between two layers.
 AbstractRotatableNodePlacer.RootAlignment getRootAlignment()
          Returns the alignment strategy for the tree's root node.
 int getRoutingStyle()
          Returns the routing style.
 double getVerticalAlignment()
          Returns the relative vertical alignment of nodes within their respective layers.
 boolean isDendrogramStyleEnabled()
           
 boolean isPolylineLabelingEnabled()
          Returns whether polyline labeling is used.
protected  y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot, byte parentConnectorDirection)
          This method must be implemented by subclasses.
 void setBusAlignment(double busAlignment)
          Sets the vertical alignment of the bus
 void setDendrogramStyleEnabled(boolean enabled)
           
 void setLayerSpacing(double layerSpacing)
          Sets the spacing between two layers.
 void setPolylineLabelingEnabled(boolean polylineLabelingEnabled)
          Specifies whether polyline labeling should be used.
 void setRootAlignment(AbstractRotatableNodePlacer.RootAlignment rootAlignment)
          Specifies the alignment strategy for the tree's root node.
 void setRoutingStyle(int routingStyle)
          Sets the routing style.
 void setVerticalAlignment(double verticalAlignment)
          Sets the relative vertical alignment of nodes within their respective layers.
 
Methods inherited from class y.layout.tree.AbstractRotatableNodePlacer
createComparator, createFromSketchComparator, 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

DP_KEY_DISTANCE_TO_PARENT_MAP

public static final Object DP_KEY_DISTANCE_TO_PARENT_MAP
References a NodeMap that contains double values. Those values represent the distance between the center of the actual node and the center of its children


PLAIN_STYLE

public static final int PLAIN_STYLE
Layout style constant. Draw edges as straight lines.

See Also:
getRoutingStyle(), setRoutingStyle(int), Constant Field Values

ORTHOGONAL_STYLE

public static final int ORTHOGONAL_STYLE
Layout style constant. Draw edges orthogonally in a bus-like fashion.

See Also:
getRoutingStyle(), setRoutingStyle(int), Constant Field Values
Constructor Detail

LayeredNodePlacer

public LayeredNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix,
                         Object id)
Default constructor. Instantiates a new instance with the given modification matrix.

Parameters:
modificationMatrix - the translation for the NodePlacer

LayeredNodePlacer

public LayeredNodePlacer()
Method Detail

isDendrogramStyleEnabled

public boolean isDendrogramStyleEnabled()

setDendrogramStyleEnabled

public void setDendrogramStyleEnabled(boolean enabled)

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:
a byte constant as defined in the NodePlacer interface

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:
a SubtreeShape instance that describes the shape of the whole subtree

createProcessor

public Processor createProcessor(GenericTreeLayouter layouter,
                                 LayoutGraph graph,
                                 Node currentRoot)
Creates an processor that distributes the LayerRoot

Specified by:
createProcessor in interface NodePlacer
Overrides:
createProcessor in class AbstractRotatableNodePlacer
Parameters:
graph - the actual graph
currentRoot - the actual root node for this node placer
Returns:
a Processor or null

getRootAlignment

public AbstractRotatableNodePlacer.RootAlignment getRootAlignment()
Returns the alignment strategy for the tree's root node.


setRootAlignment

public void setRootAlignment(AbstractRotatableNodePlacer.RootAlignment rootAlignment)
Specifies the alignment strategy for the tree's root node.


getVerticalAlignment

public double getVerticalAlignment()
Returns the relative vertical alignment of nodes within their respective layers. A value of 0 means nodes are top aligned; a value of 1 means nodes are bottom aligned.

Defaults to 0.5, i.e. nodes are center aligned.

Returns:
the relative vertical alignment of nodes within their respective layers.
See Also:
setVerticalAlignment(double)

setVerticalAlignment

public void setVerticalAlignment(double verticalAlignment)
Sets the relative vertical alignment of nodes within their respective layers. A value of 0 means nodes are top aligned; a value of 1 means nodes are bottom aligned.

Defaults to 0.5, i.e. nodes are center aligned.

Parameters:
verticalAlignment - a value in [0, 1].
See Also:
getVerticalAlignment()

getId

public Object getId()
Returns the ID. The ID is used to identify LayeredNodePlacers that share information about their height. Using different IDs offers aligned layouts within different subtrees.

Returns:
The ID

getLayerSpacing

public double getLayerSpacing()
Returns the spacing between two layers.

Returns:
the spacing between two layers.

setLayerSpacing

public void setLayerSpacing(double layerSpacing)
Sets the spacing between two layers.


setRoutingStyle

public void setRoutingStyle(int routingStyle)
Sets the routing style. The possible values are:


getRoutingStyle

public int getRoutingStyle()
Returns the routing style. The possible values are:

Returns:
the routing style

getBusAlignment

public double getBusAlignment()
Returns the actual set bus alignment. The bus alignment represents the position of the "bus" within the spacing between the layers (getLayerSpacing()). 0: the bus is a the top of the space between the layers 0.5: the bus is exactly in the middle 1: the bus is at the bottom

Returns:
the bus alignment (0.0 - 1.0)

setBusAlignment

public void setBusAlignment(double busAlignment)
Sets the vertical alignment of the bus

Parameters:
busAlignment - (between 0 and 1)

isPolylineLabelingEnabled

public boolean isPolylineLabelingEnabled()
Returns whether polyline labeling is used.

If set to true, the poly line connectors between the parent and its children are added to the shape. Labels (of nodes and edges) will not cut them.

Returns:
whether polyline labeling is enabled

setPolylineLabelingEnabled

public void setPolylineLabelingEnabled(boolean polylineLabelingEnabled)
Specifies whether polyline labeling should be used.

If set to true, the poly line connectors between the parent and its children are added to the shape. Labels (of nodes and edges) will not cut them.


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