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

11
LINES

< > BotCompany Repo | #1019516 // jVerticalGreenBar - dynamic green bar based on LiveValue

JavaX fragment (include)

static JComponent jVerticalGreenBar(final LiveValue<? extends Number> lv, fO... _) {
  final JComponent c = dynamicallyPaintedComponent(voidfunc(Graphics2D g, int w, int h) {
    float value = toFloat(lv!);
    float max = toFloat(optParam(_, 'max, (Number) 1f));
    int height = iround(doubleRatio(value, max)*h);
    main.fillRect(g, 0, 0, w, h-height, Color.black);
    main.fillRect(g, 0, h-height, w, height, Color.green);
  });
  bindLiveValueListenerToComponent(c, lv, r { c.repaint() });
  ret c;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019516
Snippet name: jVerticalGreenBar - dynamic green bar based on LiveValue
Eternal ID of this version: #1019516/2
Text MD5: e29c71b0b926de1a5fda2dd1fb060d9e
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-11-11 18:49:14
Source code size: 517 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 200 / 242
Version history: 1 change(s)
Referenced in: [show references]