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