예제 #1
0
 private void visualize(RNode n, java.io.PrintWriter pw, int x0, int y0, int w, int h) {
   pw.printf(
       "<div style=\"position:absolute; left: %d; top: %d; width: %d; height: %d; border: 1px dashed\">\n",
       x0, y0, w, h);
   pw.println("<pre>");
   pw.println("Node: " + n.toString() + " \n(root==" + (n == root) + ") \n");
   pw.println("Coords start: " + Arrays.toString(n.getMbr().getP_start()) + "\n");
   pw.println("coords end: " + Arrays.toString(n.getMbr().getP_end()) + "\n");
   pw.println("# Children: " + ((n.children() == null) ? 0 : n.children().size()) + "\n");
   if (n instanceof REntry) {
     REntry n1 = (REntry) n;
     pw.println("Content: " + n1.getContent());
   }
   pw.println("isLeaf: " + n.isLeaf() + "\n");
   pw.println("</pre>");
   int numChildren = (n.children() == null) ? 0 : n.children().size();
   for (int i = 0; i < numChildren; i++) {
     visualize(
         n.children().get(i),
         pw,
         (int) (x0 + (i * w / (float) numChildren)),
         y0 + elemHeight,
         (int) (w / (float) numChildren),
         h - elemHeight);
   }
   pw.println("</div>");
 }
예제 #2
0
  public void insert(REntry e) throws DimensionalException {

    if (e.getDimension() != dimension)
      throw new DimensionalException(
          "Can only insert n-dimensional objects in n-dimensional RTree");
    RNode theLeaf = findFittingLeaf(root, e);
    theLeaf.children().add(e);
    e.setParent(theLeaf);
    size++;
    // numOfNodes++;
    if (theLeaf.children().size() > M_order) {
      RNode[] parts = makePartition(theLeaf);
      refresh(parts[0], parts[1]);
    } else {
      refresh(theLeaf, null);
    }
  }