Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1023073 // screenTextOverlay_withOutline_multiLine_centered

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (2708L) is out of date.

1  
static JWindow screenTextOverlay_withOutline_multiLine_centered(fS text, O... _) {
2  
  ret swing(func -> JWindow {
3  
    new JWindow w;
4  
    w.setAlwaysOnTop(true);
5  
    w.setVisible(true);
6  
    
7  
    optPar Color outlineColor = Color.black;
8  
    
9  
    Font font = cast optPar font(_);
10  
    if (font == null)
11  
      font = w.getFont().deriveFont(boolPar bold(_, true) ? Font.BOLD : Font.PLAIN, optPar fontSize(_, 80));
12  
    Pair<Shape, Rect> shapeAndSize = textLayoutToOutlineAndSize_multiLine_centered(text, font, w);
13  
14  
    float outlineWidth = optPar outlineWidth(_, 4.0f);
15  
    JComponent c = dynamicallyPaintedComponent(voidfunc(Graphics2D g, int w, int h) {
16  
      fillRect(g, 0, 0, w, h, optPar color(_, Color.WHITE));
17  
      g.setColor(outlineColor);
18  
      g.setStroke(new BasicStroke(outlineWidth);
19  
      antiAliasOn(g);
20  
      g.draw(shapeAndSize.a);
21  
    });
22  
    w.add(c);
23  
24  
    centerWindow(w, iceil(shapeAndSize.b.w+optPar magicXMargin(_, 10)), 
25  
      iceil(shapeAndSize.b.h+optPar magicYMargin(_, 10)));
26  
    w.setShape(shapeAndSize.a);
27  
    ret w;
28  
  });
29  
}

Author comment

Began life as a copy of #1023070

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023073
Snippet name: screenTextOverlay_withOutline_multiLine_centered
Eternal ID of this version: #1023073/5
Text MD5: 6241273b78fc8320bd6bfea5cae09c62
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-09 13:16:48
Source code size: 1075 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 196 / 279
Version history: 4 change(s)
Referenced in: [show references]