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

29
LINES

< > BotCompany Repo | #1025619 // screenTextOverlay_withOutline_multiLine_centered backup with old execution order

JavaX fragment (include)

static JWindow screenTextOverlay_withOutline_multiLine_centered(fS text, O... _) {
  ret swing(func -> JWindow {
    new JWindow w;
    w.setAlwaysOnTop(true);
    w.setVisible(true);
    
    optPar Color outlineColor = Color.black;
    
    Font font = cast optPar font(_);
    if (font == null)
      font = w.getFont().deriveFont(boolPar bold(_, true) ? Font.BOLD : Font.PLAIN, optPar fontSize(_, 80));
    Pair<Shape, Rect> shapeAndSize = textLayoutToOutlineAndSize_multiLine_centered(text, font, w);

    float outlineWidth = optPar outlineWidth(_, 4.0f);
    JComponent c = dynamicallyPaintedComponent(voidfunc(Graphics2D g, int w, int h) {
      fillRect(g, 0, 0, w, h, optPar color(_, Color.WHITE));
      g.setColor(outlineColor);
      g.setStroke(new BasicStroke(outlineWidth);
      antiAliasOn(g);
      g.draw(shapeAndSize.a);
    });
    w.add(c);

    centerWindow(w, iceil(shapeAndSize.b.w+optPar magicXMargin(_, 10)), 
      iceil(shapeAndSize.b.h+optPar magicYMargin(_, 10)));
    w.setShape(shapeAndSize.a);
    ret w;
  });
}

Author comment

Began life as a copy of #1023073

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1025619
Snippet name: screenTextOverlay_withOutline_multiLine_centered backup with old execution order
Eternal ID of this version: #1025619/1
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:13:23
Source code size: 1075 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 178 / 203
Referenced in: [show references]