コード例 #1
0
  private void drawNode(Node2d node) {
    if (node == null) return;

    StdDraw.setPenColor(StdDraw.BLACK);
    StdDraw.setPenRadius(.005);
    node.p.draw();

    StdDraw.setPenRadius(.003);

    if (node.depth % 2 == 0) {
      StdDraw.setPenColor(StdDraw.RED);
      node.p.drawTo(new Point2D(node.p.x(), node.rect.ymax()));
      node.p.drawTo(new Point2D(node.p.x(), node.rect.ymin()));

      drawNode(node.left);
      drawNode(node.right);
    } else {
      StdDraw.setPenColor(StdDraw.BLUE);
      node.p.drawTo(new Point2D(node.rect.xmax(), node.p.y()));
      node.p.drawTo(new Point2D(node.rect.xmin(), node.p.y()));

      drawNode(node.left);
      drawNode(node.right);
    }
  }
コード例 #2
0
 public void draw() { // draw all of the points to standard draw
   drawNode(root);
 }