Пример #1
0
 private void recompute() {
   x = u.x;
   y = u.y;
   p = new Polygon();
   p.addPoint(u.x - 1, u.y - 1);
   if (u.D.getLayout() == Layout.SIMPLE) {
     if (u.height == 1) {
       p.addPoint(u.x - 7, u.y + 10);
       p.addPoint(u.x + 7, u.y + 10);
     } else {
       final int x1 = u.x - u.leftw + DataStructure.minsepx / 2,
           x2 = u.x + u.rightw - DataStructure.minsepx / 2,
           y1 = u.y + DataStructure.minsepy,
           y2 = u.y + (u.height - 1) * DataStructure.minsepy;
       p.addPoint(x1, y1);
       p.addPoint(x1, y2);
       p.addPoint(x2, y2);
       p.addPoint(x2, y1);
     }
   } else {
     // TODO: BST needs to expose threads
     BSTNode w = u;
     final Stack<BSTNode> tmp = new Stack<BSTNode>();
     while (u != null && w != null) {
       p.addPoint(u.x - 1, u.y);
       tmp.add(w);
       u = (u.getLeft() != null) ? u.getLeft() : u.getRight(); // TODO
       w = (w.getRight() != null) ? w.getRight() : w.getLeft();
     }
     while (!tmp.isEmpty()) {
       w = tmp.pop();
       p.addPoint(w.x + 1, w.y);
     }
   }
   p.addPoint(u.x + 1, u.y - 1);
 }