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
private static int ACTION_GET
           
private static int ACTION_MAKE
           
private static int ACTION_PUT
           
 int[][] gridSize
           
private  AccordionDrawer owner
           
 QuadGridCell rootCell
           
 int totalDepth
           
 
Constructor Summary
QuadTree(AccordionDrawer theowner)
          Constructor.
 
Method Summary
private  GridCell actionChildAt(QuadGridCell cell, int ddepth, int x, int y, int action, QuadGridCell insertCell)
          Does the actual work for the xChildAt methods.
 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

owner

private AccordionDrawer owner

rootCell

public QuadGridCell rootCell

totalDepth

public int totalDepth

gridSize

public int[][] gridSize

ACTION_GET

private static final int ACTION_GET
See Also:
Constant Field Values

ACTION_MAKE

private static final int ACTION_MAKE
See Also:
Constant Field Values

ACTION_PUT

private static final int ACTION_PUT
See Also:
Constant Field Values
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.


actionChildAt

private GridCell actionChildAt(QuadGridCell cell,
                               int ddepth,
                               int x,
                               int y,
                               int action,
                               QuadGridCell insertCell)
Does the actual work for the xChildAt methods.