Search this API

y.layout.tree
Class ARNodePlacer

java.lang.Object
  extended by y.layout.tree.AbstractNodePlacer
      extended by y.layout.tree.ARNodePlacer
All Implemented Interfaces:
Cloneable, FromSketchNodePlacer, NodePlacer

public class ARNodePlacer
extends AbstractNodePlacer
implements FromSketchNodePlacer

This class is used by GenericTreeLayouter and implements a sophisticated NodePlacer. Subtrees are placed so that the overall subtree layout's aspect ratio will be close to a given aspect ratio.


Field Summary
static byte FILL_STYLE_CENTERED
          Byte constant that can be used for the fillStyle property.
static byte FILL_STYLE_JUSTIFY
          Byte constant that can be used for the fillStyle property.
static byte FILL_STYLE_LEADING
          Byte constant that can be used for the fillStyle property.
static byte FILL_STYLE_TRAILING
          Byte constant that can be used for the fillStyle property.
 
Fields inherited from class y.layout.tree.AbstractNodePlacer
graph
 
Fields inherited from interface y.layout.tree.NodePlacer
DIRECTION_ANY, DIRECTION_EAST, DIRECTION_NONE, DIRECTION_NORTH, DIRECTION_SOUTH, DIRECTION_WEST
 
Constructor Summary
ARNodePlacer()
          Creates a new instance of ARNodePlacer with default orientation (vertical), aspect ratio (1.0d), fill style (FILL_STYLE_LEADING), and default distances (40.0d).
ARNodePlacer(boolean horizontal, double aspectRatio, byte fillStyle, double horizontalDistance, double verticalDistance)
          Creates a new instance of ARNodePlacer with given orientation and distances.
 
Method Summary
 Comparator createFromSketchComparator()
          Creates a comparator for edges.
protected  byte determineChildConnector(Node child)
          This method must be implemented by subclasses.
 double getAspectRatio()
          Gets the preferred aspect ratio.
 byte getFillStyle()
          Returns the fill style.
 double getHorizontalDistance()
          Returns the horizontal distance this NodePlacer should use for the arrangement of the elements.
 double getVerticalDistance()
          Returns the vertical distance this NodePlacer should use for the arrangement of the elements.
 boolean isHorizontal()
          Returns whether this instance is configured to create horizontal rows of child nodes.
protected  GenericTreeLayouter.SubtreeShape placeSubtree(Node localRoot, byte parentConnectorDirection)
          The main placeSubtree method that must be implemented by subclasses.
 void setAspectRatio(double aspectRatio)
          Sets the preferred aspect ratio.
 void setFillStyle(byte fillStyle)
          Sets the fill style.
 void setHorizontal(boolean horizontal)
          Determines whether this instance is configured to create horizontal rows of child nodes.
 void setHorizontalDistance(double horizontalDistance)
          Sets the horizontal distance this NodePlacer should use for the arrangement of the elements.
 void setVerticalDistance(double verticalDistance)
          Sets the vertical distance this NodePlacer should use for the arrangement of the elements.
 
Methods inherited from class y.layout.tree.AbstractNodePlacer
clone, createProcessor, determineChildConnectors, getNodeShape, getSubtreeShape, placeSubtree
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface y.layout.tree.NodePlacer
createProcessor, determineChildConnectors, placeSubtree
 

Field Detail

FILL_STYLE_LEADING

public static final byte FILL_STYLE_LEADING
Byte constant that can be used for the fillStyle property. Elements in one lane will be aligned with the leading edge.

See Also:
Constant Field Values

FILL_STYLE_CENTERED

public static final byte FILL_STYLE_CENTERED
Byte constant that can be used for the fillStyle property. Elements in one lane will be centered with the bounds.

See Also:
Constant Field Values

FILL_STYLE_JUSTIFY

public static final byte FILL_STYLE_JUSTIFY
Byte constant that can be used for the fillStyle property. Elements in one lane will be justified with the bounds.

See Also:
Constant Field Values

FILL_STYLE_TRAILING

public static final byte FILL_STYLE_TRAILING
Byte constant that can be used for the fillStyle property. Elements in one lane will be aligned with the trailing edge.

See Also:
Constant Field Values
Constructor Detail

ARNodePlacer

public ARNodePlacer()
Creates a new instance of ARNodePlacer with default orientation (vertical), aspect ratio (1.0d), fill style (FILL_STYLE_LEADING), and default distances (40.0d).


ARNodePlacer

public ARNodePlacer(boolean horizontal,
                    double aspectRatio,
                    byte fillStyle,
                    double horizontalDistance,
                    double verticalDistance)
Creates a new instance of ARNodePlacer with given orientation and distances.

Parameters:
horizontal - true for horizontal row mode
horizontalDistance - horizontal distance between adjacent elements
verticalDistance - vertical distance between adjacent elements
aspectRatio - the aspectRatio, this instance should try to obey
fillStyle - a fill style constant describing the node distribution
Method Detail

determineChildConnector

protected byte determineChildConnector(Node child)
Description copied from class: AbstractNodePlacer
This method must be implemented by subclasses. It assigns a connector shape direction to each child.

Specified by:
determineChildConnector in class AbstractNodePlacer
Parameters:
child - the child node
Returns:
a byte constant as defined in the NodePlacer interface

placeSubtree

protected GenericTreeLayouter.SubtreeShape placeSubtree(Node localRoot,
                                                        byte parentConnectorDirection)
Description copied from class: AbstractNodePlacer
The main placeSubtree method that must be implemented by subclasses.

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

isHorizontal

public boolean isHorizontal()
Returns whether this instance is configured to create horizontal rows of child nodes.

Returns:
true rows will be filled, false for columns

setHorizontal

public void setHorizontal(boolean horizontal)
Determines whether this instance is configured to create horizontal rows of child nodes.

Parameters:
horizontal - true for horizontal rows, false for vertical columns

getVerticalDistance

public double getVerticalDistance()
Returns the vertical distance this NodePlacer should use for the arrangement of the elements.

Returns:
the current value

setVerticalDistance

public void setVerticalDistance(double verticalDistance)
Sets the vertical distance this NodePlacer should use for the arrangement of the elements.

Parameters:
verticalDistance - the new value

getHorizontalDistance

public double getHorizontalDistance()
Returns the horizontal distance this NodePlacer should use for the arrangement of the elements.

Returns:
the current value

setHorizontalDistance

public void setHorizontalDistance(double horizontalDistance)
Sets the horizontal distance this NodePlacer should use for the arrangement of the elements.

Parameters:
horizontalDistance - the new value

getAspectRatio

public double getAspectRatio()
Gets the preferred aspect ratio.

Returns:
the ratio preferred width / preferred height

setAspectRatio

public void setAspectRatio(double aspectRatio)
Sets the preferred aspect ratio.

Parameters:
aspectRatio - the ratio preferred width / preferred height

getFillStyle

public byte getFillStyle()
Returns the fill style. The byte constant defines how nodes should be distributed within their lanes.

Returns:
the current fill style constant

setFillStyle

public void setFillStyle(byte fillStyle)
Sets the fill style. The byte constant defines how nodes should be distributed within their lanes.

Parameters:
fillStyle - the new fill style constant

createFromSketchComparator

public Comparator createFromSketchComparator()
Description copied from interface: FromSketchNodePlacer
Creates a comparator for edges. This comparator is used to sort the outgoing edges of a node before the placement of the node's subtree is calculated.

Specified by:
createFromSketchComparator in interface FromSketchNodePlacer
Returns:
a comparator for edges.

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