Package adams.gui.flow.tree
Class Node
- java.lang.Object
-
- javax.swing.tree.DefaultMutableTreeNode
-
- adams.gui.core.BaseTreeNode
-
- adams.gui.core.LazyExpansionTreeNode
-
- adams.gui.flow.tree.Node
-
- All Implemented Interfaces:
Destroyable
,Transferable
,Serializable
,Cloneable
,MutableTreeNode
,TreeNode
public class Node extends LazyExpansionTreeNode implements Destroyable
A custom tree node for actors.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static AnnotationProcessor
m_AnnotationProcessor
the annotation processor.protected static Boolean
m_AnnotationProcessorInitialized
whether the processor has been initialized.protected boolean
m_Bookmarked
whether the node is currently bookmarked.protected String
m_CommandLine
the commandline (cache for undo/redo).protected boolean
m_Editable
whether the node is editable.protected AbstractFileChangeMonitor
m_ExternalFlowMonitor
for monitoring external actor files.protected Tree
m_Owner
the owning tree.protected String
m_RenderString
the render string.protected HashSet<String>
m_Variables
the variables.-
Fields inherited from class adams.gui.core.LazyExpansionTreeNode
m_ExpansionOccurred
-
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canExpand()
Returns whether the node can be expanded at all.protected String
classArrayToString(Class[] classes)
Turns a class array (from input/output arrays) into a string.void
destroy()
Frees up memory in a "destructive" non-reversible way.protected boolean
doExpand()
Expands this node.protected void
doReset()
Resets the node.void
expandOrReexpandIfNecessary(boolean notify)
Expands or e-expands the node if necessary.String
generateSizeAttribute(String size)
Generates the size attribute HTML string.Actor
getActor()
Returns the stored (stripped down) actor.String
getCommandLine()
Returns the (cached) commandline of the actor.boolean
getExpansionOccurred()
Returns whether the expansion has already occurred.Actor
getFullActor()
Returns the full actor, i.e., including all possible sub-actors.Actor
getFullActor(StringBuilder errors)
Returns the full actor, i.e., including all possible sub-actors.String
getFullName()
Returns the full name of the node (up to the root).Tree
getOwner()
Returns the tree the node belongs to.boolean
hasOwner()
Returns whether an owner is set.int
indexOf(String name)
Returns the index of the child with the specified actor name.void
invalidateRendering()
Invalidates the rendering string recursively, forces the tree to redraw itself.boolean
isBookmarked()
Returns whether the node is currently bookmarked.boolean
isEditable()
Returns whether the node is editable.boolean
isRemovable()
Returns whether this node can be removed or not.int
replace(Comparable find, Comparable replace, boolean recursive)
Replaces an object in the tree (ie, the actors), recursion is optional.boolean
requiresReexpand()
Returns whether the node requires resetting.protected String
scaleFontSize(String size)
Scales the HTML font size using the icon scaling factor of the tree.void
setActor(Actor value)
Sets the actor.void
setBookmarked(boolean value)
Sets whether the node is being bookmarked.void
setEditable(boolean value)
Sets whether the node is editable.void
setEditable(boolean value, boolean recurse)
Sets whether the node is editable.void
setOwner(Tree value)
Sets the owning tree recursively.protected void
setOwner(Tree value, boolean invalidate)
Sets the owning tree recursively.void
setUserObject(Object userObject)
Sets the user object for this node touserObject
.void
sortChildren(Comparator<Node> comp)
Sorts the children using the supplied comparator.static String
strippedCommandLine(Actor actor)
Returns the commandline of the stripped down version of the actor, i.e., for ActorHandlers, without any sub-actors.String
toPlainText()
Returns the actor in plain text.String
toString()
Returns the actor in HTML.Transferable
toTransferable()
Turns the node/userObject into a transferable string.-
Methods inherited from class adams.gui.core.LazyExpansionTreeNode
collapse, expand, expandOrReexpandIfNecessary, reexpand, reset, setExpansionOccurred
-
Methods inherited from class adams.gui.core.BaseTreeNode
getChildren, getTransferData, getTransferDataFlavors, isDataFlavorSupported
-
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent
-
-
-
-
Field Detail
-
m_Owner
protected transient Tree m_Owner
the owning tree.
-
m_RenderString
protected String m_RenderString
the render string.
-
m_Editable
protected boolean m_Editable
whether the node is editable.
-
m_Bookmarked
protected boolean m_Bookmarked
whether the node is currently bookmarked.
-
m_AnnotationProcessor
protected static AnnotationProcessor m_AnnotationProcessor
the annotation processor.
-
m_AnnotationProcessorInitialized
protected static Boolean m_AnnotationProcessorInitialized
whether the processor has been initialized.
-
m_CommandLine
protected String m_CommandLine
the commandline (cache for undo/redo).
-
m_ExternalFlowMonitor
protected AbstractFileChangeMonitor m_ExternalFlowMonitor
for monitoring external actor files.
-
-
Method Detail
-
setUserObject
public void setUserObject(Object userObject)
Sets the user object for this node touserObject
.- Specified by:
setUserObject
in interfaceMutableTreeNode
- Overrides:
setUserObject
in classDefaultMutableTreeNode
- Parameters:
userObject
- the Object that constitutes this node's user-specified data
-
hasOwner
public boolean hasOwner()
Returns whether an owner is set.- Returns:
- true if owner is set
-
setOwner
public void setOwner(Tree value)
Sets the owning tree recursively.- Parameters:
value
- the tree this node belongs to
-
setOwner
protected void setOwner(Tree value, boolean invalidate)
Sets the owning tree recursively.- Parameters:
value
- the tree this node belongs to
-
getOwner
public Tree getOwner()
Returns the tree the node belongs to.- Returns:
- the tree
-
setActor
public void setActor(Actor value)
Sets the actor. Strips it down before using it.- Parameters:
value
- the actor
-
getActor
public Actor getActor()
Returns the stored (stripped down) actor.- Returns:
- the actor
-
getFullName
public String getFullName()
Returns the full name of the node (up to the root).- Returns:
- the full name
-
getFullActor
public Actor getFullActor()
Returns the full actor, i.e., including all possible sub-actors.- Returns:
- the generated actor
-
getFullActor
public Actor getFullActor(StringBuilder errors)
Returns the full actor, i.e., including all possible sub-actors.- Parameters:
errors
- for appending errors encountered while assembling, use null to ignore- Returns:
- the generated actor
-
isRemovable
public boolean isRemovable()
Returns whether this node can be removed or not. E.g., the elements of non-mutable ActorHandlers.- Returns:
- true if removeable
-
replace
public int replace(Comparable find, Comparable replace, boolean recursive)
Replaces an object in the tree (ie, the actors), recursion is optional.- Parameters:
find
- the object to findreplace
- the replacementrecursive
- whether to recurse deeper in the tree- Returns:
- true if something got replaced
-
toTransferable
public Transferable toTransferable()
Turns the node/userObject into a transferable string.- Overrides:
toTransferable
in classBaseTreeNode
- Returns:
- the generated string
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.- Specified by:
destroy
in interfaceDestroyable
-
classArrayToString
protected String classArrayToString(Class[] classes)
Turns a class array (from input/output arrays) into a string.- Parameters:
classes
- the classes to turn into a list- Returns:
- the generated list string
-
scaleFontSize
protected String scaleFontSize(String size)
Scales the HTML font size using the icon scaling factor of the tree.- Parameters:
size
- the HTML font size string- Returns:
- the new font size
-
generateSizeAttribute
public String generateSizeAttribute(String size)
Generates the size attribute HTML string. Gets skipped if the scale factor differs from 1.0, as the rendering doesn't take this properly into account.- Parameters:
size
- the size string to parse/use- Returns:
- the HTML code, can be empty string
- See Also:
scaleFontSize(String)
-
toString
public String toString()
Returns the actor in HTML.- Overrides:
toString
in classDefaultMutableTreeNode
- Returns:
- the HTML description
-
toPlainText
public String toPlainText()
Returns the actor in plain text.- Overrides:
toPlainText
in classBaseTreeNode
- Returns:
- the actor
-
strippedCommandLine
public static String strippedCommandLine(Actor actor)
Returns the commandline of the stripped down version of the actor, i.e., for ActorHandlers, without any sub-actors.- Parameters:
actor
- the actor to strip down- Returns:
- the stripped down actor
- See Also:
ActorHandler
-
invalidateRendering
public void invalidateRendering()
Invalidates the rendering string recursively, forces the tree to redraw itself.
-
indexOf
public int indexOf(String name)
Returns the index of the child with the specified actor name.- Parameters:
name
- the name to look for- Returns:
- the index, -1 if not found
-
canExpand
public boolean canExpand()
Returns whether the node can be expanded at all.- Overrides:
canExpand
in classLazyExpansionTreeNode
- Returns:
- true if it can be expanded
-
getExpansionOccurred
public boolean getExpansionOccurred()
Returns whether the expansion has already occurred.- Overrides:
getExpansionOccurred
in classLazyExpansionTreeNode
- Returns:
- true if the expansion has already occurred
-
doExpand
protected boolean doExpand()
Expands this node.- Specified by:
doExpand
in classLazyExpansionTreeNode
- Returns:
- true if structure below this node was changed
-
requiresReexpand
public boolean requiresReexpand()
Returns whether the node requires resetting.- Overrides:
requiresReexpand
in classLazyExpansionTreeNode
- Returns:
- true if it can be expanded
-
doReset
protected void doReset()
Resets the node.- Specified by:
doReset
in classLazyExpansionTreeNode
-
setEditable
public void setEditable(boolean value)
Sets whether the node is editable.- Parameters:
value
- if true then the node will be editable
-
setEditable
public void setEditable(boolean value, boolean recurse)
Sets whether the node is editable.- Parameters:
value
- if true then the node will be editablerecurse
- whether to set the state recursively
-
setBookmarked
public void setBookmarked(boolean value)
Sets whether the node is being bookmarked.- Parameters:
value
- true if bookmarked
-
isBookmarked
public boolean isBookmarked()
Returns whether the node is currently bookmarked.- Returns:
- true if bookmarked
-
isEditable
public boolean isEditable()
Returns whether the node is editable.- Returns:
- true if the node is editable
-
getCommandLine
public String getCommandLine()
Returns the (cached) commandline of the actor.- Returns:
- the commandline
-
sortChildren
public void sortChildren(Comparator<Node> comp)
Sorts the children using the supplied comparator.- Parameters:
comp
- the comparator to use
-
expandOrReexpandIfNecessary
public void expandOrReexpandIfNecessary(boolean notify)
Expands or e-expands the node if necessary.
-
-