int findNearestAtomIndex(int x, int y) {
		if (atomCount == 0)
			return -1;
		closest.atom = null;
		findNearestAtomIndex(x, y, closest);
		for (int i = 0; i < shapes.length; ++i) {
			if (closest.atom != null)
				break;
			Shape shape = shapes[i];
			if (shape != null)
				shape.findNearestAtomIndex(x, y, closest);
		}
		int closestIndex = (closest.atom == null ? -1 : closest.atom.atomIndex);
		closest.atom = null;
		return closestIndex;
	}