spatial
Class MemoryRTreeNode

java.lang.Object
  |
  +--spatial.MemoryRTreeNode
All Implemented Interfaces:
SpatialSearchTreeEntry, SpatialSearchTreeNode

public class MemoryRTreeNode
extends java.lang.Object
implements SpatialSearchTreeNode

A memory-based R-tree node.


Nested Class Summary
protected  class MemoryRTreeNode.MemoryRTreeEntry
          Class representing an entry - required for calling strategy.distribute
 
Field Summary
protected  SpatialSearchTreeEntry[] entry
          the entries.
protected  boolean isLeaf
          leaf flag.
protected  boolean isRoot
          root flag.
protected static int MAXENTRYNUM
          maximum number of entries per node.
protected  MBR mbr
          minimum bounding box.
protected  int num
          number of entries.
protected  MemoryRTree tree
          the tree of the node.
 
Constructor Summary
protected MemoryRTreeNode(boolean isLeaf, MemoryRTree tree)
          Internal constructor for new nodes which are not the root.
protected MemoryRTreeNode(MemoryRTree tree)
          Creates a new root which is also a leaf.
protected MemoryRTreeNode(MemoryRTreeNode subtree1, MemoryRTreeNode subtree2)
          Internal constructor for a new root.
 
Method Summary
protected  void adaptMBR()
          Re-computes the mbr.
 int computeNumberOfEntries()
          Returns the number of entries of the tree.
 int computeNumberOfNodes()
          Returns the number of nodes of the tree.
protected  void debugPrint(int height, boolean traverse)
          Debug print of the tree.
protected  void draw(int actHeight, java.awt.Graphics g, int scale, int minHeight, int maxHeight)
          Draws the subtree.
 SpatialSearchTreeNode getChildNode(int index)
          Returns the child node of a non-leaf entry.
 SpatialSearchTreeEntry getEntry(int index)
          Returns an entry in a node.
 MBR getEntryMBR(int index)
          Returns the minimum bounding box of an entry in a node.
 int getHeight()
          Returns the height of the tree.
 int getMaxNumberOfEntries()
          Returns the maximum number of entries.
 MBR getMBR()
          Returns the minimum bounding box.
 int getNumberOfEntries()
          Returns the number of entries in the node.
 int getNumOfDimensions()
          Returns the number of spatial dimensions.
 SpatialSearchTreeObject getObject(int index)
          Returns the object of a leaf node.
 SpatialSearchTree getTree()
          Returns the tree the node belongs to.
 MemoryRTreeNode insert(SpatialSearchTreeObject obj)
          Inserts the object into the r-tree.
protected  void insertSimple(SpatialSearchTreeEntry obj)
          Inserts the object into the node without handling of any special cases.
 boolean isLeaf()
          Returns whether the node is a leaf or not.
 boolean isRoot()
          Returns whether the node is a root node or not.
 boolean move(int index, MBR newMBR)
          Moves an object.
 boolean pointsToLeaf()
          Returns whether the node points to a leaf or not.
 void removeObject(int index)
          Removes the object with a given index.
 void resetLock()
          Pseudo operation.
 void setEntry(SpatialSearchTreeEntry entry, int i)
          Sets the i-th entry of the node
 void setLock()
          Pseudo operation.
static void setMaximumCapacity(int capacity)
          Sets the maximum capacity of the nodes.
protected  MemoryRTreeNode split()
          Splits this node.
 void updateObject(int index)
          Simulates an update of the object with a given index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXENTRYNUM

protected static int MAXENTRYNUM
maximum number of entries per node.


tree

protected MemoryRTree tree
the tree of the node.


mbr

protected MBR mbr
minimum bounding box.


entry

protected SpatialSearchTreeEntry[] entry
the entries.


num

protected int num
number of entries.


isLeaf

protected boolean isLeaf
leaf flag.


isRoot

protected boolean isRoot
root flag.

Constructor Detail

MemoryRTreeNode

protected MemoryRTreeNode(MemoryRTree tree)
Creates a new root which is also a leaf.

Parameters:
tree - the memory r-tree

MemoryRTreeNode

protected MemoryRTreeNode(MemoryRTreeNode subtree1,
                          MemoryRTreeNode subtree2)
Internal constructor for a new root. The mbr is computed.

Parameters:
subtree1 - first subtree
subtree2 - second subtree

MemoryRTreeNode

protected MemoryRTreeNode(boolean isLeaf,
                          MemoryRTree tree)
Internal constructor for new nodes which are not the root. The mbr is unset.

Parameters:
tree - the memory r-tree
Method Detail

adaptMBR

protected void adaptMBR()
Re-computes the mbr.


computeNumberOfEntries

public int computeNumberOfEntries()
Returns the number of entries of the tree.

Returns:
number of entries

computeNumberOfNodes

public int computeNumberOfNodes()
Returns the number of nodes of the tree.

Returns:
number of nodes

debugPrint

protected void debugPrint(int height,
                          boolean traverse)
Debug print of the tree.

Parameters:
height - height of the node
traverse - traverse tree?
Returns:
number of nodes

draw

protected void draw(int actHeight,
                    java.awt.Graphics g,
                    int scale,
                    int minHeight,
                    int maxHeight)
Draws the subtree.

Parameters:
actHeight - actual height
g - graphic context
scale - scale
minHeight - minimum height
maxHeight - maximum height

getChildNode

public SpatialSearchTreeNode getChildNode(int index)
Returns the child node of a non-leaf entry.

Specified by:
getChildNode in interface SpatialSearchTreeNode
Parameters:
index - index of entry
Returns:
the child node

getEntry

public SpatialSearchTreeEntry getEntry(int index)
Returns an entry in a node.

Specified by:
getEntry in interface SpatialSearchTreeNode
Parameters:
index - index of the entry
Returns:
the entry

getEntryMBR

public MBR getEntryMBR(int index)
Returns the minimum bounding box of an entry in a node.

Specified by:
getEntryMBR in interface SpatialSearchTreeNode
Parameters:
index - index of entry
Returns:
rectangle

getHeight

public int getHeight()
Returns the height of the tree.

Specified by:
getHeight in interface SpatialSearchTreeNode
Returns:
height

getMaxNumberOfEntries

public int getMaxNumberOfEntries()
Returns the maximum number of entries.

Specified by:
getMaxNumberOfEntries in interface SpatialSearchTreeNode
Returns:
maximum number

getMBR

public MBR getMBR()
Returns the minimum bounding box.

Specified by:
getMBR in interface SpatialSearchTreeEntry
Returns:
minimum bounding box

getNumOfDimensions

public int getNumOfDimensions()
Returns the number of spatial dimensions.

Specified by:
getNumOfDimensions in interface SpatialSearchTreeEntry
Returns:
the dimensions

getNumberOfEntries

public int getNumberOfEntries()
Returns the number of entries in the node.

Specified by:
getNumberOfEntries in interface SpatialSearchTreeNode
Returns:
number of entries

getObject

public SpatialSearchTreeObject getObject(int index)
Returns the object of a leaf node.

Specified by:
getObject in interface SpatialSearchTreeNode
Parameters:
index - index of object
Returns:
object

getTree

public SpatialSearchTree getTree()
Returns the tree the node belongs to.

Specified by:
getTree in interface SpatialSearchTreeNode
Returns:
the tree

insert

public MemoryRTreeNode insert(SpatialSearchTreeObject obj)
Inserts the object into the r-tree.

Parameters:
obj - spatial searchtree object
Returns:
new r-tree node

insertSimple

protected void insertSimple(SpatialSearchTreeEntry obj)
Inserts the object into the node without handling of any special cases.

Parameters:
obj - new spatial searchtree object

isLeaf

public boolean isLeaf()
Returns whether the node is a leaf or not.

Specified by:
isLeaf in interface SpatialSearchTreeNode
Returns:
is leaf?

isRoot

public boolean isRoot()
Returns whether the node is a root node or not.

Specified by:
isRoot in interface SpatialSearchTreeNode
Returns:
true if it is a node

move

public boolean move(int index,
                    MBR newMBR)
Moves an object.

Parameters:
index - the index of the object

pointsToLeaf

public boolean pointsToLeaf()
Returns whether the node points to a leaf or not.

Returns:
points to a leaf?

removeObject

public void removeObject(int index)
Removes the object with a given index.

Specified by:
removeObject in interface SpatialSearchTreeNode
Parameters:
index - index of the object

resetLock

public void resetLock()
Pseudo operation.

Specified by:
resetLock in interface SpatialSearchTreeNode

setEntry

public void setEntry(SpatialSearchTreeEntry entry,
                     int i)
Sets the i-th entry of the node

Specified by:
setEntry in interface SpatialSearchTreeNode
Parameters:
entry - the new entry
i - the index

setLock

public void setLock()
Pseudo operation.

Specified by:
setLock in interface SpatialSearchTreeNode

setMaximumCapacity

public static void setMaximumCapacity(int capacity)
Sets the maximum capacity of the nodes. Must be called before a node is created.

Parameters:
capacity - the new capaciy

split

protected MemoryRTreeNode split()
Splits this node.

Returns:
the new node

updateObject

public void updateObject(int index)
Simulates an update of the object with a given index.

Specified by:
updateObject in interface SpatialSearchTreeNode
Parameters:
index - index of the object