private int getRowHit(float y) {

        final float squareHeight = this.squareHeight;
        float hitSize = squareHeight * hitFactor;

        float offset = paddingTop + (squareHeight - hitSize) / 2f;
        for (int i = 0; i < gridRows; i++) {

            final float hitTop = offset + squareHeight * i;
            if (y >= hitTop && y <= hitTop + hitSize) {
                return i;
            }
        }
        return -1;
    }
Helper method to find the row that y falls into.

@param y The y coordinate
@return The row that y falls in, or -1 if it falls in no row.
android-patternview/src/main/java/com/eftimoff/patternview/PatternView.java