!7 module MarkImage > DynImageSurface { File file; transient JTable table; start { ownResource(onClipboardFile(vf loadFile)); } void loadFile(final File f) enter { if (!isImageFile(f)) ret; setModuleName("Mark Image - " + f2s(f)); setField(file := f); loadMarkings(); setImage(loadImage2(file)); } visualize { table = sexyTable(); JComponent i = super.visualize(); loadFile(file); ret withCenteredButtons(jvsplit(i, jSection("Marked things", table)), imageSelectionDepend(imageSurface, jbutton("Mark selection...", rThread markSelection)), jHelpIcon("Copy an image to the clipboard to mark it here")); } void markSelection enter { Rect r = getSelection(); if (r == null) ret; inputText("Enter description for selected area", voidfunc(S name) { LPair markings = unnull(loadImageFileMarkings(file)); setAdd(markings, pair(r, name)); print("New markings:"); pnlIndent(markings); saveImageFileMarkings(file, markings); }); } }