AccordionDrawer
Class QuadTree

java.lang.Object
  |
  +--AccordionDrawer.QuadTree

public class QuadTree
extends java.lang.Object

A class which implements a quadtree This class is a tree of GridCells; each GridCell has up to 4 children.


Field Summary
 int[][] gridSize
           
 QuadGridCell rootCell
           
 int totalDepth
           
 
Constructor Summary
QuadTree(AccordionDrawer theowner)
          Constructor.
 
Method Summary
 GridCell getChildAt(QuadGridCell cell, int ddepth, int x, int y)
          Gets a child at a specified x, y, depth location.
 GridCell getGridCell(int level, int row, int col)
          Returns the GridCell at the specified row, column and level.
 void init(int depth)
          Initializes a few variables.
 GridCell makeChildAt(QuadGridCell cell, int ddepth, int x, int y)
          Like getChildAt, but makes new cells whenever necessary.
 GridCell putChildAt(QuadGridCell cell, int ddepth, int x, int y, QuadGridCell insertCell)
          Like makeChildAt, but the instead of creating a new cell at the specified location, puts the specified cell there.
 void setRootCell(QuadGridCell rootCell)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rootCell

public QuadGridCell rootCell

totalDepth

public int totalDepth

gridSize

public int[][] gridSize
Constructor Detail

QuadTree

public QuadTree(AccordionDrawer theowner)
Constructor.

Method Detail

init

public void init(int depth)
Initializes a few variables. Should probably be absorbed into the constructor


setRootCell

public void setRootCell(QuadGridCell rootCell)

getGridCell

public GridCell getGridCell(int level,
                            int row,
                            int col)
Returns the GridCell at the specified row, column and level. Time is linear in the depth of the requested cell.


getChildAt

public GridCell getChildAt(QuadGridCell cell,
                           int ddepth,
                           int x,
                           int y)
Gets a child at a specified x, y, depth location.


makeChildAt

public GridCell makeChildAt(QuadGridCell cell,
                            int ddepth,
                            int x,
                            int y)
Like getChildAt, but makes new cells whenever necessary.


putChildAt

public GridCell putChildAt(QuadGridCell cell,
                           int ddepth,
                           int x,
                           int y,
                           QuadGridCell insertCell)
Like makeChildAt, but the instead of creating a new cell at the specified location, puts the specified cell there.