Class InnerNode<T>

  • All Implemented Interfaces:
    Bounded, Node<T>, TreeNode

    public class InnerNode<T>
    extends RTreeNode<T>
    implements Node<T>
    a non-leaf node of the R-Tree. Contains a list of non leaf or leaf node children
    Author:
    Tom Nelson
    • Method Detail

      • create

        public static <T> InnerNode<T> create​(Node<T> node)
        create a new InnerVertex with one child
        Type Parameters:
        T - the type of the node and children
        Parameters:
        node - the first child for the created Node
        Returns:
        the newly created InnerVertex
      • create

        public static <T> InnerNode<T> create​(InnerNode<T> node)
        create a new InnerVertex with one child
        Type Parameters:
        T - the type of the Node
        Parameters:
        node - the first child of the created node
        Returns:
        the newly created InnerVertex
      • create

        public static <T> InnerNode<T> create​(Collection<Node<T>> nodes)
        create a new InnerVertex with the passed nodes as children
        Type Parameters:
        T - the type of the Node
        Parameters:
        nodes - the children for the new InnerVertex
        Returns:
        the newly created InnerVertex
      • isLeafChildren

        public boolean isLeafChildren()
        true if the children are LeafVertices
        Specified by:
        isLeafChildren in interface Node<T>
        Returns:
        whether this node's children are LeafNodes
      • get

        public Node<T> get​(int i)
        return the ith child node
        Parameters:
        i - the index of the child to return
        Returns:
        the ith child
      • getChildren

        public List<Node<T>> getChildren()
        Specified by:
        getChildren in interface TreeNode
        Returns:
        an immutable collection of the child nodes
      • getBounds

        public Rectangle2D getBounds()
        Description copied from interface: Bounded
        return the Rectangle of the bounding box
        Specified by:
        getBounds in interface Bounded
        Specified by:
        getBounds in interface TreeNode
        Returns:
        the bounding box of this InnerVertex. A zero sized Rectangle is returned if this InnerVertex is empty
      • recalculateBounds

        public Node<T> recalculateBounds()
        recompute the bounding box for this InnerVertex, then the recompute for parent node Climbs the tree to the root as it recalcultes. This i required when a leaf node is removed.
        Specified by:
        recalculateBounds in interface Node<T>
        Returns:
        the Node with new bounds
      • getPickedObject

        public T getPickedObject​(Point2D p)
        Specified by:
        getPickedObject in interface Node<T>
        Parameters:
        p - the point to search
        Returns:
        the element in the Leaf node that is contained by p
      • size

        public int size()
        Specified by:
        size in interface Node<T>
        Returns:
        the number of child nodes
      • getContainingLeaf

        public LeafNode<T> getContainingLeaf​(T element)
        Specified by:
        getContainingLeaf in interface Node<T>
        Parameters:
        element - the element to look for
        Returns:
        the LeafVertex that contains the element
      • getContainingLeafs

        public Set<LeafNode<T>> getContainingLeafs​(Set<LeafNode<T>> containingLeafs,
                                                   Point2D p)
        Specified by:
        getContainingLeafs in interface Node<T>
        Parameters:
        p - the point to look for
        Returns:
        Collection of the LeafVertices that would contain the passed point
      • getContainingLeafs

        public Set<LeafNode<T>> getContainingLeafs​(Set<LeafNode<T>> containingLeafs,
                                                   double x,
                                                   double y)
        Specified by:
        getContainingLeafs in interface Node<T>
        Parameters:
        x - coordinate of a point to look for
        y - coordinate of a point to look for
        Returns:
        Collection of the LeafVertices that would contain the passed coordinates
      • collectGrids

        public Collection<Shape> collectGrids​(Collection<Shape> list)
        gather the RTree Node rectangles into a Collection
        Specified by:
        collectGrids in interface Node<T>
        Parameters:
        list - an ordered collection of shapes
        Returns:
      • add

        public Node<T> add​(SplitterContext<T> splitterContext,
                           T element,
                           Rectangle2D bounds)
        Specified by:
        add in interface Node<T>
        Parameters:
        splitterContext - rules for splitting nodes
        element - the element to add
        bounds - the bounds of the element to add
        Returns:
        the returned node or its parent
      • remove

        public Node<T> remove​(T element)
        remove the passed element. Find the LeafVertex that contains the element, remove the element from the LeafVertex map
        Specified by:
        remove in interface Node<T>
        Parameters:
        element - the element to remove
        Returns:
        the parent node or this node
      • getVisibleElements

        public Set<T> getVisibleElements​(Set<T> visibleElements,
                                         Shape shape)
        Specified by:
        getVisibleElements in interface Node<T>
        Parameters:
        shape - the shape to filter the visible elements
        Returns:
        a collection of all elements that intersect with the passed shape
      • count

        public int count()
        descend into the tree and count all children
        Specified by:
        count in interface Node<T>
        Returns: