code: public int calculateHeight(int rows) {
          int rowHeight = 39 - rows;
          int offset = 20 - rows;
          rowHeight = rowHeight < 30 ? 30 : rowHeight;
          offset = offset < 0 ? 0 : offset;
          return offset + (rowHeight * (rows == 0 ? 1 : rows));
      }
docs: Table internals