Skip to content

Commit 6a8b7d7

Browse files
committed
Added description for point quad tree example
1 parent 697f9ec commit 6a8b7d7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/main/java/at/jotschi/quadtree/point/PointNode.java

+1
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,6 @@ public void clear() {
211211
node.clear();
212212
}
213213
elements.clear();
214+
nodes.clear();
214215
}
215216
}

src/test/java/at/jotschi/quadtree/RenderPointQuadTree.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ protected PointQuadTree<String> createQuadTree() {
5151

5252
@Override
5353
protected void paintComponent(Graphics g) {
54+
g.drawString(
55+
"Left click to add new points. Right click to highlight all elements of a selected cell/node.",
56+
100, 80);
5457
PointNode<String> rootNode = tree.getRootNode();
5558
drawCells(rootNode, g);
5659
}
@@ -104,7 +107,18 @@ public void drawElements(PointNode node, Graphics g) {
104107
}
105108
}
106109

107-
110+
public void keyReleased(KeyEvent e) {
111+
112+
if (e.getKeyCode() == 27) {
113+
System.exit(10);
114+
} else if (e.getKeyCode() == 67) {
115+
log.debug("Invoking clearing of tree.");
116+
tree.clear();
117+
repaint();
118+
}
119+
120+
}
121+
108122
public void mouseClicked(MouseEvent e) {
109123

110124
Point p = e.getPoint();

0 commit comments

Comments
 (0)