Package adams.gui.flow.tree
Class TreeHelper
- java.lang.Object
-
- adams.gui.flow.tree.TreeHelper
-
public class TreeHelper extends Object
Helper class for flow tree related stuff.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description TreeHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Node
buildTree(Actor root)
Builds the tree with the given root.protected static Node[]
buildTree(Node parent, Actor[] actors, boolean append)
Builds the tree recursively.static Node
buildTree(Node parent, Actor actor, boolean append)
Builds the tree recursively.protected static Node
buildTree(Node root, List nested, MessageCollection warnings, MessageCollection errors, ArrayConsumer consumer)
Builds the tree from the nested commandlines.static Node
buildTree(List nested)
Builds the tree from the nested commandlines.static Node
buildTree(List nested, MessageCollection warnings, MessageCollection errors)
Builds the tree from the nested commandlines.static List<String>
getCommandLines(Node root)
Returns the nested commandlines.static List<String>
getCommandLines(Node root, boolean noExtActors)
Returns the nested commandlines.protected static void
getCommandLines(Node node, List<String> cmdlines, boolean noExtActors)
Adds the node and its children to the list of commandlines.static List
getNested(Node root)
Returns the nested format.static List
getNested(Node root, boolean noExtActors)
Returns the nested format.protected static void
getNested(Node node, List nested, boolean noExtActors)
Adds the node and its children to the nested format.protected static String
indent(String s, int numBlanks)
Inserts blanks at the start of the string.static Actor[]
pathsToActors(TreePath[] paths)
Converts the paths to actors (the last component in a path).static Actor[]
pathsToActors(TreePath[] paths, boolean full)
Converts the paths to actors (the last component in a path).static List[]
pathsToNested(TreePath[] paths)
Converts the paths to actors (the last component in a path).static Node[]
pathsToNodes(TreePath[] paths)
Converts the paths to actors (the last component in a path).static Actor
pathToActor(TreePath path)
Converts the path to an actor (the last component in a path).static Actor
pathToActor(TreePath path, boolean full)
Converts the path to an actor (the last component in a path).static List
pathToNested(TreePath path)
Converts the path to nested node format (the last component in a path).static Node
pathToNode(TreePath path)
Converts the path to a node (the last component in a path).static ActorPath
treePathToActorPath(TreePath path)
-
-
-
Method Detail
-
pathToNode
public static Node pathToNode(TreePath path)
Converts the path to a node (the last component in a path).- Parameters:
path
- the path to the actor- Returns:
- the node
-
pathsToNodes
public static Node[] pathsToNodes(TreePath[] paths)
Converts the paths to actors (the last component in a path).- Parameters:
paths
- the paths to the actors- Returns:
- the actors
-
pathToActor
public static Actor pathToActor(TreePath path)
Converts the path to an actor (the last component in a path). Does not return the "full" actor.- Parameters:
path
- the path to the actor- Returns:
- the actor
-
pathToActor
public static Actor pathToActor(TreePath path, boolean full)
Converts the path to an actor (the last component in a path). "Full" actor means including (potential) sub-tree.- Parameters:
path
- the path to the actorfull
- whether to return the full actor- Returns:
- the actor
-
pathsToActors
public static Actor[] pathsToActors(TreePath[] paths)
Converts the paths to actors (the last component in a path). Does not return the "full" actor.- Parameters:
paths
- the paths to the actors- Returns:
- the actors
-
pathsToActors
public static Actor[] pathsToActors(TreePath[] paths, boolean full)
Converts the paths to actors (the last component in a path). "Full" actor means including (potential) sub-tree.- Parameters:
paths
- the paths to the actorsfull
- whether to return the full actor- Returns:
- the actors
-
pathToNested
public static List pathToNested(TreePath path)
Converts the path to nested node format (the last component in a path).- Parameters:
path
- the path to the actor- Returns:
- the nested format
-
pathsToNested
public static List[] pathsToNested(TreePath[] paths)
Converts the paths to actors (the last component in a path).- Parameters:
paths
- the paths to the actors- Returns:
- the actors
-
treePathToActorPath
public static ActorPath treePathToActorPath(TreePath path)
- Parameters:
path
- the path to convert- Returns:
- the generated path
-
buildTree
public static Node buildTree(List nested)
Builds the tree from the nested commandlines.- Parameters:
nested
- the nested commandlines- Returns:
- the root node, null if failed to build
-
buildTree
public static Node buildTree(List nested, MessageCollection warnings, MessageCollection errors)
Builds the tree from the nested commandlines.- Parameters:
nested
- the nested commandlineswarnings
- for storing any warningserrors
- for storing any errors- Returns:
- the root node, null if failed to build
-
buildTree
protected static Node buildTree(Node root, List nested, MessageCollection warnings, MessageCollection errors, ArrayConsumer consumer)
Builds the tree from the nested commandlines.- Parameters:
root
- the root node to add tonested
- the nested commandlineswarnings
- for storing any warningserrors
- for storing any errors- Returns:
- the root node, null if failed to build
-
buildTree
public static Node buildTree(Actor root)
Builds the tree with the given root.- Parameters:
root
- the root actor, can be null- Returns:
- the root node
-
buildTree
public static Node buildTree(Node parent, Actor actor, boolean append)
Builds the tree recursively.- Parameters:
parent
- the parent to add the actor toactor
- the actor to addappend
- whether to append the sub-tree to the parent or just return it (recursive calls always append the sub-tree!)- Returns:
- the generated node
-
buildTree
protected static Node[] buildTree(Node parent, Actor[] actors, boolean append)
Builds the tree recursively.- Parameters:
parent
- the parent to add the actor toactors
- the actors to addappend
- whether to append the sub-tree to the parent or just return it (recursive calls always append the sub-tree!)- Returns:
- the generated nodes
-
indent
protected static String indent(String s, int numBlanks)
Inserts blanks at the start of the string.- Parameters:
s
- the string to processnumBlanks
- the number of blanks to insert- Returns:
- the processed string
-
getCommandLines
protected static void getCommandLines(Node node, List<String> cmdlines, boolean noExtActors)
Adds the node and its children to the list of commandlines.- Parameters:
node
- the node to addcmdlines
- the command lines to add to
-
getCommandLines
public static List<String> getCommandLines(Node root)
Returns the nested commandlines. Indentation in blanks represents nesting level.- Parameters:
root
- the root node- Returns:
- the tree as nested commandlines
-
getCommandLines
public static List<String> getCommandLines(Node root, boolean noExtActors)
Returns the nested commandlines. Indentation in blanks represents nesting level.- Parameters:
root
- the root nodenoExtActors
- whether to exclude external actors- Returns:
- the tree as nested commandlines
-
getNested
protected static void getNested(Node node, List nested, boolean noExtActors)
Adds the node and its children to the nested format.- Parameters:
node
- the node to addnested
- the nested format to add to
-
getNested
public static List getNested(Node root)
Returns the nested format.- Parameters:
root
- the root node- Returns:
- the tree as nested format
-
-