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

51
LINES

< > BotCompany Repo | #1034488 // G22RunSingleAnalyzerPanel

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

Transpiled version (35228L) is out of date.

1  
srecord noeq G22RunSingleAnalyzerPanel(G22Utils g22utils, BufferedImage image, G22Recognizer analyzer) is Swingable {
2  
  transient ReliableSingleThread rst = new(r _run);
3  
  transient SingleComponentPanel scp = singleComponentPanel();
4  
  transient S pleaseSelectMsg = ""; //"Please select an analyzer";
5  
  
6  
  event analyzerResult(G22Recognizer.CompiledAnalyzer analyzer, O result);
7  
  event analyzerError(G22Recognizer.CompiledAnalyzer analyzer, Throwable error);
8  
  
9  
  visual {
10  
    reRun();
11  
    ret scp;
12  
  }
13  
  
14  
  void reRun() {
15  
    rst.trigger();
16  
  }
17  
  
18  
  void setImage(BufferedImage image) {
19  
    this.image = image;
20  
    reRun();
21  
  }
22  
  
23  
  void _run {
24  
    if (analyzer == null) ret with scp.set(jcenteredlabel(pleaseSelectMsg));
25  
    if (image == null) ret with scp.set(jcenteredlabel("No image"));
26  
  
27  
    G22Recognizer.CompiledAnalyzer compiled = analyzer.compileForAutoRun();
28  
    if (compiled == null)
29  
      ret with scp.set(jcenteredlabel(analyzer + " is not cleared for auto-run"));
30  
      
31  
    if (compiled.compileError != null)
32  
      ret with scp.set(jErrorView(compiled.compileError));
33  
    
34  
    if (scp.isEmpty())  
35  
      scp.set(jcenteredlabel("Running analyzer..."));
36  
      
37  
    try {
38  
      long time = nanoTime();
39  
      O result = compiled.get(image);
40  
      time = nanoTime()-time;
41  
      analyzerResult(compiled, result);
42  
      var visualizer = new G22JavaObjectVisualizer(g22utils, result)
43  
        .horizontal(true);
44  
      visualizer.nanos(time);
45  
      scp.set(visualizer);
46  
    } catch e {
47  
      scp.set(jErrorView(e));
48  
      analyzerError(compiled, e);
49  
    }
50  
  }
51  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034488
Snippet name: G22RunSingleAnalyzerPanel
Eternal ID of this version: #1034488/22
Text MD5: 70b9f551e296a84489159795b61d1aa7
Author: stefan
Category: javax / gazelle 22
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-11 06:58:42
Source code size: 1618 bytes / 51 lines
Pitched / IR pitched: No / No
Views / Downloads: 209 / 392
Version history: 21 change(s)
Referenced in: [show references]