|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.CanonicMultiStageLayouter y.layout.tree.GenericTreeLayouter
public class GenericTreeLayouter
This class implements the basis of a generic tree layout algorithm.
It can be customized easily to control the
placement and order of child nodes, the edge routing and port assignment on a per node basis.
Using DataProvider
s, one can specify objects that implement the NodePlacer
interface. Those instances are
responsible for the arrangement of the subtrees of the node's they are registered with and the routing of the
connecting edges.
Likewise instances of PortAssignment
are responsible for the assignment of the ports
and Comparator
instances can be used to sort the outgoing edges of each node.
Customization of this
class should be done via own implementations of the NodePlacer
, possibly PortAssignment
, and Comparator
instances.
DefaultNodePlacer
instances:
NodePlacer
,
DefaultNodePlacer
,
PortAssignment
,
DefaultPortAssignment
Nested Class Summary | |
---|---|
static class |
GenericTreeLayouter.SubtreeShape
Instances of this class are used to represent the shape of subtrees during the layout. |
Field Summary | |
---|---|
static Object |
CHILD_COMPARATOR_DPKEY
DataProvider key that can be registered with the graph to provide each node with its own Comparator
instance that will be used to sort its outgoing edges. |
protected LayoutGraph |
graph
the graph this layout is running on |
static Object |
NODE_PLACER_DPKEY
DataProvider key that can be registered with the graph to provide each node with its own NodePlacer
instance. |
static Object |
PORT_ASSIGNMENT_DPKEY
DataProvider key that can be registered with the graph to provide each node with its own PortAssignment
instance. |
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
GenericTreeLayouter()
Creates a new GenericTreeLayouter with a default NodePlacer , a default PortAssignment instance and
no default edge comparator. |
Method Summary | |
---|---|
protected boolean |
canLayoutCore(LayoutGraph graph)
Subclasses have to provide information whether or not they can layout the given graph. |
protected EdgeList |
directTree()
This method is called initially with the graph to calculate a rooted tree. |
protected void |
doLayoutCore(LayoutGraph graph)
Subclasses have to provide core layout code in this method. |
protected Comparator |
getChildNodeInEdgeComparator(Node localRoot)
This method returns a Comparator instance or null that will be used for the sorting of the
outgoing edges at the given Node. |
Comparator |
getDefaultChildComparator()
Returns the default Comparator instance or null that will be used for those subtrees, that
don't have their own specific instance set via the appropriate DataProvider. |
NodePlacer |
getDefaultLeafPlacer()
Returns the default NodePlacer instance that will be used for the leaf nodes of the tree. |
NodePlacer |
getDefaultNodePlacer()
Returns the default NodePlacer instance that will be used for those subtrees, that don't have their own
specific instance set via the appropriate DataProvider. |
PortAssignment |
getDefaultPortAssignment()
Returns the default PortAssignment instance that will be used for those subtrees, that don't have their
own specific instance set via the appropriate DataProvider. |
protected NodePlacer |
getNodePlacer(Node localRoot)
This method returns a NodePlacer instance that will be used for the placement of the root node and the
subtree shapes. |
protected GenericTreeLayouter.SubtreeShape |
getNodeShape(Node node)
Factory method that creates a SubtreeShape for a given node, that consists of the bounds of the node only. |
protected PortAssignment |
getPortAssignment(Node localRoot)
This method returns a PortAssignment instance that will be used for the port assignments at the given Node. |
protected Node[] |
getRootsArray(Node root)
Returns the array of the nodes to be laid out. |
protected DataAcceptor |
getSourcePortConstraintDataAcceptor()
Returns a DataAcceptor implementation
that can be used to overwrite the source port constraint (PortConstraint
temporarily for use during the layout. |
protected GenericTreeLayouter.SubtreeShape |
getSubtreeShape(Node localRoot)
Provides access to the SubTreeShape instances for each node. |
protected DataAcceptor |
getTargetPortConstraintDataAcceptor()
Returns a DataAcceptor implementation
that can be used to overwrite the target port constraint (PortConstraint
temporarily for use during the layout. |
boolean |
isGroupingSupported()
Returns true if grouping support is enabled. |
boolean |
isIntegratedEdgeLabeling()
Returns whether integrated edge labeling is enabled (extension of the shapes of subtrees with the labels of the edges). |
boolean |
isIntegratedNodeLabeling()
Returns whether integrated node labeling is enabled (extension of the shapes of the nodes with its labels). |
protected GenericTreeLayouter.SubtreeShape |
layoutRoot(Node localRoot)
This is the core method of the algorithm. |
protected void |
reverseEdges(EdgeList reversedEdges)
This method is used for the actual reversal of edges. |
void |
setDefaultChildComparator(Comparator defaultChildComparator)
Sets the default Comparator instance that will be used for those subtrees that don't have their own
specific instance set via the appropriate DataProvider. |
void |
setDefaultLeafPlacer(NodePlacer defaultLeafPlacer)
Sets the default NodePlacer instance that will be used for the leaf nodes of the tree. |
void |
setDefaultNodePlacer(NodePlacer defaultNodePlacer)
Sets the default NodePlacer instance that will be used for those subtrees, that don't have their own
specific instance set via the appropriate DataProvider. |
void |
setDefaultPortAssignment(PortAssignment defaultPortAssignment)
Sets the default PortAssignment instance that will be used for those subtrees, that don't have their own
specific instance set via the appropriate DataProvider. |
void |
setGroupingSupported(boolean groupingSupported)
Whether or not grouping support should be enabled. |
void |
setIntegratedEdgeLabeling(boolean integratedEdgeLabeling)
Specifies whether or not to use integrated edge labeling (extension of the shapes of the subtrees with the labels for the edges). |
void |
setIntegratedNodeLabeling(boolean integratedNodeLabeling)
Specifies whether or not to use integrated node labeling. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Object NODE_PLACER_DPKEY
NodePlacer
instance.
public static final Object PORT_ASSIGNMENT_DPKEY
PortAssignment
instance.
public static final Object CHILD_COMPARATOR_DPKEY
Comparator
instance that will be used to sort its outgoing edges.
protected LayoutGraph graph
Constructor Detail |
---|
public GenericTreeLayouter()
NodePlacer
, a default PortAssignment
instance and
no default edge comparator.
Method Detail |
---|
public boolean isGroupingSupported()
public void setGroupingSupported(boolean groupingSupported)
groupingSupported
- if true, grouping support is enabled.protected boolean canLayoutCore(LayoutGraph graph)
CanonicMultiStageLayouter
canLayoutCore
in class CanonicMultiStageLayouter
protected void doLayoutCore(LayoutGraph graph)
CanonicMultiStageLayouter
doLayoutCore
in class CanonicMultiStageLayouter
protected GenericTreeLayouter.SubtreeShape getSubtreeShape(Node localRoot)
localRoot
- the node for which the subtree should be returned
null
otherwiseprotected GenericTreeLayouter.SubtreeShape layoutRoot(Node localRoot)
getSubtreeShape(Node)
callback to retrieve the shapes of the subtrees of all
of the children of localRoot
.
localRoot
- The root to be laid out together with its SubtreeShapes
protected PortAssignment getPortAssignment(Node localRoot)
PortAssignment
instance that will be used for the port assignments at the given Node.
This method is allowed to return a shared instance for multiple different nodes, the instances are not used after
subsequent calls to this method.
localRoot
- the root of the local subtree
PortAssignment
that can be used to assign the ports of the edges
at the given local root node.protected Comparator getChildNodeInEdgeComparator(Node localRoot)
Comparator
instance or null
that will be used for the sorting of the
outgoing edges at the given Node. This method is allowed to return a shared instance for multiple different nodes,
the instances are not used after subsequent calls to this method.
localRoot
- the root of the local subtree
Comparator
or null
that can be used sort the outgoing
edges of the given nodeprotected NodePlacer getNodePlacer(Node localRoot)
NodePlacer
instance that will be used for the placement of the root node and the
subtree shapes. This method is allowed to return a shared instance for multiple different nodes, the instances are
not used after subsequent calls to this method.
localRoot
- the root of the local subtree
NodePlacer
that can be used to layout the subtree under the given
local root node.protected GenericTreeLayouter.SubtreeShape getNodeShape(Node node)
node
- the node that will be represented by a SubTreeShape instance
protected Node[] getRootsArray(Node root)
root
- the node that should be used as the root of the tree
protected EdgeList directTree()
protected DataAcceptor getSourcePortConstraintDataAcceptor()
DataAcceptor
implementation
that can be used to overwrite the source port constraint (PortConstraint
temporarily for use during the layout.
PortConstraint
s to Edge
sprotected DataAcceptor getTargetPortConstraintDataAcceptor()
DataAcceptor
implementation
that can be used to overwrite the target port constraint (PortConstraint
temporarily for use during the layout.
PortConstraint
s to Edge
sprotected void reverseEdges(EdgeList reversedEdges)
directTree()
method and finally
after the layout has been calculated.
reversedEdges
- the edges that will be reversed by this methodpublic NodePlacer getDefaultNodePlacer()
NodePlacer
instance that will be used for those subtrees, that don't have their own
specific instance set via the appropriate DataProvider.
public void setDefaultNodePlacer(NodePlacer defaultNodePlacer)
NodePlacer
instance that will be used for those subtrees, that don't have their own
specific instance set via the appropriate DataProvider. This should be non-null
, unless it is
guaranteed that for any node in the graph there is a specific instance provided by the registered DataProvider
instance.
defaultNodePlacer
- the new default instancepublic NodePlacer getDefaultLeafPlacer()
NodePlacer
instance that will be used for the leaf nodes of the tree.
public void setDefaultLeafPlacer(NodePlacer defaultLeafPlacer)
NodePlacer
instance that will be used for the leaf nodes of the tree.
public PortAssignment getDefaultPortAssignment()
PortAssignment
instance that will be used for those subtrees, that don't have their
own specific instance set via the appropriate DataProvider.
public void setDefaultPortAssignment(PortAssignment defaultPortAssignment)
PortAssignment
instance that will be used for those subtrees, that don't have their own
specific instance set via the appropriate DataProvider. This should be non-null
, unless it is
guaranteed that for any node in the graph there is a specific instance provided by the registered DataProvider
instance.
defaultPortAssignment
- the new default instancepublic Comparator getDefaultChildComparator()
Comparator
instance or null
that will be used for those subtrees, that
don't have their own specific instance set via the appropriate DataProvider.
null
if no such instance is setpublic void setDefaultChildComparator(Comparator defaultChildComparator)
Comparator
instance that will be used for those subtrees that don't have their own
specific instance set via the appropriate DataProvider. This can be set to null
which implies no
sorting by default.
defaultChildComparator
- the new default instance or null
if no such sorting should be donepublic void setIntegratedNodeLabeling(boolean integratedNodeLabeling)
true
, the shape of the nodes will be extended with
the shapes of its labels.
integratedNodeLabeling
- whether integrated node labeling should be enabled.public boolean isIntegratedNodeLabeling()
true
if intergrated node labeling is enabled;
false
otherwise.public boolean isIntegratedEdgeLabeling()
true
if enabled; false
otherwise.public void setIntegratedEdgeLabeling(boolean integratedEdgeLabeling)
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |