public int findNearestTBondIndex(int x, int y) {
		TBonds tbonds = ((ExtendedFrameRenderer) repaintManager.frameRenderer).tbonds;
		if (tbonds == null || tbonds.isEmpty())
			return -1;
		initHighlightTBond();
		tbonds.removeTBond(highlightTBond);
		int zmin = Integer.MAX_VALUE;
		TBond tbond = null;
		TBond tbondFound = null;
		int zDepth;
		int foundIndex = -1;
		Atom[] atom = modelManager.frame.atoms;
		if (polygon == null)
			polygon = new Polygon();
		Atom a1, a2, a3, a4;
		synchronized (tbonds.getLock()) {
			for (Iterator it = tbonds.iterator(); it.hasNext();) {
				tbond = (TBond) it.next();
				if (tbond == highlightTBond)
					continue;
				a1 = atom[tbond.atom1];
				a2 = atom[tbond.atom2];
				a3 = atom[tbond.atom3];
				a4 = atom[tbond.atom4];
				polygon.reset();
				polygon.addPoint(a1.screenX, a1.screenY);
				polygon.addPoint(a2.screenX, a2.screenY);
				polygon.addPoint(a3.screenX, a3.screenY);
				polygon.addPoint(a4.screenX, a4.screenY);
				if (polygon.contains(x, y)) {
					zDepth = a1.screenZ + a2.screenZ + a3.screenZ + a4.screenZ;
					if (zDepth < zmin) {
						zmin = zDepth;
						foundIndex = tbonds.indexOf(tbond);
						tbondFound = tbond;
					}
				}
			}
		}
		if (foundIndex >= 0 && tbondFound != null) {
			highlightTBond.atom1 = tbondFound.atom1;
			highlightTBond.atom2 = tbondFound.atom2;
			highlightTBond.atom3 = tbondFound.atom3;
			highlightTBond.atom4 = tbondFound.atom4;
			tbonds.addTBond(highlightTBond);
		}
		return foundIndex;
	}