Class LeafNode<T>
- java.lang.Object
-
- org.jungrapht.visualization.spatial.rtree.RTreeNode<T>
-
- org.jungrapht.visualization.spatial.rtree.LeafNode<T>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Node<T>add(SplitterContext<T> splitterContext, Map.Entry<T,Rectangle2D> entry)add the passed Entry to the mapNode<T>add(SplitterContext<T> splitterContext, Map.Entry<T,Rectangle2D>... entries)Node<T>add(SplitterContext<T> splitterContext, T element, Rectangle2D bounds)StringasString(String margin)Point2DcenterOfGravity()Collection<Shape>collectGrids(Collection<Shape> list)gather the bounds of the node children of this nodebooleancontains(Object key)intcount()static <T> LeafNode<T>create(Collection<Map.Entry<T,Rectangle2D>> entries)static <T> LeafNode<T>create(Map.Entry<T,Rectangle2D> entry)static <T> LeafNode<T>create(T element, Rectangle2D bounds)Rectangle2DgetBounds()the bounding box of this node is held in the children mapRectangle2DgetBoundsFor(T element)Collection<? extends TreeNode>getChildren()LeafNode<T>getContainingLeaf(T element)Set<LeafNode<T>>getContainingLeafs(Set<LeafNode<T>> containingLeafs, double x, double y)Set<LeafNode<T>>getContainingLeafs(Set<LeafNode<T>> containingLeafs, Point2D p)TgetPickedObject(Point2D p)Set<T>getVisibleElements(Set<T> visibleElements, Shape shape)booleanisLeafChildren()always false.Node<T>recalculateBounds()called after a removal.Node<T>remove(T element)remove passed element from the map if it exists call recalculateBounds to update all parent node bounds after removal of the elementintsize()the number of children of this nodeStringtoString()-
Methods inherited from class org.jungrapht.visualization.spatial.rtree.RTreeNode
getParent, setParent
-
-
-
-
Field Detail
-
EMPTY
public static LeafNode EMPTY
a LeafVertex with no children
-
-
Method Detail
-
create
public static <T> LeafNode<T> create(Map.Entry<T,Rectangle2D> entry)
- Type Parameters:
T- the type of the element- Parameters:
entry- the child for the newly created LeafVertex- Returns:
- a newly created LeafVertex that contains the passed entry as its only element
-
create
public static <T> LeafNode<T> create(T element, Rectangle2D bounds)
- Type Parameters:
T- the type of the element- Parameters:
element- the element child for the newly created LeafVertexbounds- the bounds for the child of the newly created LeafVertex- Returns:
- the newly created LeafVertex with one child element
-
create
public static <T> LeafNode<T> create(Collection<Map.Entry<T,Rectangle2D>> entries)
- Type Parameters:
T- the type of the elements for this LeafVertex- Parameters:
entries- the elements for the newly created LeafVertex- Returns:
- the newly created LeadVertex with the entries as children
-
centerOfGravity
public Point2D centerOfGravity()
- Specified by:
centerOfGravityin interfaceNode<T>
-
add
public Node<T> add(SplitterContext<T> splitterContext, Map.Entry<T,Rectangle2D>... entries)
- Parameters:
splitterContext- how to split on overflow (R-Tree or R*-Tree)entries- add to this LeafVertex- Returns:
- the last node added to
-
add
public Node<T> add(SplitterContext<T> splitterContext, T element, Rectangle2D bounds)
-
isLeafChildren
public boolean isLeafChildren()
always false. children are elements, not LeafVertices- Specified by:
isLeafChildrenin interfaceNode<T>- Returns:
-
remove
public Node<T> remove(T element)
remove passed element from the map if it exists call recalculateBounds to update all parent node bounds after removal of the element
-
recalculateBounds
public Node<T> recalculateBounds()
called after a removal. climb the tree to the root recalculating the bounds- Specified by:
recalculateBoundsin interfaceNode<T>- Returns:
- this LeafVertex
-
getBoundsFor
public Rectangle2D getBoundsFor(T element)
-
add
public Node<T> add(SplitterContext<T> splitterContext, Map.Entry<T,Rectangle2D> entry)
add the passed Entry to the map- Parameters:
splitterContext- how to split on overflowentry- the entry to add to the map- Returns:
- the parent or this
-
contains
public boolean contains(Object key)
- Parameters:
key- the element key to search for- Returns:
- true if the key exists in the map. false otherwise
-
size
public int size()
the number of children of this node
-
getContainingLeaf
public LeafNode<T> getContainingLeaf(T element)
- Specified by:
getContainingLeafin interfaceNode<T>- Parameters:
element- the element to find- Returns:
- the LeafVertex that contains the passed element
-
getContainingLeafs
public Set<LeafNode<T>> getContainingLeafs(Set<LeafNode<T>> containingLeafs, Point2D p)
- Specified by:
getContainingLeafsin interfaceNode<T>- Parameters:
p- the point to search for- Returns:
- a Collection of LeafVertices that would contain the point
-
getContainingLeafs
public Set<LeafNode<T>> getContainingLeafs(Set<LeafNode<T>> containingLeafs, double x, double y)
- Specified by:
getContainingLeafsin interfaceNode<T>- Parameters:
x- coordinate of the point to search fory- coordinate of the point to search for- Returns:
- a Collection of LeafVertices that would contain the passed coordinates
-
collectGrids
public Collection<Shape> collectGrids(Collection<Shape> list)
gather the bounds of the node children of this node- Specified by:
collectGridsin interfaceNode<T>- Parameters:
list- a list to populate with child bounds rectangles- Returns:
- the list of child bounds rectangles
-
getBounds
public Rectangle2D getBounds()
the bounding box of this node is held in the children map
-
getPickedObject
public T getPickedObject(Point2D p)
- Specified by:
getPickedObjectin interfaceNode<T>- Parameters:
p- a point to search for- Returns:
- the map entry key whose bounds value contains the passed point
-
getVisibleElements
public Set<T> getVisibleElements(Set<T> visibleElements, Shape shape)
- Specified by:
getVisibleElementsin interfaceNode<T>- Parameters:
shape- a shape to filter the visible elements- Returns:
- a subset of elements whose bounds intersect with the passed shape
-
count
public int count()
-
getChildren
public Collection<? extends TreeNode> getChildren()
- Specified by:
getChildrenin interfaceTreeNode
-
-