Uses 3981K of libraries. Click here for Pure Java version (10136L/74K/276K).
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 | awt { is.zoomToWindow(); }
|
18 | |
19 | if (first) {
|
20 | registerLeftKey(getFrame(is), r { nextFile(-1) });
|
21 | registerRightKey(getFrame(is), r { nextFile(1) });
|
22 | registerMinusKeys(is, r { is.zoomOut(1.5) });
|
23 | registerPlusKeys(is, r { is.zoomIn(1.5) });
|
24 | registerKey(is, KeyEvent.VK_A, "A", r { is.setZoom(1.0) });
|
25 | registerKey(is, KeyEvent.VK_W, "W", r { is.zoomToWindow() });
|
26 | hideConsole(); |
27 | } |
28 | } |
29 | |
30 | void nextFile(int offset) {
|
31 | L<File> files = asList(listFilesOnly(file.getParentFile())); |
32 | int i = indexOfPred(files, func(File f) { eq(f.getName(), file.getName()) });
|
33 | showFile(get(files, mod(i+offset, l(files)))); |
34 | } |
35 | } |
Began life as a copy of #1006685
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: | #1007760 |
| Snippet name: | Local Image Viewer 2 (fits image in window by default) |
| Eternal ID of this version: | #1007760/3 |
| Text MD5: | 5169ab8763f71bc2c98acdbe7e492367 |
| Transpilation MD5: | 8f3b318abdbb256b944ca459ab3733d5 |
| Author: | stefan |
| Category: | javax / gui |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-06-03 01:09:09 |
| Source code size: | 1172 bytes / 35 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 1003 / 2835 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |