Package overit.geocall.util
Class Tree
java.lang.Object
overit.geocall.util.Tree
- All Implemented Interfaces:
Serializable,overit.geocall.clipboard.ClipboardObject,overit.geocall.marks.NameExposer
- Direct Known Subclasses:
CustomTree.SearchNode,overit.geocallapp.wfm.util.WFMTree
This class implements the hierarchical tree structure, with a root value and
subtrees of children with a parent node.
It exposes some utility methods to add and remove nodes on the tree.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void_reset()booleanaddAfterNodeByPath(String path, Tree t) Adds a node element after the sub-tree at the desired pathbooleanaddBeforeNodeByPath(String path, Tree t) Adds a node element before the sub-tree at the desired pathAdds a child in the desired positionAdds a child to the Tree, in the desired positionAdds a child, in the last position of the list of childs, to the TreebooleanaddChildNodeByPath(String path, int i, Tree t) Adds a child node of the Tree in the desired pathbooleanaddChildNodeByPath(String path, Tree t) Adds a child node, as last child, of the Tree in the desired pathbooleanChecks if the Tree contains the one passed as parameterCreates a copy of the TreedelChild(int i) Deletes the children in the i-th positionbooleandelNodeByPath(String path) Deletes the Tree element node located at the desired pathgetChild(int i) Returns the child element in the i-th positiongetChild(int i, boolean applyFilter, boolean reverse) Returns the child element in the i-th positionReturns the list of children of the Tree elementintReturns the number of childs of the Tree elementintgetDepth()Returns the depth of the Tree elementReturns the first children of the Tree elementgetFirstChild(boolean applyFilter) Returns the first children of the Tree elementgetHead()Returns the head object associated to the root of the TreeReturns the last children of the Tree elementgetLastChild(boolean applyFilter) Returns the last children of the Tree elementgetNodeByPath(String path) Returns the Tree element node at the desired pathReturns the parent Tree, the node directly connected to this when moving towards the rootgetPath()Returns the path of the Tree elementintgetPos()Returns the position of the Tree elementgetRoot()Returns the top element of the TreebooleanReturns the selected state of the TreebooleanReturns the stopped state of the TreebooleanChecks if the Tree is filtered.booleanisLeaf()Checks if the Tree is a leaf, ie a node with no childrenbooleanisRoot()Checks if the Tree is the top nodeoverit.geocall.clipboard.ClipboardObjectonCopy()overit.geocall.clipboard.ClipboardObjectonCut()voidonLost(boolean wasCut) overit.geocall.clipboard.ClipboardObjectonPaste(overit.geocall.clipboard.PasteEvent pe, boolean wasCut) Sets the child in the i-th positionvoidSets the head object to the root of the TreebooleansetNodeByPath(String path, Tree t) Sets the node of the Tree in the desired pathvoidsetSelected(boolean selected) Sets the selected state of the TreevoidsetStopped(boolean stopped) Sets the stopped state of the Tree
-
Field Details
-
_alChildren
-
_head
-
_tParent
-
_tRoot
-
_path
-
_pos
protected int _pos -
_depth
protected int _depth -
_stopped
protected boolean _stopped -
_selected
protected boolean _selected
-
-
Constructor Details
-
Tree
public Tree()Main constructor -
Tree
Empty constructor- Parameters:
t- Not used
-
-
Method Details
-
getStopped
public boolean getStopped()Returns the stopped state of the Tree- Returns:
trueif the Tree is in stopped state,falseotherwise
-
setStopped
public void setStopped(boolean stopped) Sets the stopped state of the Tree- Parameters:
stopped- The boolean value that defines the stopped state of the Tree
-
getSelected
public boolean getSelected()Returns the selected state of the Tree- Returns:
trueif the Tree is in selected state,falseotherwise
-
setSelected
public void setSelected(boolean selected) Sets the selected state of the Tree- Parameters:
selected- The boolean value that defines the selected state of the Tree
-
isFiltered
public boolean isFiltered()Checks if the Tree is filtered. The method returns alwaysfalse.- Returns:
false
-
getPos
public int getPos()Returns the position of the Tree element- Returns:
- The position of the Tree element, that is the position in the list of siblings
-
getPath
Returns the path of the Tree element- Returns:
- The string that represents the sequence of nodes connecting the root to the element
-
_reset
protected void _reset() -
setChild
Sets the child in the i-th position- Parameters:
i- The position in which set the childt- The Tree element to set- Returns:
- The instance of Tree with the given child
-
setNodeByPath
Sets the node of the Tree in the desired path- Parameters:
path- The path that defines the location in which set the nodet- The Tree element to set- Returns:
trueif the operation is successfull,falseotherwise
-
addChild
Adds a child to the Tree, in the desired position- Parameters:
i- The position in which add the childt- The Tree element to add- Returns:
- The instance of Tree with the added child
-
addChild
Adds a child, in the last position of the list of childs, to the Tree- Parameters:
t- The Tree element to add as a child- Returns:
- The instance of Tree with the added child
-
addChild
Adds a child in the desired position- Parameters:
i- The position in which add the childt- The Tree element to add- Returns:
- The instance of Tree with the added child
-
addChildNodeByPath
Adds a child node of the Tree in the desired path- Parameters:
path- The path that defines the location in which set the nodei- The position of the child to addt- The Tree element to set- Returns:
trueif the operation is successfull,falseotherwise
-
addChildNodeByPath
Adds a child node, as last child, of the Tree in the desired path- Parameters:
path- The path that defines the location in which set the nodet- The Tree element to set- Returns:
trueif the operation is successfull,falseotherwise
-
addBeforeNodeByPath
Adds a node element before the sub-tree at the desired path- Parameters:
path- The path that defines the locationt- The Tree element to add before- Returns:
trueif the operation is successfull,falseotherwise
-
addAfterNodeByPath
Adds a node element after the sub-tree at the desired path- Parameters:
path- The path that defines the locationt- The Tree element to add after- Returns:
trueif the operation is successfull,falseotherwise
-
delChild
Deletes the children in the i-th position- Parameters:
i- The position of the children element to delete- Returns:
- The deleted element, or
nullif the position is greater than the number of childs
-
getChildren
Returns the list of children of the Tree element- Returns:
- The list of child nodes of the Tree
-
getFirstChild
Returns the first children of the Tree element- Returns:
- The first child node of the Tree
-
getFirstChild
Returns the first children of the Tree element- Parameters:
applyFilter- boolean value that defines if the search of the first child must be performed even on the filtered nodes- Returns:
- The first child node of the Tree
-
getLastChild
Returns the last children of the Tree element- Returns:
- The last child of the Tree
-
getLastChild
Returns the last children of the Tree element- Parameters:
applyFilter- boolean value that defines if the search of the last child must be performed even on the filtered nodes- Returns:
- The last child node of the Tree
-
getChild
Returns the child element in the i-th position- Parameters:
i- The position of the child- Returns:
- The Tree element node located in the desired position, or
null
-
getChild
Returns the child element in the i-th position- Parameters:
i- The position of the childapplyFilter- boolean value that defines if the search of the child must be performed even on the filtered nodesreverse- boolean value that defines if the search must be performed towards the leafs or towards the root- Returns:
- The Tree element node
-
getNodeByPath
Returns the Tree element node at the desired path- Parameters:
path- The path that defines the location of the node element- Returns:
- The Tree element at the desired path
-
delNodeByPath
Deletes the Tree element node located at the desired path- Parameters:
path- The path that defines the location of the node element- Returns:
trueif the operation is successfull,falseotherwise
-
getParent
Returns the parent Tree, the node directly connected to this when moving towards the root- Returns:
- The parent Tree
-
isRoot
public boolean isRoot()Checks if the Tree is the top node- Returns:
trueif the Tree is a root,falseotherwise
-
getRoot
Returns the top element of the Tree- Returns:
- The Tree that corresponds to the root element of the Tree
-
isLeaf
public boolean isLeaf()Checks if the Tree is a leaf, ie a node with no children- Returns:
trueif the Tree is a leaf,falseotherwise
-
contains
Checks if the Tree contains the one passed as parameter- Parameters:
t- The Tree searched- Returns:
trueif the Tree contains the one passed as parameter,falseotherwise
-
getDepth
public int getDepth()Returns the depth of the Tree element- Returns:
- The depth of the Tree, that is the number of edges from the root to the node
-
getChildrenSize
public int getChildrenSize()Returns the number of childs of the Tree element- Returns:
- The number of nodes directly connected to the element
-
getHead
Returns the head object associated to the root of the Tree- Returns:
- The head object
-
setHead
Sets the head object to the root of the Tree- Parameters:
head- The object to set
-
createCopy
Creates a copy of the Tree- Returns:
- A new Tree that is the copy of the object on which the method was called
-
onCopy
public overit.geocall.clipboard.ClipboardObject onCopy()- Specified by:
onCopyin interfaceoverit.geocall.clipboard.ClipboardObject
-
onCut
public overit.geocall.clipboard.ClipboardObject onCut()- Specified by:
onCutin interfaceoverit.geocall.clipboard.ClipboardObject
-
onPaste
public overit.geocall.clipboard.ClipboardObject onPaste(overit.geocall.clipboard.PasteEvent pe, boolean wasCut) throws overit.geocall.clipboard.ClipboardException - Specified by:
onPastein interfaceoverit.geocall.clipboard.ClipboardObject- Throws:
overit.geocall.clipboard.ClipboardException
-
onLost
public void onLost(boolean wasCut) - Specified by:
onLostin interfaceoverit.geocall.clipboard.ClipboardObject
-