Uses 3874K of libraries. Click here for Pure Java version (5287L/37K/136K).
1 | !7 |
2 | |
3 | p-substance { |
4 | if (l(args) != 0) new Viewer().showFile(new File(join(" ", args))); |
5 | else inputFilePath("Image to view", voidfunc(File file) { new Viewer().showFile(file) }); |
6 | } |
7 | |
8 | sclass Viewer { |
9 | ImageSurface is; |
10 | File file; |
11 | |
12 | void showFile(final File file) { |
13 | assertTrue("File not found: " + absolutePath(file), file.exists()); |
14 | this.file = file; |
15 | bool first = is == null; |
16 | is = showImage_centered(is, file.getName(), loadBufferedImage(file)); |
17 | |
18 | if (first) { |
19 | registerLeftKey(getFrame(is), r { nextFile(-1) }); |
20 | registerRightKey(getFrame(is), r { nextFile(1) }); |
21 | registerMinusKeys(is, r { is.zoomOut(1.5) }); |
22 | registerPlusKeys(is, r { is.zoomIn(1.5) }); |
23 | registerKey(is, KeyEvent.VK_A, "A", r { is.setZoom(1.0) }); |
24 | registerKey(is, KeyEvent.VK_W, "W", r { is.zoomToWindow() }); |
25 | hideConsole(); |
26 | } |
27 | } |
28 | |
29 | void nextFile(int offset) { |
30 | L<File> files = asList(listFilesOnly(file.getParentFile())); |
31 | int i = indexOfPred(files, func(File f) { eq(f.getName(), file.getName()) }); |
32 | showFile(get(files, mod(i+offset, l(files)))); |
33 | } |
34 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006685 |
Snippet name: | Local Image Viewer (optionally takes image path as argument) |
Eternal ID of this version: | #1006685/16 |
Text MD5: | a9a992fa92f70724a8c42e6e81d82069 |
Transpilation MD5: | 878f4ed52fab3b45090ad4f9c8bb7848 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-02-05 11:09:05 |
Source code size: | 1140 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 589 / 1959 |
Version history: | 15 change(s) |
Referenced in: | [show references] |