Class TreeLayoutHelper
- java.lang.Object
-
- org.eclipse.gef.layout.algorithms.TreeLayoutHelper
-
public class TreeLayoutHelper extends java.lang.Object
A helper class for layout algorithms that are based on tree structure. It keeps track of changes in observed layout context and stores current information about the tree structure - children of each node and several other parameters.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TreeLayoutHelper.TreeListener
A superclass for listeners that can be added to this observer to get notification whenever the tree structure changes.static class
TreeLayoutHelper.TreeNode
Represents a node in a tree structure and stores all information related to it.static class
TreeLayoutHelper.TreeNodeFactory
TreeLayoutObserver
uses instance of this class to create instances ofTreeLayoutHelper.TreeNode
.
-
Constructor Summary
Constructors Constructor Description TreeLayoutHelper(TreeLayoutHelper.TreeNodeFactory nodeFactory)
Constructs a newTreeLayoutHelper
for observing the givenLayoutContext
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
computeTree(org.eclipse.gef.graph.Node[] nodes)
Recomputes all the information about the tree structure (the same effect as creating newTreeLayoutObserver
).protected TreeLayoutHelper.TreeNode
getSuperRoot()
Returns Super Root, that is an artificial node being a common parent for all nodes in observed tree structure.protected TreeLayoutHelper.TreeNode
getTreeNode(org.eclipse.gef.graph.Node node)
Returns aTreeLayoutHelper.TreeNode
related to given node layout.
-
-
-
Constructor Detail
-
TreeLayoutHelper
public TreeLayoutHelper(TreeLayoutHelper.TreeNodeFactory nodeFactory)
Constructs a newTreeLayoutHelper
for observing the givenLayoutContext
. The givenTreeLayoutHelper.TreeNodeFactory
will be used for the construction ofTreeLayoutHelper.TreeNode
s. If no factory is supplied, theTreeLayoutHelper.TreeNodeFactory
will be used.- Parameters:
nodeFactory
- TheTreeLayoutHelper.TreeNodeFactory
to use.
-
-
Method Detail
-
computeTree
public void computeTree(org.eclipse.gef.graph.Node[] nodes)
Recomputes all the information about the tree structure (the same effect as creating newTreeLayoutObserver
).- Parameters:
nodes
- nodes
-
getSuperRoot
protected TreeLayoutHelper.TreeNode getSuperRoot()
Returns Super Root, that is an artificial node being a common parent for all nodes in observed tree structure.- Returns:
- Super Root
-
getTreeNode
protected TreeLayoutHelper.TreeNode getTreeNode(org.eclipse.gef.graph.Node node)
Returns aTreeLayoutHelper.TreeNode
related to given node layout. If such aTreeNode
doesn't exist, it's created.- Parameters:
node
- TheNode
for which to return the correspondingTreeLayoutHelper.TreeNode
.- Returns:
- The already existing
TreeLayoutHelper.TreeNode
related to the givenNode
or a newly created one in case there was no relatedTreeLayoutHelper.TreeNode
before.
-
-