public int findNearestABondIndex(int x, int y) {
		ABonds abonds = ((ExtendedFrameRenderer) repaintManager.frameRenderer).abonds;
		if (abonds == null)
			return -1;
		int n = 0;
		synchronized (abonds.getLock()) {
			n = abonds.count();
		}
		if (n <= 0)
			return -1;
		initHighlightTriangle();
		Triangles triangles = ((ExtendedFrameRenderer) repaintManager.frameRenderer).triangles;
		triangles.removeTriangle(highlightTriangle);
		int zmin = Integer.MAX_VALUE;
		ABond abond;
		int zDepth;
		int foundIndex = -1;
		Atom[] atom = modelManager.frame.atoms;
		if (polygon == null)
			polygon = new Polygon();
		Atom a1, a2, a3;
		synchronized (abonds.getLock()) {
			for (int i = 0; i < n; i++) {
				abond = abonds.getABond(i);
				a1 = atom[abond.atom1];
				a2 = atom[abond.atom2];
				a3 = atom[abond.atom3];
				polygon.reset();
				polygon.addPoint(a1.screenX, a1.screenY);
				polygon.addPoint(a2.screenX, a2.screenY);
				polygon.addPoint(a3.screenX, a3.screenY);
				if (polygon.contains(x, y)) {
					zDepth = a1.screenZ + a2.screenZ + a3.screenZ;
					if (zDepth < zmin) {
						zmin = zDepth;
						foundIndex = i;
					}
				}
			}
		}
		if (foundIndex >= 0) {
			triangles.addTriangle(highlightTriangle);
			abond = abonds.getABond(foundIndex);
			highlightTriangle.setVertices(atom[abond.atom1], atom[abond.atom2], atom[abond.atom3]);
		}
		return foundIndex;
	}