-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added abstract classes for quad tree
- Loading branch information
Showing
17 changed files
with
565 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package at.jotschi.quadtree; | ||
|
||
import java.awt.Dimension; | ||
import java.awt.Point; | ||
|
||
public abstract class AbstractNode { | ||
|
||
/** | ||
* Default value for amount of elements | ||
*/ | ||
protected final int MAX_ELEMENTS = 4; | ||
|
||
/** | ||
* Default value for max depth | ||
*/ | ||
protected final int MAX_DEPTH = 4; | ||
|
||
public static enum Cell { | ||
TOP_LEFT, BOTTOM_RIGHT, BOTTOM_LEFT, TOP_RIGHT | ||
} | ||
|
||
protected Dimension bounds; | ||
protected Point startCoordinates; | ||
protected int maxDepth; | ||
protected int maxElements; | ||
protected int depth; | ||
|
||
public AbstractNode(Point startCoordinates, Dimension bounds, int depth) { | ||
this.startCoordinates = startCoordinates; | ||
this.bounds = bounds; | ||
this.depth = depth; | ||
this.maxDepth = MAX_DEPTH; | ||
this.maxElements = MAX_ELEMENTS; | ||
} | ||
|
||
public AbstractNode(Point startCoordinates, Dimension bounds, int depth, | ||
int maxDepth, int maxChildren) { | ||
this.startCoordinates = startCoordinates; | ||
this.bounds = bounds; | ||
this.maxDepth = maxDepth; | ||
this.maxElements = maxChildren; | ||
this.depth = depth; | ||
} | ||
|
||
/** | ||
* Returns the bounds for this Node | ||
* | ||
* @return | ||
*/ | ||
public Dimension getBounds() { | ||
return this.bounds; | ||
} | ||
|
||
/** | ||
* Returns the startCoordinates for this Node | ||
* | ||
* @return | ||
*/ | ||
public Point getStartCoordinates() { | ||
return this.startCoordinates; | ||
} | ||
|
||
/** | ||
* Returns the max elements | ||
* | ||
* @return | ||
*/ | ||
public int getMaxElements() { | ||
return this.maxElements; | ||
} | ||
|
||
/** | ||
* Returns the max depth | ||
* | ||
* @return | ||
*/ | ||
public int getMaxDepth() { | ||
return this.maxDepth; | ||
} | ||
|
||
public abstract void subdivide(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package at.jotschi.quadtree; | ||
|
||
import java.awt.Dimension; | ||
import java.awt.Point; | ||
|
||
import at.jotschi.quadtree.impl.PointNode; | ||
|
||
public abstract class AbstractQuadTree<T> { | ||
|
||
protected Dimension size; | ||
protected Point startCoordinates; | ||
|
||
public AbstractQuadTree(Point startCoordinates, Dimension size) { | ||
this.size = size; | ||
this.startCoordinates = startCoordinates; | ||
} | ||
|
||
/** | ||
* Returns the size | ||
* | ||
* @return | ||
*/ | ||
public Dimension getSize() { | ||
return this.size; | ||
} | ||
|
||
/** | ||
* Returns the startCoordinates | ||
* | ||
* @return | ||
*/ | ||
public Point getStartCoordinates() { | ||
return this.startCoordinates; | ||
} | ||
|
||
/** | ||
* Clear the QuadTree | ||
*/ | ||
public abstract void clear(); | ||
|
||
|
||
/** | ||
* Return the root node of this quad tree | ||
* @return | ||
*/ | ||
public abstract PointNode<T> getRootNode(); | ||
|
||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.