MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / paintIcon

Method paintIcon

ij/src/main/java/ij/astro/util/EmojiIcon.java:29–56  ·  view source on GitHub ↗
(Component c, Graphics g, int x, int y)

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 15

getCachedFontMethod · 0.95
getCachedFontSizeMethod · 0.95
getCodepointStringMethod · 0.95
getIconWidthMethod · 0.95
getIconHeightMethod · 0.95
firstMethod · 0.80
setFontMethod · 0.65
setColorMethod · 0.65
getYMethod · 0.65
lengthMethod · 0.65
createMethod · 0.45
getStringBoundsMethod · 0.45

Tested by

no test coverage detected