private int calcCappedYSize(int max) { int h = slot.h * getTotalRows(); h = border.getHeightWithBorder(h); if (shouldDrawName()) { h += textBackground.h; } // not higher than the max while (h > max) { h -= slot.h; } return h; }