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

27
LINES

< > BotCompany Repo | #1007300 // updateCanvas - repaint jcanvas

JavaX fragment (include)

1  
static int updateCanvas_retryInterval = 50;
2  
3  
// if makeImg returns null, it is recalled after a delay
4  
static void updateCanvas(final Canvas canvas, fO makeImg) {
5  
  awtIfNecessary {
6  
    if (canvas.updating || canvas.getWidth() == 0) ret;
7  
    canvas.updating = true;
8  
    try {
9  
      BufferedImage img = asBufferedImage(callF(makeImg, canvas.getWidth(), canvas.getHeight()));
10  
      if (img != null) {
11  
        canvas.setImage(img);
12  
        canvas.updating = false;
13  
      } else
14  
        awtLater(updateCanvas_retryInterval, r {
15  
          canvas.updating = false;
16  
          updateCanvas(canvas, makeImg);
17  
        });
18  
    } catch e {
19  
      canvas.updating = false;
20  
      throw rethrow(e);
21  
    }
22  
  }
23  
}
24  
25  
static void updateCanvas(final Canvas canvas) {
26  
  if (canvas != null) canvas.update();
27  
}

Author comment

Began life as a copy of #1007284

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007300
Snippet name: updateCanvas - repaint jcanvas
Eternal ID of this version: #1007300/16
Text MD5: bdca4fb73c2192d9b9ba1418dfb98f1c
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-21 16:52:32
Source code size: 809 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 643 / 674
Version history: 15 change(s)
Referenced in: [show references]