static class ShowBigText { S fontID = "#1000993"; // Brother Deluxe Font Color background = Color.white; Color foreground = Color.black; S text = "test"; ImageSurface is; Font font; S title = "JavaX"; // thread-safe void showText(final S text) { swing { ShowBigText.this.text = text; if (is == null) { font = loadFont(fontID); BufferedImage img = makeImage(); is = showImage_centered(img, title); moveToTopRightCorner(getFrame(is)); } getFrame(is).setTitle(title); is.setImage(makeImage()); } } BufferedImage makeImage() { // TODO: dispose old image? BufferedImage img = new BufferedImage(200, 60, BufferedImage.TYPE_INT_RGB); Graphics g = img.getGraphics(); int w = img.getWidth(), h = img.getHeight(); g.setColor(background); g.fillRect(0, 0, w, h); g.setColor(foreground); g.setFont(font.deriveFont(30f)); FontMetrics fm = g.getFontMetrics(); int y = fm.getAscent() + (h-fm.getHeight())/2; int x = (w-fm.stringWidth(text))/2; g.drawString(text, x, y); g.dispose(); return img; } void setToolTip(S text) { if (is != null) is.setToolTipText(text); } }
Began life as a copy of #1001424
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001425 |
Snippet name: | ShowBigText class |
Eternal ID of this version: | #1001425/5 |
Text MD5: | 511d19266f0918d247b7dac5d9110ae6 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-09-13 16:09:51 |
Source code size: | 1288 bytes / 49 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 726 / 2835 |
Version history: | 4 change(s) |
Referenced in: | [show references] |