Search this API

y.layout.tree
Class AbstractRotatableNodePlacer

java.lang.Object
  extended by y.layout.tree.AbstractRotatableNodePlacer
All Implemented Interfaces:
FromSketchNodePlacer, NodePlacer
Direct Known Subclasses:
AssistantPlacer, BusPlacer, DelegatingNodePlacer, DoubleLinePlacer, FreePlacer, GridNodePlacer, LayeredNodePlacer, LeftRightPlacer, SimpleNodePlacer

public abstract class AbstractRotatableNodePlacer
extends Object
implements FromSketchNodePlacer

This is an abstract base class for NodePlacers that supports rotations.
"Supporting rotation" means that the NodePlacers only implement the default direction (e.g. bottom-down). The other directions are calculated using the modification matrix within the constructor.
But take care! Using rotatable NodePlacers contains some pitfalls. Especially calculations must be aware of that. Especially operations on BorderLines should not be called directly (e.g. mergeWithMin, mergeWithMax). Use the corresponding methods on AbstractRotatableNodePlacer instead.


Nested Class Summary
static class AbstractRotatableNodePlacer.Matrix
          Instances of this class may be used to configure the AbstractRotatableNodePlacer.
static class AbstractRotatableNodePlacer.RootAlignment
          This class represents the horizontal alignment of the root node.
 
Field Summary
protected  List createdChildren
          List containing the created children
protected  LayoutGraph graph
          The graph instance this class is working on
protected  AbstractRotatableNodePlacer.Matrix modificationMatrix
          The active modification matrix.
protected  DataProvider nodeShapeProvider
          The actual node shape provider
protected  double spacing
          This is the "default" spacing for the different move operations.
protected  DataProvider subtreeShapeProvider
          The actual subtree shape provider
 
Fields inherited from interface y.layout.tree.NodePlacer
DIRECTION_ANY, DIRECTION_EAST, DIRECTION_NONE, DIRECTION_NORTH, DIRECTION_SOUTH, DIRECTION_WEST
 
Constructor Summary
protected AbstractRotatableNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
          Default constructor.
 
Method Summary
 Comparator createComparator()
           
 Comparator createFromSketchComparator()
          Creates a comparator for edges.
 Processor createProcessor(GenericTreeLayouter layouter, LayoutGraph graph, Node currentRoot)
          Creates an optional Processor for pre- and post-processing.
protected  y.layout.tree.SubtreeShapeRotated createRootNodeShape(Node node)
          Convenience method that queries the DataProvider for the shape of a single node as a SubtreeShape instance.
protected  y.layout.tree.SubtreeShapeRotated createSubtreeShape(Node node)
          Convenience method that queries the DataProvider for a SubtreeShape.
protected abstract  byte determineChildConnector(Node child)
          This method must be implemented by subclasses.
 void determineChildConnectors(Node localRoot, DataMap connectorMap)
          This method initializes internal data structures, then uses the abstract method determineChildConnector(y.base.Node) to determine the child node connector directions.
 AbstractRotatableNodePlacer.Matrix getModificationMatrix()
          The actual modification matrix
protected  PortConstraint getPortConstraint(Node localRoot)
          Lookup method to get the PortConstraint for the local root translated.
protected  YPoint getSourcePointAbs(Edge edge)
          Translates the absolute source point of the given edge to the "view coordinates" (translated by the modification matrix)
 double getSpacing()
          Returns the spacing between subtrees this NodePlacer is arranging.
 GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider, DataProvider subtreeShapeProvider, LayoutGraph graph, Node localRoot, byte parentConnectorDirection)
          This method initializes the local data structures and then delegates the work to the abstract variant.
protected abstract  y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot, byte parentConnectorDirection)
          This method must be implemented by subclasses.
 void setSpacing(double spacing)
          Specifies the spacing between subtrees this NodePlacer is arranging.
protected  byte translateDirectionToModel(byte realDirection)
          Translates a "real" direction into a directionModel direction
protected  byte translateDirectionToReal(byte modelDirection)
          Translates a modelDirectionModel into the "real" directionModel
static YPoint translatePoint(AbstractRotatableNodePlacer.Matrix modificationMatrix, YPoint realWorldPoint)
          Translates a "real world point" to a "model point"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

spacing

protected double spacing
This is the "default" spacing for the different move operations.


graph

protected LayoutGraph graph
The graph instance this class is working on


modificationMatrix

protected final AbstractRotatableNodePlacer.Matrix modificationMatrix
The active modification matrix.


subtreeShapeProvider

protected DataProvider subtreeShapeProvider
The actual subtree shape provider


nodeShapeProvider

protected DataProvider nodeShapeProvider
The actual node shape provider


createdChildren

protected List createdChildren
List containing the created children

Constructor Detail

AbstractRotatableNodePlacer

protected AbstractRotatableNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
Default constructor. Instantiates a new instance with the given modification matrix.

Parameters:
modificationMatrix - the translation for the NodePlacer
Method Detail

createProcessor

public Processor createProcessor(GenericTreeLayouter layouter,
                                 LayoutGraph graph,
                                 Node currentRoot)
Creates an optional Processor for pre- and post-processing.

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

getSourcePointAbs

protected YPoint getSourcePointAbs(Edge edge)
Translates the absolute source point of the given edge to the "view coordinates" (translated by the modification matrix)

Parameters:
edge - the source point for is returned
Returns:
the translated absolute source point for the given edge and the actual modification matrix

placeSubtree

protected abstract y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot,
                                                                  byte parentConnectorDirection)
This method must be implemented by subclasses.

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

createRootNodeShape

protected y.layout.tree.SubtreeShapeRotated createRootNodeShape(Node node)
Convenience method that queries the DataProvider for the shape of a single node as a SubtreeShape instance. This instance can be used to modify and return it in the main placeSubtree method.
This method can only be called during the execution of placeSubtree(Node, byte)

Parameters:
node - the node whose shape will be returned in the form of a SubtreeShape instance
Returns:
an instance that can be modified

createSubtreeShape

protected y.layout.tree.SubtreeShapeRotated createSubtreeShape(Node node)
Convenience method that queries the DataProvider for a SubtreeShape.
This method can only be called during the execution of placeSubtree(y.base.Node, byte)

Parameters:
node - the root node whose subtree shape will be returned in the form of a SubtreeShape instance
Returns:
an instance that can be modified

determineChildConnectors

public void determineChildConnectors(Node localRoot,
                                     DataMap connectorMap)
This method initializes internal data structures, then uses the abstract method determineChildConnector(y.base.Node) to determine the child node connector directions.

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

getPortConstraint

protected PortConstraint getPortConstraint(Node localRoot)
Lookup method to get the PortConstraint for the local root translated.

Parameters:
localRoot - the local root
Returns:
the PortConstraint for the local root. The PortConstraint is translated based on the actual modification matrix.

translateDirectionToReal

protected byte translateDirectionToReal(byte modelDirection)
Translates a modelDirectionModel into the "real" directionModel

Parameters:
modelDirection - the model direction
Returns:
the translated model direction

translateDirectionToModel

protected byte translateDirectionToModel(byte realDirection)
Translates a "real" direction into a directionModel direction

Parameters:
realDirection - the "real" direction
Returns:
the translated direction

determineChildConnector

protected abstract byte determineChildConnector(Node child)
This method must be implemented by subclasses. It is used to assigns a connector shape direction to each child.

Parameters:
child - the child node
Returns:
a byte constant as defined in the NodePlacer interface

placeSubtree

public GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider,
                                                     DataProvider subtreeShapeProvider,
                                                     LayoutGraph graph,
                                                     Node localRoot,
                                                     byte parentConnectorDirection)
This method initializes the local data structures and then delegates the work to the abstract variant.

Specified by:
placeSubtree in interface NodePlacer
Parameters:
nodeShapeProvider - this instance can be used to obtain an initial shape of the root node. This shape can then be merged with all the subtrees' shapes and finally be returned by this method.
subtreeShapeProvider - provides access to the pre-calculated shapes of the subtrees. It is guaranteed that at the time of the invocation of this method for every child node the subtree shape has already been calculated
graph - the graph which is to be laid out
localRoot - the root of the subtree that should be laid out by this method
parentConnectorDirection - the direction byte constant as it is defined in this interface, that must be used for initializing the connector of the localRoot node to the parent node of the localRoot node
Returns:
the shape of the whole subtree
See Also:
placeSubtree(Node, byte)

getModificationMatrix

public AbstractRotatableNodePlacer.Matrix getModificationMatrix()
The actual modification matrix

Returns:
the actual modification matrix

createComparator

public Comparator createComparator()

translatePoint

public static YPoint translatePoint(AbstractRotatableNodePlacer.Matrix modificationMatrix,
                                    YPoint realWorldPoint)
Translates a "real world point" to a "model point"

Parameters:
modificationMatrix - the matrix to apply
realWorldPoint - the point with the coordinates from the real world
Returns:
the model point

getSpacing

public double getSpacing()
Returns the spacing between subtrees this NodePlacer is arranging.

Returns:
the spacing for the current NodePlacer.

setSpacing

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


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.