!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); } void start { ownTimer(doEvery(2.0, r fullUpdate)); // TODO: watch service } JComponent visualize() { if (dir == 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, "Files contained", filesContained == null ? "Unknown" : l(filesContained)); } void fullUpdate { update(); } void update { lock lock; if (path != null && allowedToLook) { bool change = setField(exists := file().isFile()); change |= setField(size := null); if (exists) { image = loadImage2(file()); change |= setField(size, pt(image.getWidth(), image.getHeight())); } if (change) revisualize(); } else if (setFields(exists := null, size := null, image := null)) revisualize(); } // API for other modules File getFile() { ret file(); } }