public abstract class AbstractRotatableNodePlacer extends Object implements IFromSketchNodePlacer
INodePlacers that support rotations of the subtrees.
The direction specified in this AbstractRotatableNodePlacer (defined by a
transformation matrix) rotates the subtree that is placed. This is the final
direction of this subtree. Rotations are not accumulated.
INodePlacers of this type will only implement the default direction (i.e. top-to-bottom). The other directions
are calculated using the specified modification AbstractRotatableNodePlacer.Matrix. The direction used by the
implementing
INodePlacers is called the model direction while the actual direction in the graph is the real direction.
Note that using rotatable INodePlacers has some pitfalls. Calculations must be aware of the rotations.
Especially operations on BorderLines should not be called directly (e.g.
BorderLine.mergeWithMin(com.yworks.yfiles.algorithms.BorderLine),
BorderLine.mergeWithMax(com.yworks.yfiles.algorithms.BorderLine)). The
corresponding methods of AbstractRotatableNodePlacer already support the different directions.
Subclasses just need to override the following two abstract methods: placeSubtree(Node, ParentConnectorDirection)
and determineChildConnectors(Node, IDataMap).
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractRotatableNodePlacer.Matrix
A matrix describes the rotation of the subtree handled by
AbstractRotatableNodePlacer. |
static class |
AbstractRotatableNodePlacer.RootAlignment
A
RootAlignment describes how a local root node is arranged in relation to its children. |
| Modifier and Type | Field and Description |
|---|---|
protected List<Object> |
createdChildren
The list containing the created children.
|
protected LayoutGraph |
graph
The graph instance this
INodePlacer is working on. |
protected IDataProvider |
nodeShapeProvider
The provider of
TreeLayout.SubtreeShapes for single nodes. |
protected IDataProvider |
subtreeShapeProvider
The provider of
TreeLayout.SubtreeShapes for whole subtrees. |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractRotatableNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
Creates a new instance of
AbstractRotatableNodePlacer whose direction is specified by the given modification
matrix. |
| Modifier and Type | Method and Description |
|---|---|
Comparator<Object> |
createComparator()
Creates a
Comparator for outgoing edges that takes the rotation into account. |
Comparator<Object> |
createFromSketchComparator()
Delegates to
createComparator(). |
IProcessor |
createProcessor(TreeLayout layouter,
LayoutGraph graph,
Node currentRoot)
Creates an optional
IProcessor for pre- and post-processing. |
protected abstract ParentConnectorDirection |
determineChildConnector(Node child)
Determines a connector direction for the given child node.
|
void |
determineChildConnectors(Node localRoot,
IDataMap connectorMap)
Provides the direction of the connector to the
SubtreeShape for each child node. |
AbstractRotatableNodePlacer.Matrix |
getModificationMatrix()
Gets the modification matrix that defines the direction of the subtree.
|
protected RotatedSubtreeShape |
getNodeShape(Node node)
Returns the rotated subtree shape for the given node.
|
protected PortConstraint |
getPortConstraint(Node localRoot)
Returns the target
PortConstraint for the local root's incoming edge. |
protected YPoint |
getSourcePointAbs(Edge edge)
Returns the absolute source point of the given edge depending on the rotation of this
INodePlacer. |
double |
getSpacing()
Gets the spacing between subtrees.
|
protected RotatedSubtreeShape |
getSubtreeShape(Node node)
Returns the rotated subtree shape for the subtree rooted at the given node.
|
TreeLayout.SubtreeShape |
placeSubtree(IDataProvider nodeShapeProvider,
IDataProvider subtreeShapeProvider,
LayoutGraph graph,
Node localRoot,
ParentConnectorDirection parentConnectorDirection)
Initializes the local data structures and then delegates the work to the abstract variant of this method
(
placeSubtree(Node, ParentConnectorDirection)). |
protected abstract RotatedSubtreeShape |
placeSubtree(Node localRoot,
ParentConnectorDirection parentConnectorDirection)
Arranges the local root relative to the rotated subtree shapes of its children.
|
void |
setSpacing(double value)
Sets the spacing between subtrees.
|
protected byte |
translateDirectionToModel(ParentConnectorDirection realDirection)
Translates the given real direction of the resulting layout to the model direction of this
AbstractRotatableNodePlacer. |
protected byte |
translateDirectionToReal(ParentConnectorDirection modelDirection)
Translates the given model direction to the real direction in the resulting layout.
|
static YPoint |
translatePoint(AbstractRotatableNodePlacer.Matrix modificationMatrix,
YPoint realWorldPoint)
Translates a point from the real layout direction to the model direction using the given modification matrix.
|
protected LayoutGraph graph
INodePlacer is working on.protected IDataProvider nodeShapeProvider
TreeLayout.SubtreeShapes for single nodes.protected IDataProvider subtreeShapeProvider
TreeLayout.SubtreeShapes for whole subtrees.protected AbstractRotatableNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
AbstractRotatableNodePlacer whose direction is specified by the given modification
matrix.modificationMatrix - the transformation matrix for the INodePlacerpublic Comparator<Object> createComparator()
Comparator for outgoing edges that takes the rotation into account.Comparator that considers the rotationpublic Comparator<Object> createFromSketchComparator()
createComparator().createFromSketchComparator in interface IFromSketchNodePlacerComparatorcreateComparator()public IProcessor createProcessor(TreeLayout layouter, LayoutGraph graph, Node currentRoot)
IProcessor for pre- and post-processing.
This implementation returns null. Hence, no pre- or post-processing is done.
createProcessor in interface INodePlacerlayouter - the current TreeLayout instancegraph - the input graphcurrentRoot - the root node handled by this INodePlacernullprotected abstract ParentConnectorDirection determineChildConnector(Node child)
This method is called by determineChildConnectors(Node, IDataMap) and must be implemented by subclasses.
Implementations can assume the default direction (top-to-bottom) for their arrangement.
child - the child nodeINodePlacer interfacepublic void determineChildConnectors(Node localRoot, IDataMap connectorMap)
SubtreeShape for each child node.
This implementation uses determineChildConnector(Node) and the modification matrix
to retrieve the direction for the connectors.
determineChildConnectors in interface INodePlacerlocalRoot - the local rootconnectorMap - the map that must be used for storing the direction specifiers of the child nodesdetermineChildConnector(Node)public AbstractRotatableNodePlacer.Matrix getModificationMatrix()
protected RotatedSubtreeShape getNodeShape(Node node)
This is a convenience method that retrieves a rotated subtree shape for a single node from the corresponding
IDataProvider. This shape may be modified and returned by
placeSubtree(Node, ParentConnectorDirection).
placeSubtree(Node, ParentConnectorDirection).
Otherwise, the IDataProvider for querying results will not have been initialized yet.node - the nodeprotected PortConstraint getPortConstraint(Node localRoot)
PortConstraint for the local root's incoming edge.
This method translates the PortConstraint according to the rotation described by the
modification matrix. It should be used instead of
PortConstraint.getTPC(LayoutGraph, Edge).
This method may be used in placeSubtree(Node, ParentConnectorDirection) to route the edges to the according
port. It may be overridden to provide constant PortConstraints for each node.
localRoot - the local rootPortConstraint for the incoming edge of the local root or PortSide.ANY if no PortConstraint
is assigned for that edgeprotected YPoint getSourcePointAbs(Edge edge)
INodePlacer.
This method translates the source point according to the rotation described by the
modification matrix. It should be used instead of
LayoutGraph.getSourcePointAbs(Edge).
It can be used in an implementation of placeSubtree(Node, ParentConnectorDirection).
edge - the edge whose absolute source point should be calculatedpublic double getSpacing()
The spacing needs to be non-negative.
IllegalArgumentException - if the given spacing is negativesetSpacing(double)protected RotatedSubtreeShape getSubtreeShape(Node node)
This is a convenience method that retrieves a subtree shape of a complete subtree from the corresponding
IDataProvider.
placeSubtree(Node, ParentConnectorDirection). Before,
the IDataProvider for querying results will not have been initialized yet.node - the local root nodepublic TreeLayout.SubtreeShape placeSubtree(IDataProvider nodeShapeProvider, IDataProvider subtreeShapeProvider, LayoutGraph graph, Node localRoot, ParentConnectorDirection parentConnectorDirection)
placeSubtree(Node, ParentConnectorDirection)).placeSubtree in interface INodePlacernodeShapeProvider - the IDataProvider for obtaining an initial shape of the root nodesubtreeShapeProvider - the IDataProvider for accessing the pre-calculated shapes of the subtreesgraph - the input graphlocalRoot - the root of the subtree that should be arranged by this methodparentConnectorDirection - the direction specifier for the connector of the local root node to its parent nodeTreeLayout.SubtreeShape for the subtree rooted at the local root nodeplaceSubtree(Node, ParentConnectorDirection)protected abstract RotatedSubtreeShape placeSubtree(Node localRoot, ParentConnectorDirection parentConnectorDirection)
This is the main method that must be implemented by subclasses. For calculations and locations subclasses should use the
corresponding methods of AbstractRotatableNodePlacer which already consider the
modification matrix.
localRoot - the local root nodeparentConnectorDirection - the direction specifier for the connector of the local root node to its parent nodepublic void setSpacing(double value)
The spacing needs to be non-negative.
IllegalArgumentException - if the given spacing is negativevalue - the distance between subtreesgetSpacing()protected byte translateDirectionToModel(ParentConnectorDirection realDirection)
AbstractRotatableNodePlacer.
This method is used in placeSubtree(Node, ParentConnectorDirection) to be able to retrieve the model direction
for the connector
IllegalArgumentException - if translation for the given real direction is not implementedrealDirection - the real directionprotected byte translateDirectionToReal(ParentConnectorDirection modelDirection)
This method is used in determineChildConnectors(Node, IDataMap) to be able to return the real connector
direction.
IllegalArgumentException - if translation for the given model direction is not implementedmodelDirection - the model directionpublic static final YPoint translatePoint(AbstractRotatableNodePlacer.Matrix modificationMatrix, YPoint realWorldPoint)
modificationMatrix - the modification matrix to use for the translationrealWorldPoint - the point with coordinates from the real world