Package de.freaklamarsch.systarest
Class RTree
java.lang.Object
de.freaklamarsch.systarest.RTree
public class RTree
extends java.lang.Object
A spatial data structure for efficiently storing and querying geometric
objects. This implementation uses an R-Tree to organize objects such as
rectangles, circles, and text elements.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description RTree()Constructs an empty R-Tree with a root node that spans the entire coordinate space. -
Method Summary
Modifier and Type Method Description booleanadd(RTreeNode newNode)Adds a new node to the R-Tree.private booleanadd(RTreeNode node, RTreeNode newNode)private intcountDigits(int n)private voiddrawElement(java.awt.Graphics2D g, java.lang.Object o, java.awt.Color fgColor, java.awt.Color bgColor)java.lang.ObjectfindContainingObject(int x, int y)TODO what is this search for?private java.lang.ObjectfindContainingObject(RTreeNode node, int x, int y)TODO what is this search for?java.lang.ObjectfindContainingObjectWithType(int x, int y, java.lang.Class<?> type)TODO what is this search for?private java.lang.ObjectfindContainingObjectWithType(RTreeNode node, int x, int y, java.lang.Class<?> type)RTreeNodefindNodeAtPos(int x, int y)Searches for a node at the specified geometric position.private RTreeNodefindNodeAtPos(RTreeNode node, int x, int y)private java.lang.StringgetElementAsExcalidrawJSON(java.lang.Object o)java.lang.StringgetExcalidrawJSON()java.awt.image.BufferedImagegetImage()RTreeNodegetRoot()voidremove(RTreeNode node)Removes a node from the R-Tree.voidsetRoot(RTreeNode root)java.lang.StringtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
root
The root node of the R-Tree. -
elements
A set of all nodes currently stored in the tree. This obkjct is used for direct access to the stored elements, without traversing the R-Tree
-
-
Constructor Details
-
RTree
public RTree()Constructs an empty R-Tree with a root node that spans the entire coordinate space.
-
-
Method Details
-
getRoot
- Returns:
- the root
-
setRoot
- Parameters:
root- the root to set
-
add
Adds a new node to the R-Tree.- Parameters:
newNode- the node to add- Returns:
trueif the node was added successfully;falseif the node already exists
-
remove
Removes a node from the R-Tree.- Parameters:
node- the node to remove
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
findContainingObject
public java.lang.Object findContainingObject(int x, int y)TODO what is this search for?- Parameters:
x-y-- Returns:
-
findNodeAtPos
Searches for a node at the specified geometric position.- Parameters:
x- the x-coordinate of the positiony- the y-coordinate of the position- Returns:
- the node at the specified position, or
nullif no node exists at that position
-
findNodeAtPos
-
findContainingObjectWithType
public java.lang.Object findContainingObjectWithType(int x, int y, java.lang.Class<?> type)TODO what is this search for?- Parameters:
x-y-- Returns:
-
add
-
findContainingObject
TODO what is this search for?- Parameters:
node-x-y-- Returns:
-
findContainingObjectWithType
private java.lang.Object findContainingObjectWithType(RTreeNode node, int x, int y, java.lang.Class<?> type) -
getExcalidrawJSON
public java.lang.String getExcalidrawJSON() -
getElementAsExcalidrawJSON
private java.lang.String getElementAsExcalidrawJSON(java.lang.Object o) -
countDigits
private int countDigits(int n) -
getImage
public java.awt.image.BufferedImage getImage() -
drawElement
private void drawElement(java.awt.Graphics2D g, java.lang.Object o, java.awt.Color fgColor, java.awt.Color bgColor)
-