code: public static IAtom getClosestAtom(double xPosition, double yPosition, IAtomContainer atomCon, IAtom toignore) {
          IAtom closestAtom = null;
          IAtom currentAtom;
          // we compare squared distances, allowing us to do one sqrt()
          // calculation less
          double smallestSquaredMouseDistance = -1;
          double mouseSquaredDistance;
          double atomX;
          double atomY;
          for (int i = 0; i < atomCon.getAtomCount(); i++) {
              currentAtom = atomCon.getAtom(i);
              if (!currentAtom.equals(toignore)) {
                  atomX = currentAtom.getPoint2d().x;
                  atomY = currentAtom.getPoint2d().y;
                  mouseSquaredDistance = Math.pow(atomX - xPosition, 2) + Math.pow(atomY - yPosition, 2);
                  if (mouseSquaredDistance < smallestSquaredMouseDistance || smallestSquaredMouseDistance == -1) {
                      smallestSquaredMouseDistance = mouseSquaredDistance;
                      closestAtom = currentAtom;
                  }
              }
          }
          return closestAtom;
      }
docs: Returns the atom of the given molecule that is closest to the given
  coordinates and is not the atom.
  See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
  
  @param  xPosition  The x coordinate
  @param  yPosition  The y coordinate
  @param  atomCon    The molecule that is searched for the closest atom
  @param toignore    This molecule will not be returned.
  @return            The atom that is closest to the given coordinates