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

49
LINES

< > BotCompany Repo | #1015996 - DynSCP

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (10225L) is out of date.

1  
abstract sclass DynSCP extends DynModule {
2  
  transient SingleComponentPanel scp;
3  
  transient ReliableSingleThread rstRevisualize2 = new(r revisualize2_impl);
4  
  transient L<Runnable> afterVisualize2;
5  
  static bool verbose;
6  
7  
  /*final*/ JComponent visualize() {
8  
    scp = singleComponentPanel();
9  
    scp.setComponent(visualize2());
10  
    pcallFAll(afterVisualize2);
11  
    ret scp;
12  
  }
13  
    
14  
  void unvisualize() { scp = null; unvisualize2(); }
15  
  JComponent visualize2() { null; }
16  
  
17  
  void unvisualize2() {} // overridable
18  
  
19  
  void revisualize2() {
20  
    rstRevisualize2.trigger();
21  
  }
22  
  
23  
  void revisualize2_impl() enter {
24  
    //lock lock;
25  
    if (scp == null) ret;
26  
    JComponent c = visualize2();
27  
    if (c != scp.getComponent()) {
28  
      if (verbose) print("Setting component");
29  
      scp.setComponent(c);
30  
      pcallFAll(afterVisualize2);
31  
    }
32  
  }
33  
  
34  
  void setComponent(Component c) {
35  
    if (scp != null) scp.setComponent(c);
36  
  }
37  
  
38  
  // usually it'll be a JComponent
39  
  JComponent getComponent() {
40  
    ret scp == null ? null : (JComponent) scp.getComponent();
41  
  }
42  
  
43  
  bool isShowing() { ret scp != null; }
44  
  bool isShowing(Component c) { ret isComponentShowing(c); }
45  
  
46  
  void afterVisualize2(Runnable r) {
47  
    afterVisualize2 = createOrAddToSyncList(afterVisualize2, r);
48  
  }
49  
}

download  show line numbers  debug dex   

Travelled to 11 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz, xrpafgyirdlv

No comments. add comment

Snippet ID: #1015996
Snippet name: DynSCP
Eternal ID of this version: #1015996/22
Text MD5: 16b58936d3e8b06e0332c589d9af2fd9
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-21 01:55:26
Source code size: 1325 bytes / 49 lines
Pitched / IR pitched: No / No
Views / Downloads: 245 / 672
Version history: 21 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1015996 & http://1015996.tinybrain.de