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

public class Tree extends Object implements overit.geocall.clipboard.ClipboardObject
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 Details

    • _alChildren

      protected ArrayList _alChildren
    • _head

      protected Object _head
    • _tParent

      protected Tree _tParent
    • _tRoot

      protected Tree _tRoot
    • _path

      protected String _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

      public Tree(Tree t)
      Empty constructor
      Parameters:
      t - Not used
  • Method Details

    • getStopped

      public boolean getStopped()
      Returns the stopped state of the Tree
      Returns:
      true if the Tree is in stopped state, false otherwise
    • 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:
      true if the Tree is in selected state, false otherwise
    • 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 always false.
      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

      public String 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

      public Tree setChild(int i, Tree t)
      Sets the child in the i-th position
      Parameters:
      i - The position in which set the child
      t - The Tree element to set
      Returns:
      The instance of Tree with the given child
    • setNodeByPath

      public boolean setNodeByPath(String path, Tree t)
      Sets the node of the Tree in the desired path
      Parameters:
      path - The path that defines the location in which set the node
      t - The Tree element to set
      Returns:
      true if the operation is successfull, false otherwise
    • addChild

      public Tree addChild(Integer i, Tree t)
      Adds a child to the Tree, in the desired position
      Parameters:
      i - The position in which add the child
      t - The Tree element to add
      Returns:
      The instance of Tree with the added child
    • addChild

      public Tree addChild(Tree t)
      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

      public Tree addChild(int i, Tree t)
      Adds a child in the desired position
      Parameters:
      i - The position in which add the child
      t - The Tree element to add
      Returns:
      The instance of Tree with the added child
    • addChildNodeByPath

      public boolean addChildNodeByPath(String path, int i, Tree t)
      Adds a child node of the Tree in the desired path
      Parameters:
      path - The path that defines the location in which set the node
      i - The position of the child to add
      t - The Tree element to set
      Returns:
      true if the operation is successfull, false otherwise
    • addChildNodeByPath

      public boolean addChildNodeByPath(String path, Tree t)
      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 node
      t - The Tree element to set
      Returns:
      true if the operation is successfull, false otherwise
    • addBeforeNodeByPath

      public boolean addBeforeNodeByPath(String path, Tree t)
      Adds a node element before the sub-tree at the desired path
      Parameters:
      path - The path that defines the location
      t - The Tree element to add before
      Returns:
      true if the operation is successfull, false otherwise
    • addAfterNodeByPath

      public boolean addAfterNodeByPath(String path, Tree t)
      Adds a node element after the sub-tree at the desired path
      Parameters:
      path - The path that defines the location
      t - The Tree element to add after
      Returns:
      true if the operation is successfull, false otherwise
    • delChild

      public Tree delChild(int i)
      Deletes the children in the i-th position
      Parameters:
      i - The position of the children element to delete
      Returns:
      The deleted element, or null if the position is greater than the number of childs
    • getChildren

      public ArrayList getChildren()
      Returns the list of children of the Tree element
      Returns:
      The list of child nodes of the Tree
    • getFirstChild

      public Tree getFirstChild()
      Returns the first children of the Tree element
      Returns:
      The first child node of the Tree
    • getFirstChild

      public Tree getFirstChild(boolean applyFilter)
      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

      public Tree getLastChild()
      Returns the last children of the Tree element
      Returns:
      The last child of the Tree
    • getLastChild

      public Tree getLastChild(boolean applyFilter)
      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

      public Tree getChild(int i)
      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

      public Tree getChild(int i, boolean applyFilter, boolean reverse)
      Returns the child element in the i-th position
      Parameters:
      i - The position of the child
      applyFilter - boolean value that defines if the search of the child must be performed even on the filtered nodes
      reverse - boolean value that defines if the search must be performed towards the leafs or towards the root
      Returns:
      The Tree element node
    • getNodeByPath

      public Tree getNodeByPath(String path)
      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

      public boolean delNodeByPath(String path)
      Deletes the Tree element node located at the desired path
      Parameters:
      path - The path that defines the location of the node element
      Returns:
      true if the operation is successfull, false otherwise
    • getParent

      public Tree 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:
      true if the Tree is a root, false otherwise
    • getRoot

      public Tree 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:
      true if the Tree is a leaf, false otherwise
    • contains

      public boolean contains(Tree t)
      Checks if the Tree contains the one passed as parameter
      Parameters:
      t - The Tree searched
      Returns:
      true if the Tree contains the one passed as parameter, false otherwise
    • 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

      public Object getHead()
      Returns the head object associated to the root of the Tree
      Returns:
      The head object
    • setHead

      public void setHead(Object head)
      Sets the head object to the root of the Tree
      Parameters:
      head - The object to set
    • createCopy

      public Tree 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:
      onCopy in interface overit.geocall.clipboard.ClipboardObject
    • onCut

      public overit.geocall.clipboard.ClipboardObject onCut()
      Specified by:
      onCut in interface overit.geocall.clipboard.ClipboardObject
    • onPaste

      public overit.geocall.clipboard.ClipboardObject onPaste(overit.geocall.clipboard.PasteEvent pe, boolean wasCut) throws overit.geocall.clipboard.ClipboardException
      Specified by:
      onPaste in interface overit.geocall.clipboard.ClipboardObject
      Throws:
      overit.geocall.clipboard.ClipboardException
    • onLost

      public void onLost(boolean wasCut)
      Specified by:
      onLost in interface overit.geocall.clipboard.ClipboardObject