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

    Fields
    Modifier and Type Field Description
    private java.util.Set<RTreeNode> elements
    A set of all nodes currently stored in the tree.
    private RTreeNode root
    The root node of the R-Tree.
  • 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
    boolean add​(RTreeNode newNode)
    Adds a new node to the R-Tree.
    private boolean add​(RTreeNode node, RTreeNode newNode)  
    private int countDigits​(int n)  
    private void drawElement​(java.awt.Graphics2D g, java.lang.Object o, java.awt.Color fgColor, java.awt.Color bgColor)  
    java.lang.Object findContainingObject​(int x, int y)
    TODO what is this search for?
    private java.lang.Object findContainingObject​(RTreeNode node, int x, int y)
    TODO what is this search for?
    java.lang.Object findContainingObjectWithType​(int x, int y, java.lang.Class<?> type)
    TODO what is this search for?
    private java.lang.Object findContainingObjectWithType​(RTreeNode node, int x, int y, java.lang.Class<?> type)  
    RTreeNode findNodeAtPos​(int x, int y)
    Searches for a node at the specified geometric position.
    private RTreeNode findNodeAtPos​(RTreeNode node, int x, int y)  
    private java.lang.String getElementAsExcalidrawJSON​(java.lang.Object o)  
    java.lang.String getExcalidrawJSON()  
    java.awt.image.BufferedImage getImage()  
    void remove​(RTreeNode node)
    Removes a node from the R-Tree.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • root

      private RTreeNode root
      The root node of the R-Tree.
    • elements

      private java.util.Set<RTreeNode> 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

    • add

      public boolean add​(RTreeNode newNode)
      Adds a new node to the R-Tree.
      Parameters:
      newNode - the node to add
      Returns:
      true if the node was added successfully; false if the node already exists
    • remove

      public void remove​(RTreeNode node)
      Removes a node from the R-Tree.
      Parameters:
      node - the node to remove
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • findContainingObject

      public java.lang.Object findContainingObject​(int x, int y)
      TODO what is this search for?
      Parameters:
      x -
      y -
      Returns:
    • findNodeAtPos

      public RTreeNode findNodeAtPos​(int x, int y)
      Searches for a node at the specified geometric position.
      Parameters:
      x - the x-coordinate of the position
      y - the y-coordinate of the position
      Returns:
      the node at the specified position, or null if no node exists at that position
    • findNodeAtPos

      private RTreeNode findNodeAtPos​(RTreeNode node, int x, int y)
    • 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

      private boolean add​(RTreeNode node, RTreeNode newNode)
    • findContainingObject

      private java.lang.Object findContainingObject​(RTreeNode node, int x, int y)
      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)