Libraryless. Click here for Pure Java version (4870L/32K).
1 | !7 |
2 | |
3 | sclass LockMatrix > DynModule { |
4 | transient int n; |
5 | transient BitSet data; |
6 | transient JComponent canvas; |
7 | |
8 | visualize { |
9 | canvas = dynamicallyPaintedComponent(voidfunc(Graphics2D g, int w, int h) { |
10 | int rows = ifloor(sqrt(n)); |
11 | if (rows == 0) fillRect(g, 0, 0, w, h, Color.white); |
12 | int cols = (n+rows-1)/rows; |
13 | L<Rect> tiles = tileRects(w, h, cols, rows); |
14 | _print("n=" + n + ", rows=" + rows + ", first tile=" + first(tiles)); |
15 | for i over tiles: |
16 | fillRect(g, tiles.get(i), main.contains(data, i) ? Color.red : Color.black); |
17 | }); |
18 | awtEvery(canvas, 1000, r updateMe); |
19 | ret canvas; |
20 | } |
21 | |
22 | void update { |
23 | new BitSet bs; |
24 | L l = dm_listModules(); |
25 | for i over l: |
26 | if (isLocked((Lock) getOpt(l.get(i), 'lock))) { |
27 | print("Locked: " + l.get(i)); |
28 | bs.set(i); |
29 | } |
30 | setFields(n := l(l), data := bs); |
31 | repaint(canvas); |
32 | } |
33 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016660 |
Snippet name: | Lock Matrix [shows which modules are currently locked] |
Eternal ID of this version: | #1016660/19 |
Text MD5: | 93a41a3802a73eff03814b0bff65f2d7 |
Transpilation MD5: | 3374b3fd4533fb82dbf3ba450cd45fdf |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-11 17:30:12 |
Source code size: | 938 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 383 / 548 |
Version history: | 18 change(s) |
Referenced in: | [show references] |