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 AnnotationProcessorm_AnnotationProcessorthe annotation processor.protected static Booleanm_AnnotationProcessorInitializedwhether the processor has been initialized.protected booleanm_Bookmarkedwhether the node is currently bookmarked.protected Stringm_CommandLinethe commandline (cache for undo/redo).protected booleanm_Editablewhether the node is editable.protected AbstractFileChangeMonitorm_ExternalFlowMonitorfor monitoring external actor files.protected Treem_Ownerthe owning tree.protected Stringm_RenderStringthe render string.protected HashSet<String>m_Variablesthe 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 booleancanExpand()Returns whether the node can be expanded at all.protected StringclassArrayToString(Class[] classes)Turns a class array (from input/output arrays) into a string.voiddestroy()Frees up memory in a "destructive" non-reversible way.protected booleandoExpand()Expands this node.protected voiddoReset()Resets the node.voidexpandOrReexpandIfNecessary(boolean notify)Expands or e-expands the node if necessary.StringgenerateSizeAttribute(String size)Generates the size attribute HTML string.ActorgetActor()Returns the stored (stripped down) actor.StringgetCommandLine()Returns the (cached) commandline of the actor.booleangetExpansionOccurred()Returns whether the expansion has already occurred.ActorgetFullActor()Returns the full actor, i.e., including all possible sub-actors.ActorgetFullActor(StringBuilder errors)Returns the full actor, i.e., including all possible sub-actors.StringgetFullName()Returns the full name of the node (up to the root).TreegetOwner()Returns the tree the node belongs to.booleanhasOwner()Returns whether an owner is set.intindexOf(String name)Returns the index of the child with the specified actor name.voidinvalidateRendering()Invalidates the rendering string recursively, forces the tree to redraw itself.booleanisBookmarked()Returns whether the node is currently bookmarked.booleanisEditable()Returns whether the node is editable.booleanisRemovable()Returns whether this node can be removed or not.intreplace(Comparable find, Comparable replace, boolean recursive)Replaces an object in the tree (ie, the actors), recursion is optional.booleanrequiresReexpand()Returns whether the node requires resetting.protected StringscaleFontSize(String size)Scales the HTML font size using the icon scaling factor of the tree.voidsetActor(Actor value)Sets the actor.voidsetBookmarked(boolean value)Sets whether the node is being bookmarked.voidsetEditable(boolean value)Sets whether the node is editable.voidsetEditable(boolean value, boolean recurse)Sets whether the node is editable.voidsetOwner(Tree value)Sets the owning tree recursively.protected voidsetOwner(Tree value, boolean invalidate)Sets the owning tree recursively.voidsetUserObject(Object userObject)Sets the user object for this node touserObject.voidsortChildren(Comparator<Node> comp)Sorts the children using the supplied comparator.static StringstrippedCommandLine(Actor actor)Returns the commandline of the stripped down version of the actor, i.e., for ActorHandlers, without any sub-actors.StringtoPlainText()Returns the actor in plain text.StringtoString()Returns the actor in HTML.TransferabletoTransferable()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:
setUserObjectin interfaceMutableTreeNode- Overrides:
setUserObjectin 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:
toTransferablein classBaseTreeNode- Returns:
- the generated string
-
destroy
public void destroy()
Frees up memory in a "destructive" non-reversible way.- Specified by:
destroyin 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:
toStringin classDefaultMutableTreeNode- Returns:
- the HTML description
-
toPlainText
public String toPlainText()
Returns the actor in plain text.- Overrides:
toPlainTextin 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:
canExpandin classLazyExpansionTreeNode- Returns:
- true if it can be expanded
-
getExpansionOccurred
public boolean getExpansionOccurred()
Returns whether the expansion has already occurred.- Overrides:
getExpansionOccurredin classLazyExpansionTreeNode- Returns:
- true if the expansion has already occurred
-
doExpand
protected boolean doExpand()
Expands this node.- Specified by:
doExpandin classLazyExpansionTreeNode- Returns:
- true if structure below this node was changed
-
requiresReexpand
public boolean requiresReexpand()
Returns whether the node requires resetting.- Overrides:
requiresReexpandin classLazyExpansionTreeNode- Returns:
- true if it can be expanded
-
doReset
protected void doReset()
Resets the node.- Specified by:
doResetin 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.
-
-