|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.tree.AbstractRotatableNodePlacer
public abstract class AbstractRotatableNodePlacer
Abstract base class for NodePlacer
s 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.
NodePlacer
s 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
NodePlacer
s is called the model direction while the actual direction in the graph is the real direction.
Note that using rotatable NodePlacer
s has some pitfalls. Calculations must be aware of the rotations.
Especially operations on BorderLine
s should not be called directly (e.g.
BorderLine.mergeWithMin(y.geom.BorderLine)
, BorderLine.mergeWithMax(y.geom.BorderLine)
).
The corresponding methods of AbstractRotatableNodePlacer
already support the different directions.
Subclasses just need to override the following two abstract methods: placeSubtree(Node, byte)
and
determineChildConnectors(Node, DataMap)
.
Nested Class Summary | |
---|---|
static class |
AbstractRotatableNodePlacer.Matrix
A matrix describes the rotation of the subtree handled by AbstractRotatableNodePlacer . |
static class |
AbstractRotatableNodePlacer.RootAlignment
A AbstractRotatableNodePlacer.RootAlignment describes how a local root node is arranged in relation to its children. |
Field Summary | |
---|---|
protected java.util.List |
createdChildren
The list containing the created children. |
protected LayoutGraph |
graph
The graph instance this NodePlacer is working on. |
protected AbstractRotatableNodePlacer.Matrix |
modificationMatrix
The active modification matrix. |
protected DataProvider |
nodeShapeProvider
The provider of GenericTreeLayouter.SubtreeShape s for single nodes. |
protected double |
spacing
The spacing between subtrees used for the different moving operations. |
protected DataProvider |
subtreeShapeProvider
The provider of GenericTreeLayouter.SubtreeShape s for whole subtrees. |
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)
Creates a new instance of AbstractRotatableNodePlacer whose direction is specified by the given
transformation matrix. |
Method Summary | |
---|---|
java.util.Comparator |
createComparator()
Creates a Comparator for outgoing edges that takes the rotation into account. |
java.util.Comparator |
createFromSketchComparator()
Delegates to createComparator() . |
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)
Returns the rotated subtree shape for the given node. |
protected y.layout.tree.SubtreeShapeRotated |
createSubtreeShape(Node node)
Returns the rotated subtree shape for the subtree rooted at the given node. |
protected abstract byte |
determineChildConnector(Node child)
Determines a connector direction for the given child node. |
void |
determineChildConnectors(Node localRoot,
DataMap connectorMap)
Provides the direction of the connector to the SubtreeShape for each child node. |
AbstractRotatableNodePlacer.Matrix |
getModificationMatrix()
Returns the modification matrix that defines the direction of the subtree. |
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 NodePlacer . |
double |
getSpacing()
Returns the spacing between subtrees. |
GenericTreeLayouter.SubtreeShape |
placeSubtree(DataProvider nodeShapeProvider,
DataProvider subtreeShapeProvider,
LayoutGraph graph,
Node localRoot,
byte parentConnectorDirection)
Initializes the local data structures and then delegates the work to the abstract variant of this method ( placeSubtree(Node, byte) ). |
protected abstract y.layout.tree.SubtreeShapeRotated |
placeSubtree(Node localRoot,
byte parentConnectorDirection)
Arranges the local root relative to the rotated subtree shapes of its children. |
void |
setSpacing(double spacing)
Specifies the spacing between subtrees. |
protected byte |
translateDirectionToModel(byte realDirection)
Translates the given real direction of the resulting layout to the model direction of this AbstractRotatableNodePlacer . |
protected byte |
translateDirectionToReal(byte 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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected double spacing
protected LayoutGraph graph
NodePlacer
is working on.
protected final AbstractRotatableNodePlacer.Matrix modificationMatrix
protected DataProvider subtreeShapeProvider
GenericTreeLayouter.SubtreeShape
s for whole subtrees.
protected DataProvider nodeShapeProvider
GenericTreeLayouter.SubtreeShape
s for single nodes.
protected java.util.List createdChildren
Constructor Detail |
---|
protected AbstractRotatableNodePlacer(AbstractRotatableNodePlacer.Matrix modificationMatrix)
AbstractRotatableNodePlacer
whose direction is specified by the given
transformation matrix.
modificationMatrix
- the transformation matrix for the NodePlacer
java.lang.IllegalArgumentException
- if the given transformation matrix is null
Method Detail |
---|
public Processor createProcessor(GenericTreeLayouter layouter, LayoutGraph graph, Node currentRoot)
Processor
for pre- and post-processing.
This implementation returns null
. Hence, no pre- or post-processing is done.
createProcessor
in interface NodePlacer
layouter
- the current GenericTreeLayouter
instancegraph
- the input graphcurrentRoot
- the root node handled by this NodePlacer
null
protected YPoint getSourcePointAbs(Edge edge)
NodePlacer
.
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, byte)
.
edge
- the edge whose absolute source point should be calculated
protected abstract y.layout.tree.SubtreeShapeRotated placeSubtree(Node localRoot, byte 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 node
protected y.layout.tree.SubtreeShapeRotated createRootNodeShape(Node node)
This is a convenience method that retrieves a rotated subtree shape for a single node from the corresponding
DataProvider
. This shape may be modified and returned by
placeSubtree(Node, byte)
.
placeSubtree(Node, byte)
.
Otherwise, the DataProvider
for querying results will not have been initialized yet.node
- the node
protected y.layout.tree.SubtreeShapeRotated createSubtreeShape(Node node)
This is a convenience method that retrieves a subtree shape of a complete subtree from the
corresponding DataProvider
.
placeSubtree(Node, byte)
.
Before, the DataProvider
for querying results will not have been initialized yet.node
- the local root node
public void determineChildConnectors(Node localRoot, DataMap 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 NodePlacer
localRoot
- the local rootconnectorMap
- the map that must be used for storing the direction specifiers of the child nodesdetermineChildConnector(Node)
protected 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, byte)
to route the edges to the according port. It may be
overridden to provide constant PortConstraint
s for each node.
localRoot
- the local root
PortConstraint
for the incoming edge of the local root or PortConstraint.ANY_SIDE
if no
PortConstraint
is assigned for that edgeprotected byte translateDirectionToReal(byte modelDirection)
This method is used in determineChildConnectors(Node, DataMap)
to be able to return the real connector
direction.
modelDirection
- the model direction
java.lang.IllegalArgumentException
- if translation for the given model direction is not implementedprotected byte translateDirectionToModel(byte realDirection)
AbstractRotatableNodePlacer
.
This method is used in placeSubtree(Node, byte)
to be able to retrieve the model direction for the
connector
realDirection
- the real direction
java.lang.IllegalArgumentException
- if translation for the given real direction is not implementedprotected abstract byte determineChildConnector(Node child)
This method is called by determineChildConnectors(Node, DataMap)
and must be implemented by subclasses.
Implementations can assume the default direction (top-to-bottom) for their arrangement.
child
- the child node
NodePlacer
interfacepublic GenericTreeLayouter.SubtreeShape placeSubtree(DataProvider nodeShapeProvider, DataProvider subtreeShapeProvider, LayoutGraph graph, Node localRoot, byte parentConnectorDirection)
placeSubtree(Node, byte)
).
placeSubtree
in interface NodePlacer
nodeShapeProvider
- the DataProvider
for obtaining an initial shape of the root nodesubtreeShapeProvider
- the DataProvider
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 node
GenericTreeLayouter.SubtreeShape
for the subtree rooted at the local root nodeplaceSubtree(Node, byte)
public AbstractRotatableNodePlacer.Matrix getModificationMatrix()
public java.util.Comparator createComparator()
Comparator
for outgoing edges that takes the rotation into account.
Comparator
that considers the rotationpublic static YPoint translatePoint(AbstractRotatableNodePlacer.Matrix modificationMatrix, YPoint realWorldPoint)
modificationMatrix
- the modification matrix to use for the translationrealWorldPoint
- the point with coordinates from the real world
public double getSpacing()
The spacing needs to be non-negative.
setSpacing(double)
public void setSpacing(double spacing)
The spacing needs to be non-negative.
spacing
- the distance between subtrees
java.lang.IllegalArgumentException
- if the given spacing is negativeSpacing 20 using SimpleNodePlacer | Spacing 50 using SimpleNodePlacer |
public java.util.Comparator createFromSketchComparator()
createComparator()
.
createFromSketchComparator
in interface FromSketchNodePlacer
Comparator
createComparator()
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |