diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2013-03-26 07:54:25 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2013-11-15 17:38:44 +0100 |
commit | 2d3ca27255ce0433cb2af74f5e10b60fc0651d91 (patch) | |
tree | 3ac768ad5d45322200653cef369eb80408c9c10a /Algorithms/Part-I/5-KdTrees/KdTreeVisualizer.java | |
parent | c492158417199a42314eb34fe6198e33e5b46db4 (diff) | |
download | coursera-2d3ca27255ce0433cb2af74f5e10b60fc0651d91.zip coursera-2d3ca27255ce0433cb2af74f5e10b60fc0651d91.tar.gz |
Algorithms-I : 5-KdTrees: added, to be completed
Diffstat (limited to 'Algorithms/Part-I/5-KdTrees/KdTreeVisualizer.java')
-rw-r--r-- | Algorithms/Part-I/5-KdTrees/KdTreeVisualizer.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Algorithms/Part-I/5-KdTrees/KdTreeVisualizer.java b/Algorithms/Part-I/5-KdTrees/KdTreeVisualizer.java new file mode 100644 index 0000000..638a469 --- /dev/null +++ b/Algorithms/Part-I/5-KdTrees/KdTreeVisualizer.java @@ -0,0 +1,30 @@ +/************************************************************************* + * Compilation: javac KdTreeVisualizer.java + * Execution: java KdTreeVisualizer + * Dependencies: StdDraw.java Point2D.java KdTree.java + * + * Add the points that the user clicks in the standard draw window + * to a kd-tree and draw the resulting kd-tree. + * + *************************************************************************/ + +public class KdTreeVisualizer { + + public static void main(String[] args) { + StdDraw.show(0); + KdTree kdtree = new KdTree(); + while (true) { + if (StdDraw.mousePressed()) { + double x = StdDraw.mouseX(); + double y = StdDraw.mouseY(); + System.out.printf("%8.6f %8.6f\n", x, y); + Point2D p = new Point2D(x, y); + kdtree.insert(p); + StdDraw.clear(); + kdtree.draw(); + } + StdDraw.show(50); + } + + } +} |