void (Graphics g) { Rectangle bounds = g.getClipBounds(); int from = yVisibleToGrid(bounds.y) * myItemsPerRow, to = yVisibleToGrid(bounds.y + bounds.height) * myItemsPerRow + myItemsPerRow; if (from < 0) from = 0; int itemCount = myCategory.getEmoji().size(); if (to > itemCount) to = itemCount; if (from > to) from = to; FontMetrics metrics = g.getFontMetrics(myStyle.myEmojiFont); int verticalOffset = metrics.getHeight() / 2 - metrics.getDescent(); for (int i = from; i < to; i++) { int x = xGridToVisible(i % myItemsPerRow), y = yGridToVisible(i / myItemsPerRow); @Nls String item = myCategory.getEmoji().get(i).getTonedValue(myCurrentSkinTone); int width = metrics.stringWidth(item); new TextLayout(item, myStyle.myEmojiFont, ((Graphics2D)g).getFontRenderContext()) .draw((Graphics2D)g, x + (myCellSize.width - width) / 2F, y + myCellSize.height / 2F + verticalOffset); } }