Uses 911K of libraries. Click here for Pure Java version (15678L/87K).
1 | !7 |
2 | |
3 | cmodule MarkedImages > DynSCP { |
4 | File dir; |
5 | |
6 | transient DynamicHStack buttons; |
7 | transient ButtonImageLoader imageLoader; |
8 | |
9 | O[] menuItems() { |
10 | ret litobjarray("Select directory...", r select); |
11 | } |
12 | |
13 | start { |
14 | if (dir == null) dir = picturesDir(); |
15 | ownResource(vmBus_onDirChange(dir, r updateButtons)); |
16 | } |
17 | |
18 | JComponent visualize2() { |
19 | if (dir == null) |
20 | ret jHandleFileDrop(jcenteredbutton("Select directory...", rThread select), voidfunc(File f) { setDir(f) }); |
21 | setDir(dir); |
22 | ret getComponent(); |
23 | } |
24 | |
25 | void select enter { |
26 | selectDir(voidfunc(File dir) { setDir(dir) }); |
27 | } |
28 | |
29 | void setDir(File dir) enter { |
30 | setField(+dir); |
31 | |
32 | buttons = makeNiceButtons(); |
33 | imageLoader = new ButtonImageLoader(buttons) { |
34 | void setAButtonsImage(JButton b, File f) { |
35 | BufferedImage img = loadBufferedImage(f); |
36 | BufferedImage preview = scaleBufferedImageToHeight(imageHeight, img); |
37 | LPairS pairs = fileInfoFileAsPairs(f); |
38 | fOr (PairS p : pairs) { |
39 | O o = unstruct(p.b); // Note: unsafe |
40 | if (o instanceof Scored) o = o/Scored!; |
41 | Rect r = optCast Rect(o); |
42 | if (r != null) |
43 | drawRect(preview, rescaleRect_imageToImage(r, img, preview), Color.white); |
44 | } |
45 | setButtonImage(b, preview); |
46 | } |
47 | }; |
48 | updateButtons(); |
49 | setComponent(jHigherScrollPane(jfullcenter(buttons))); |
50 | } |
51 | |
52 | void updateButtons { |
53 | if (dir == null || buttons == null) ret; |
54 | temp enter(); |
55 | L<File> imageFiles = sortFilesByName(listImageFiles(dir)); |
56 | L<TextImageAction> l = filesForNiceButtons(latestFilesFirst(imageFiles), f showImage); |
57 | for (final TextImageAction tia : l) |
58 | tia.popupMenuMaker = imageFilesPopupMenuFunction(tia); |
59 | replaceNiceButtons(buttons, l); |
60 | setModuleName(nImages(l) + " - " + f2s(dir)); |
61 | if (imageLoader != null) imageLoader.update(); |
62 | } |
63 | } |
Began life as a copy of #1019188
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027224 |
Snippet name: | Marked Images Album [supports multiple objects per image] |
Eternal ID of this version: | #1027224/11 |
Text MD5: | f7710c980033773cd4f7eda9fd2d1a69 |
Transpilation MD5: | 3c3fb5b0c06808a3937bb8aadc31f7e5 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-26 17:38:27 |
Source code size: | 1949 bytes / 63 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 237 / 450 |
Version history: | 10 change(s) |
Referenced in: | [show references] |