Search in sources :

Example 11 with IJImageSource

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;
    }
}
Also used : IJImageSource(gdsc.smlm.ij.IJImageSource) MemoryPeakResults(gdsc.smlm.results.MemoryPeakResults) NonBlockingGenericDialog(ij.gui.NonBlockingGenericDialog) ImagePlus(ij.ImagePlus) Point(java.awt.Point)

Aggregations

IJImageSource (gdsc.smlm.ij.IJImageSource)11 MemoryPeakResults (gdsc.smlm.results.MemoryPeakResults)7 ImagePlus (ij.ImagePlus)5 PeakResult (gdsc.smlm.results.PeakResult)4 AggregatedImageSource (gdsc.smlm.results.AggregatedImageSource)3 ExtendedPeakResult (gdsc.smlm.results.ExtendedPeakResult)3 InterlacedImageSource (gdsc.smlm.results.InterlacedImageSource)3 ImageStack (ij.ImageStack)3 Rectangle (java.awt.Rectangle)3 Statistics (gdsc.core.utils.Statistics)2 StoredDataStatistics (gdsc.core.utils.StoredDataStatistics)2 ImageSource (gdsc.smlm.results.ImageSource)2 ExtendedGenericDialog (ij.gui.ExtendedGenericDialog)2 Color (java.awt.Color)2 Point (java.awt.Point)2 SystemColor (java.awt.SystemColor)2 IJTrackProgress (gdsc.core.ij.IJTrackProgress)1 Random (gdsc.core.utils.Random)1 FitEngine (gdsc.smlm.engine.FitEngine)1 FitJob (gdsc.smlm.engine.FitJob)1