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).

!7

cmodule PieceDatabase {
  S piece = "white king";
  bool lightSquares;
  
  transient Map<Bool, MultiMap<S>> map = new Map;
  transient SingleComponentPanel scp;
  transient ImageSurface is;
  transient JLabel lblCount;
  transient ReliableSingleThread rst = dm_rst(module(), r update);
  
  start-thread {
    for (bool lightSquares : ll(false, true))
      map.put(lightSquares, uniquifyMultiMapValues(pairsToMultiMap(reversePairs(chessPieceImagesFromAGIBlue(lightSquares)))));
    rst.trigger();
  }
  
  void update {
    if (is == null) ret;
    scp.setComponent(centerAndSouthWithMargin(jScroll_center(is), lblCount));
    MultiMap<S> mm = map.get(lightSquares);
    if (mm == null) ret;
    L<BufferedImage> images = map loadImage2(mm.get(replaceObject(piece, "empty square", "empty")));
    is.setImage(mergeBufferedImagesHorizontally(images));
    setText(lblCount, nImages(images));
  }
  
  visualize {
    is = jImageSurface();
    lblCount = jCenteredLabel();
    ret withComputing(rst, northAndCenterWithMargins(
      jline(
        withLabel("Show images for:", main.onChange(rst, dm_comboBox piece(replace(ai_chessPieces(), "empty", "empty square")))),
        dm_checkBox("Light squares", 'lightSquares)),
      scp = singleComponentPanel(jCenteredLabel("Loading..."))));
  }
}

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: 223 / 421
Version history: 9 change(s)
Referenced in: