!7 cmodule PieceDatabase { S piece = "white king"; bool lightSquares; transient Map> 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 mm = map.get(lightSquares); if (mm == null) ret; L 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...")))); } }