private int getRegisterNumber(final int x, final int y) {
    final int lineHeight = font.getSize();

    if ((y >= 7) && (y <= (7 + (lineHeight * registerModel.getNumberOfRegisters())))) {
      int registerNumber = (y - 7) / lineHeight;

      registerNumber = Math.min(registerNumber, registerModel.getNumberOfRegisters() - 1);

      if (registerNumber == -1) {
        return -1;
      }

      final RegisterInformation r = registerModel.getRegisterInformation(registerNumber);
      final int valuePrintSize = r.getRegisterSize() == 0 ? 1 : r.getRegisterSize() * 2;
      final int maxWidth = 10 + 5 + (charWidth * (longestRegisterName + valuePrintSize));

      if ((x >= 10) && (x <= maxWidth)) {
        return registerNumber;
      }
    }

    return -1;
  }
Returns the number of the register at the given coordinates.

@param x The x position.
@param y The y position.
@return The register at the coordinate (x, y) or -1 if there is no such register.
java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/JRegisterView/JRegisterView.java