Class AbstractTreeNode<D,​N extends AbstractTreeNode<D,​N>>

    • Constructor Detail

      • AbstractTreeNode

        public AbstractTreeNode​(boolean useLinkedList)
        Construct node.
        Parameters:
        useLinkedList - indicates if a linked list must be used to store the data. If false, an ArrayList will be used.
      • AbstractTreeNode

        public AbstractTreeNode​(boolean useLinkedList,
                                boolean copyDataCollection,
                                List<D> data)
        Construct node.
        Parameters:
        useLinkedList - indicates if a linked list must be used to store the data. If false, an ArrayList will be used.
        copyDataCollection - indicates if the given data collection is copied if true or the inner data collection will be the given collection itself if false.
        data - are the initial user data.
      • AbstractTreeNode

        public AbstractTreeNode​(boolean useLinkedList,
                                Collection<D> data)
        Construct node.
        Parameters:
        useLinkedList - indicates if a linked list must be used to store the data. If false, an ArrayList will be used.
        data - are the initial user data.
      • AbstractTreeNode

        public AbstractTreeNode​(boolean useLinkedList,
                                D data)
        Construct node.
        Parameters:
        useLinkedList - indicates if a linked list must be used to store the data. If false, an ArrayList will be used.
        data - are the initial user data.
    • Method Detail

      • getDepth

        @Pure
        public int getDepth()
        Description copied from interface: TreeNode
        Replies the depth level of this node. Depth level 0 is the root node, 1 are the children of the root node, etc.
        Returns:
        the height of the lowest leaf in the tree.
      • setChildAt

        public abstract boolean setChildAt​(int index,
                                           N newChild)
                                    throws IndexOutOfBoundsException
        Description copied from interface: TreeNode
        Set the n-th child in this node.
        Parameters:
        index - is the index of the child to reply
        newChild - is the new child node.
        Returns:
        true if it was set, otherwise false
        Throws:
        IndexOutOfBoundsException - if the given index was invalid
      • getParentNode

        @Pure
        public final N getParentNode()
        Description copied from interface: TreeNode
        Replies the parent node or null.
        Returns:
        the node that is containing this object.
      • setParentNodeReference

        boolean setParentNodeReference​(N newParent,
                                       boolean fireEvent)
        Set the reference to the parent node.
        Parameters:
        newParent - is the new parent.
        fireEvent - indicates if the event must be fired or not.
        Returns:
        true if an event must be fired due to the action of this function, otherwise false.
        Since:
        4.0
      • removeFromParent

        public N removeFromParent()
        Description copied from interface: IterableNode
        Remove this node from its parent.
        Returns:
        the parent node from which the node was removed.
      • removeDeeplyFromParent

        public void removeDeeplyFromParent()
        Description copied from interface: TreeNode
        Remove this node from its parent and remove the parent if it is becoming empty, and so one.
      • firePropertyChildAdded

        protected final void firePropertyChildAdded​(int childIndex,
                                                    N newChild)
        Fire the event for the node child sets.
        Parameters:
        childIndex - is the index of the child that was set. If the added node was root, this parameter is 0.
        newChild - is the child that was added.
      • firePropertyChildAdded

        void firePropertyChildAdded​(TreeNodeAddedEvent event)
        Fire the event for the node child sets.
        Parameters:
        event - the event.
      • firePropertyChildRemoved

        protected final void firePropertyChildRemoved​(int childIndex,
                                                      N oldChild)
        Fire the event for the removed node child.
        Parameters:
        childIndex - is the index of the child that was removed. If the added node was root, this parameter is 0.
        oldChild - is the child that was removed.
      • firePropertyChildRemoved

        void firePropertyChildRemoved​(TreeNodeRemovedEvent event)
        Fire the event for the removed node child.
        Parameters:
        event - the event.
      • firePropertyParentChanged

        protected final void firePropertyParentChanged​(N oldParent,
                                                       N newParent)
        Fire the event for the changes node parents.
        Parameters:
        oldParent - is the previous parent node
        newParent - is the current parent node
      • firePropertyParentChanged

        void firePropertyParentChanged​(N node,
                                       N oldParent,
                                       N newParent)
        Fire the event for the changes node parents.
        Parameters:
        node - is the node for which the parent has changed.
        oldParent - is the previous parent node
        newParent - is the current parent node
      • firePropertyParentChanged

        void firePropertyParentChanged​(TreeNodeParentChangedEvent event)
        Fire the event for the changes node parents.
        Parameters:
        event - the event.
      • isRoot

        @Pure
        public final boolean isRoot()
        Description copied from interface: TreeNode
        Replies if this node is a root.
        Returns:
        true is this node is the root, otherwise false
      • getChildren

        @Pure
        public final N[] getChildren​(Class<N> type)
        Description copied from interface: TreeNode
        Replies the child nodes of this node.

        This function may put null in the array cells if the current tree node has not a child at the corresponding index.

        Parameters:
        type - is the type of the children to reply.
        Returns:
        the children.
        See Also:
        TreeNode.getChildren(Object[]), TreeNode.children()
      • moveTo

        protected boolean moveTo​(N newParent,
                                 int index,
                                 boolean isDynamicChildList)
        Move this node in the given new node.

        If any child node is already present at the given position in the new parent node, the tree node may replace the existing node or insert the moving node according to its implementation.

        This function is preferred to a sequence of calls to removeFromParent() and setChildAt(int, AbstractTreeNode) because it fires a limited set of events dedicated to the move the node.

        Parameters:
        newParent - is the new parent for this node.
        index - is the position of this node in the new parent.
        isDynamicChildList - indicates if the parent node has a dynamic list of children. If true the given index is clamped to avoid IndexOutOfBoundsException when inserting this node in the parent node. If false an IndexOutOfBoundsException is thrown when the given index is outside the range of children of the parent node.
        Returns:
        true on success, otherwise false.