code: public int getBeatForX(int x) {
          BeatGrid grid = beatGrid.get();
          if (grid != null) {
              return grid.findBeatAtTime(getTimeForX(x));
          }
          return -1;
      }
docs: Determine the beat that corresponds to a particular X coordinate in the component, given the current scale.
  Clicks past the end of the track will return the final beat, clicks before the first beat (or if there is no
  beat grid) will return -1.
  
  @param x the horizontal position within the component coordinate space
  @return the beat number being played at that point, or -1 if the point is before the first beat