Uses 108K of libraries. Click here for Pure Java version (14251L/107K).
1 | !7 |
2 | |
3 | module MarkImage > DynImageSurface { |
4 | File file; |
5 | transient JTable table; |
6 | |
7 | start { |
8 | ownResource(onClipboardFile_monitorRegularly(3.0, vf<File> loadFile)); |
9 | } |
10 | |
11 | void loadFile(final File f) enter { |
12 | if (!isImageFile(f)) ret; |
13 | setModuleName("Mark Image - " + f2s(f)); |
14 | setField(file := f); |
15 | setImage(loadImage2(file)); |
16 | showMarkings(); |
17 | } |
18 | |
19 | visualize { |
20 | table = sexyTable(); |
21 | JComponent i = super.visualize(); |
22 | loadFile(file); |
23 | ret withCenteredButtons(jvsplit(i, |
24 | jSection("Marked things", table)), |
25 | imageSelectionDepend(imageSurface, jbutton("Mark selection...", rThread markSelection)), |
26 | tableDependentButton(table, "Delete item", rThread { |
27 | saveImageFileMarkings(file, removeAndReturnCollection(loadMarkings(), selectedTableRow(table))); |
28 | showMarkings(); |
29 | }), |
30 | jHelpIcon("Copy an image file (must be a file on disk) to the clipboard to mark it here")); |
31 | } |
32 | |
33 | void markSelection enter { |
34 | Rect r = getSelection(); |
35 | if (r == null) ret; |
36 | inputText("Enter description for selected area", voidfunc(S name) { |
37 | LPair<Rect, S> markings = loadMarkings(); |
38 | setAdd(markings, pair(r, name)); |
39 | print("New markings:"); |
40 | pnlIndent(markings); |
41 | saveImageFileMarkings(file, markings); |
42 | showMarkings(); |
43 | }); |
44 | } |
45 | |
46 | LPair<Rect, S> loadMarkings() { |
47 | ret unnull(loadImageFileMarkings(file)); |
48 | } |
49 | |
50 | void showMarkings { |
51 | LPair<Rect, S> markings = loadMarkings(); |
52 | dataToTable(table, map(markings, p -> litorderedmap("Rect" := str(p.a), "Description" := p.b))); |
53 | overlaySelectionsOnImageSurface(imageSurface, pairsA(loadMarkings())); |
54 | } |
55 | } |
Began life as a copy of #1019185
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1022923 |
Snippet name: | Mark Image [Dyn Module, dev., mark different things in image] |
Eternal ID of this version: | #1022923/17 |
Text MD5: | b41bb86cb7ef3e536c228c8a146bc82a |
Transpilation MD5: | 1e07152ccdc036c7c48667c6ff754401 |
Author: | stefan |
Category: | javax / stefan's os / image recognition |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-04-17 23:05:22 |
Source code size: | 1716 bytes / 55 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 307 / 586 |
Version history: | 16 change(s) |
Referenced in: | [show references] |