use of gdsc.smlm.ij.IJImageSource in project GDSC-SMLM by aherbert.
the class OverlayResults method run.
/*
* (non-Javadoc)
*
* @see ij.plugin.PlugIn#run(java.lang.String)
*/
public void run(String arg) {
SMLMUsageTracker.recordPlugin(this.getClass(), arg);
if (MemoryPeakResults.isMemoryEmpty()) {
IJ.error(TITLE, "There are no fitting results in memory");
return;
}
names = new String[MemoryPeakResults.getResultNames().size() + 1];
ids = new int[names.length];
int c = 0;
names[c++] = "(None)";
for (MemoryPeakResults results : MemoryPeakResults.getAllResults()) {
if (results.getSource().getOriginal() instanceof IJImageSource) {
IJImageSource source = (IJImageSource) (results.getSource().getOriginal());
ImagePlus imp = WindowManager.getImage(source.getName());
if (imp != null) {
ids[c] = imp.getID();
names[c++] = results.getName();
}
}
}
if (c == 1) {
IJ.error(TITLE, "There are no result images available");
return;
}
names = Arrays.copyOf(names, c);
Thread t = null;
Worker w = null;
NonBlockingGenericDialog gd = new NonBlockingGenericDialog(TITLE);
gd.addMessage("Overlay results on current image frame");
gd.addChoice("Results", names, (name == null) ? "" : name);
gd.addCheckbox("Show_table", showTable);
gd.addMessage("");
gd.addHelp(About.HELP_URL);
gd.hideCancelButton();
gd.setOKLabel("Close");
if (!(IJ.isMacro() || java.awt.GraphicsEnvironment.isHeadless())) {
choice = (Choice) gd.getChoices().get(0);
choice.addItemListener(this);
checkbox = (Checkbox) gd.getCheckboxes().get(0);
checkbox.addItemListener(this);
label = (Label) gd.getMessage();
// Listen for changes to an image
ImagePlus.addImageListener(this);
show();
t = new Thread(w = new Worker());
t.setDaemon(true);
t.start();
}
gd.showDialog();
if (!(IJ.isMacro() || java.awt.GraphicsEnvironment.isHeadless()))
ImagePlus.removeImageListener(this);
if (!gd.wasCanceled()) {
name = gd.getNextChoice();
showTable = gd.getNextBoolean();
}
if (t != null) {
w.running = false;
inbox.close();
try {
t.join(0);
} catch (InterruptedException e) {
}
t = null;
}
}
Aggregations