1 | static Pair<Shape, Rect> textLayoutToOutlineAndSize_multiLine_centered(S text, Font font, Component c, O... _) {
|
2 | int lineSpacing = optPar lineSpacing(_, font.getSize()/4); |
3 | LS lines = lines(text); |
4 | Area area = null; |
5 | int y = 0, w = 0; |
6 | new LPair<Shape, Rect> l; |
7 | for (S line : lines) {
|
8 | Pair<Shape, Rect> p = textLayoutToOutlineAndSize(line, font, c); |
9 | l.add(p); |
10 | w = max(w, p.b.w); |
11 | } |
12 | |
13 | for (Pair<Shape, Rect> p : l) {
|
14 | Area a = new(p.a); |
15 | new AffineTransform tx; |
16 | tx.translate((w-p.b.w)/2, y); |
17 | area = areaUnion(area, a.createTransformedArea(tx)); |
18 | y += p.b.h+lineSpacing; |
19 | } |
20 | |
21 | ret pair(area, rect(0, 0, w, y-lineSpacing)); |
22 | } |
Began life as a copy of #1023069
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: | #1023074 |
| Snippet name: | textLayoutToOutlineAndSize_multiLine_centered |
| Eternal ID of this version: | #1023074/4 |
| Text MD5: | da42a9e3b93ce9e27244fe9a21a4e74b |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2019-04-30 20:54:59 |
| Source code size: | 687 bytes / 22 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 618 / 647 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |