(Component c, Graphics g, int x, int y)
| 27 | } |
| 28 | |
| 29 | @Override |
| 30 | public void paintIcon(Component c, Graphics g, int x, int y) { |
| 31 | Graphics2D g2d = (Graphics2D) g.create(); |
| 32 | |
| 33 | Font defaultFont = getCachedFont(); |
| 34 | float fontSize = getCachedFontSize(defaultFont); |
| 35 | Font iconFont = defaultFont.deriveFont(Font.PLAIN, fontSize); |
| 36 | g2d.setFont(iconFont); |
| 37 | g2d.setColor(color); |
| 38 | |
| 39 | FontRenderContext frc = g2d.getFontRenderContext(); |
| 40 | |
| 41 | String codePointString = getCodepointString(text, 0).first(); |
| 42 | Rectangle2D textBounds = iconFont.getStringBounds(codePointString, frc); |
| 43 | |
| 44 | int textX = x + (int) ((getIconWidth() - textBounds.getWidth()) / 2); |
| 45 | int textY = y + (int) ((getIconHeight() - textBounds.getHeight()) / 2 - textBounds.getY()); |
| 46 | |
| 47 | for (int i = 0; i < text.length(); i++) { |
| 48 | var b = getCodepointString(text, i); |
| 49 | |
| 50 | g2d.drawString(b.first(), textX, textY); |
| 51 | |
| 52 | i += b.second() - 1; |
| 53 | } |
| 54 | |
| 55 | g2d.dispose(); |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public int getIconWidth() { |
nothing calls this directly
no test coverage detected