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.

srecord noeq G22RunSingleAnalyzerPanel(G22Utils g22utils, BufferedImage image, G22Recognizer analyzer) is Swingable {
  transient ReliableSingleThread rst = new(r _run);
  transient SingleComponentPanel scp = singleComponentPanel();
  transient S pleaseSelectMsg = ""; //"Please select an analyzer";
  
  event analyzerResult(G22Recognizer.CompiledAnalyzer analyzer, O result);
  event analyzerError(G22Recognizer.CompiledAnalyzer analyzer, Throwable error);
  
  visual {
    reRun();
    ret scp;
  }
  
  void reRun() {
    rst.trigger();
  }
  
  void setImage(BufferedImage image) {
    this.image = image;
    reRun();
  }
  
  void _run {
    if (analyzer == null) ret with scp.set(jcenteredlabel(pleaseSelectMsg));
    if (image == null) ret with scp.set(jcenteredlabel("No image"));
  
    G22Recognizer.CompiledAnalyzer compiled = analyzer.compileForAutoRun();
    if (compiled == null)
      ret with scp.set(jcenteredlabel(analyzer + " is not cleared for auto-run"));
      
    if (compiled.compileError != null)
      ret with scp.set(jErrorView(compiled.compileError));
    
    if (scp.isEmpty())  
      scp.set(jcenteredlabel("Running analyzer..."));
      
    try {
      long time = nanoTime();
      O result = compiled.get(image);
      time = nanoTime()-time;
      analyzerResult(compiled, result);
      var visualizer = new G22JavaObjectVisualizer(g22utils, result)
        .horizontal(true);
      visualizer.nanos(time);
      scp.set(visualizer);
    } catch e {
      scp.set(jErrorView(e));
      analyzerError(compiled, e);
    }
  }
}

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: 205 / 386
Version history: 21 change(s)
Referenced in: [show references]