Libraryless. Click here for Pure Java version (14499L/102K).
!7 sclass ImageInfo extends DynModule { S path; bool allowedToLook; Bool exists; Pt size; transient JComboBox cbAllowedToLook; transient BufferedImage image; transient long imageLoaded; File file() { ret newFile(path); } JComponent visualize() { if (path == null) ret jcenteredbutton("Load image...", r { selectFile("Load image", voidfunc(File f) { setField(path := f2s(f)); revisualize(); }); }); if (cbAllowedToLook == null) cbAllowedToLook = yesNoComboBox(allowedToLook, voidfunc(bool b) { setField(allowedToLook := b) }); ret makeForm( "Image location" := path, allowedToLook := cbAllowedToLook, +exists, "Size", size == null ? null : size.x + "*" + size.y, "Loaded" := image != null); } void update { if (path != null && allowedToLook) { bool change = setField(exists := file().isFile()); if (!exists) change |= setField(size := null); else try { getImage(); change |= setField(size := pt(image.getWidth(), image.getHeight())); } catch print e { change |= setField(size := null); } if (change) revisualize(); } else if (setFields(exists := null, size := null, image := null)) revisualize(); } // API for other modules File getFile() { ret file(); } Image getImage() { lock lock; if (image == null) { imageLoaded = now(); image = loadImage2(file()); } ret image; } }
Began life as a copy of #1015916
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: | #1016034 |
Snippet name: | Image Info [Dyn Module] |
Eternal ID of this version: | #1016034/10 |
Text MD5: | c12f21e84c7c254715c24da302bcb59a |
Transpilation MD5: | 56291b87d273d442988902524ab6ec71 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-06-08 18:38:12 |
Source code size: | 1616 bytes / 63 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 379 / 528 |
Version history: | 9 change(s) |
Referenced in: | [show references] |