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

38
LINES

< > BotCompany Repo | #1024916 // Chess Piece Database 2 (from individual images, dev.)

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (8447L/44K).

1  
!7
2  
3  
cmodule PieceDatabase {
4  
  S piece = "white king";
5  
  bool lightSquares;
6  
  
7  
  transient Map<Bool, MultiMap<S>> map = new Map;
8  
  transient SingleComponentPanel scp;
9  
  transient ImageSurface is;
10  
  transient JLabel lblCount;
11  
  transient ReliableSingleThread rst = dm_rst(module(), r update);
12  
  
13  
  start-thread {
14  
    for (bool lightSquares : ll(false, true))
15  
      map.put(lightSquares, uniquifyMultiMapValues(pairsToMultiMap(reversePairs(chessPieceImagesFromAGIBlue(lightSquares)))));
16  
    rst.trigger();
17  
  }
18  
  
19  
  void update {
20  
    if (is == null) ret;
21  
    scp.setComponent(centerAndSouthWithMargin(jScroll_center(is), lblCount));
22  
    MultiMap<S> mm = map.get(lightSquares);
23  
    if (mm == null) ret;
24  
    L<BufferedImage> images = map loadImage2(mm.get(replaceObject(piece, "empty square", "empty")));
25  
    is.setImage(mergeBufferedImagesHorizontally(images));
26  
    setText(lblCount, nImages(images));
27  
  }
28  
  
29  
  visualize {
30  
    is = jImageSurface();
31  
    lblCount = jCenteredLabel();
32  
    ret withComputing(rst, northAndCenterWithMargins(
33  
      jline(
34  
        withLabel("Show images for:", main.onChange(rst, dm_comboBox piece(replace(ai_chessPieces(), "empty", "empty square")))),
35  
        dm_checkBox("Light squares", 'lightSquares)),
36  
      scp = singleComponentPanel(jCenteredLabel("Loading..."))));
37  
  }
38  
}

Author comment

Began life as a copy of #1024850

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024916
Snippet name: Chess Piece Database 2 (from individual images, dev.)
Eternal ID of this version: #1024916/10
Text MD5: 27e7fa5327c2ad952266ca3ce348b666
Transpilation MD5: 021fc00d3cc2495d0d6d2c255bfae30e
Author: stefan
Category: javax / chess ocr
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-29 17:55:37
Source code size: 1336 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 222 / 419
Version history: 9 change(s)
Referenced in: [show references]