|
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.AbstractNodePlacer y.layout.tree.CompactNodePlacer
public class CompactNodePlacer
The CompactNodePlacer
produces a compact placement of the children.
This NodePlacer
uses a dynamic optimization approach that chooses a placement strategy of the children
of the associated local root such that the overall result is compact with respect to a
specified aspect ratio
.
The set of applied strategies is predefined and cannot be customized.
A node can either be a normal tree node or an assistant node
,
in which case the AssistantPlacer
is chosen automatically
(i.e., you shouldn't explicitly map nodes to instances of AssistantPlacer
but mark them by means
of key AssistantPlacer.ASSISTANT_DPKEY
).
All nodes are associated with an instance of CompactNodePlacer
which yields a compact overall layout using
different placement strategies.
port constraints
, port candidates
and
critical edges
.Field Summary | |
---|---|
static java.lang.Object |
STRATEGY_MEMENTO_DPKEY
A DataAcceptor key for storing/restoring the placement strategy of the children of nodes.
|
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 | |
---|---|
CompactNodePlacer()
Creates a new CompactNodePlacer instance with default settings. |
Method Summary | |
---|---|
Processor |
createProcessor(GenericTreeLayouter layouter,
LayoutGraph graph,
Node currentRoot)
Creates a Processor . |
protected 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. |
double |
getHorizontalDistance()
Returns the horizontal distance between nodes or subtrees. |
double |
getMinimumFirstSegmentLength()
Returns the minimum length for the first segment of an edge. |
double |
getMinimumLastSegmentLength()
Returns the minimum length for the last segment of an edge. |
double |
getPreferredAspectRatio()
Returns the preferred aspect ratio (width/height) for the subtrees. |
double |
getVerticalDistance()
Returns the vertical distance between nodes or subtrees. |
protected GenericTreeLayouter.SubtreeShape |
placeSubtree(Node localRoot,
byte parentConnectorDirection)
Arranges the local root relative to the GenericTreeLayouter.SubtreeShape of its children. |
void |
setHorizontalDistance(double distance)
Specifies the horizontal distance between nodes or subtrees. |
void |
setMinimumFirstSegmentLength(double minFirstSegmentLength)
Specifies the minimum length for the first segment of an edge. |
void |
setMinimumLastSegmentLength(double minLastSegmentLength)
Specifies the minimum length for the last segment of an edge. |
void |
setPreferredAspectRatio(double aspectRatio)
Specifies the preferred aspect ratio (width/height) for the subtrees. |
void |
setVerticalDistance(double distance)
Specifies the vertical distance between nodes or subtrees. |
Methods inherited from class y.layout.tree.AbstractNodePlacer |
---|
clone, getNodeShape, getSubtreeShape, placeSubtree |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Object STRATEGY_MEMENTO_DPKEY
DataAcceptor
key for storing/restoring the placement strategy of the children of nodes.
Even for small changes/updates in the graph structure, the results produced by the
CompactNodePlacer
may differ significantly. If a DataAcceptor
is registered with this key, the layout algorithm stores the applied placement strategy
for the nodes' children and keeps it in subsequent layout runs.
LeftRightPlacer
-like strategy is only applied to nodes where all children are leaf nodes.Constructor Detail |
---|
public CompactNodePlacer()
CompactNodePlacer
instance with default settings.
Method Detail |
---|
public double getHorizontalDistance()
The distance needs to be non-negative.
setHorizontalDistance(double)
public void setHorizontalDistance(double distance)
The distance needs to be non-negative.
public double getVerticalDistance()
The distance needs to be non-negative.
setVerticalDistance(double)
public void setVerticalDistance(double distance)
The distance needs to be non-negative.
protected byte determineChildConnector(Node child)
AbstractNodePlacer
This method is used in AbstractNodePlacer.determineChildConnectors(Node, DataMap)
and must be implemented by subclasses.
determineChildConnector
in class AbstractNodePlacer
child
- the child node
NodePlacer
interfacepublic void determineChildConnectors(Node localRoot, DataMap connectorMap)
AbstractNodePlacer
SubtreeShape
for each child node.
This implementation uses AbstractNodePlacer.determineChildConnector(Node)
to retrieve the direction for the connectors.
determineChildConnectors
in interface NodePlacer
determineChildConnectors
in class AbstractNodePlacer
localRoot
- the local root nodeconnectorMap
- the map that must be used for storing the direction specifiers of the child nodesprotected GenericTreeLayouter.SubtreeShape placeSubtree(Node localRoot, byte parentConnectorDirection)
AbstractNodePlacer
GenericTreeLayouter.SubtreeShape
of its children.
This is the main method that must be implemented by subclasses. It is called by
AbstractNodePlacer.placeSubtree(DataProvider, DataProvider, LayoutGraph, Node, byte)
.
placeSubtree
in class AbstractNodePlacer
localRoot
- the local root nodeparentConnectorDirection
- the direction of the connector
GenericTreeLayouter.SubtreeShape
instance that describes the shape of the whole subtree rooted at the given local rootpublic Processor createProcessor(GenericTreeLayouter layouter, LayoutGraph graph, Node currentRoot)
Processor
.
createProcessor
in interface NodePlacer
createProcessor
in class AbstractNodePlacer
layouter
- the current GenericTreeLayouter
instancegraph
- the input graphcurrentRoot
- the root node handled by this NodePlacer
Processor
instance or null
public double getPreferredAspectRatio()
The aspect ratio needs to be non-negative.
CompactNodePlacer
and without a parent associated with such a placer.public void setPreferredAspectRatio(double aspectRatio)
The aspect ratio needs to be non-negative.
CompactNodePlacer
and without a parent associated with such a placer.aspectRatio
- the preferred ratio between width and height
java.lang.IllegalArgumentException
- if the specified aspect ratio is negativepublic void setMinimumFirstSegmentLength(double minFirstSegmentLength)
During layout calculation, the edges of the tree are directed. Hence, the first segment is always the segment that is attached to the source, which is the local root node.
The length needs to be non-negative.
public double getMinimumFirstSegmentLength()
During layout calculation, the edges of the tree are directed. Hence, the first segment is always the segment that is attached to the source, which is the local root node.
The length needs to be non-negative.
setMinimumFirstSegmentLength(double)
public void setMinimumLastSegmentLength(double minLastSegmentLength)
During layout calculation, the edges of the tree are directed. Hence, the last segment is always the segment that is attached to the target, which is a child node.
The length needs to be non-negative.
public double getMinimumLastSegmentLength()
During layout calculation, the edges of the tree are directed. Hence, the last segment is always the segment that is attached to the target, which is a child node.
The length needs to be non-negative.
setMinimumLastSegmentLength(double)
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |