Search in sources :

Example 1 with ConcurrentMonoStack

use of uk.ac.sussex.gdsc.core.utils.concurrent.ConcurrentMonoStack in project GDSC-SMLM by aherbert.

the class FailCountManager method plotData.

/**
 * Show an interactive plot of the fail count data.
 */
private void plotData() {
    final LocalList<FailCountData> failCountData = failCountDataRef.get();
    if (failCountData.isEmpty()) {
        IJ.error(TITLE, "No fail count data in memory");
        return;
    }
    // Find max fail count size
    final int max = getMaxConsecutiveFailCount(failCountData);
    final ConcurrentMonoStack<PlotData> stack = new ConcurrentMonoStack<>();
    boolean clear = true;
    try {
        new Thread(new PlotWorker(stack, failCountData)).start();
        final NonBlockingExtendedGenericDialog gd = new NonBlockingExtendedGenericDialog(TITLE);
        gd.addSlider("Item", 1, failCountData.size(), settings.getPlotItem());
        gd.addCheckbox("Fixed_x_axis", settings.getPlotFixedXAxis());
        gd.addMessage("Rolling Window Fail Count");
        gd.addSlider("Rolling_window", 1.0, 3.0 * max, settings.getPlotRollingWindow());
        gd.addMessage("Weighted Fail Count");
        gd.addSlider("Pass_weight", 1, 20, settings.getPlotPassWeight());
        gd.addSlider("Fail_weight", 1, 20, settings.getPlotFailWeight());
        gd.addMessage("Resetting Fail Count");
        gd.addSlider("Reset_fraction", 0.05, 0.95, settings.getPlotResetFraction());
        gd.addDialogListener((gd2, event) -> {
            final int item = (int) gd2.getNextNumber();
            final boolean fixedXAxis = gd2.getNextBoolean();
            final int rollingWindow = (int) gd2.getNextNumber();
            final int passWeight = (int) gd2.getNextNumber();
            final int failWeight = (int) gd2.getNextNumber();
            final double resetFraction = gd2.getNextNumber();
            settings.setPlotItem(item);
            settings.setPlotRollingWindow(rollingWindow);
            settings.setPlotPassWeight(passWeight);
            settings.setPlotFailWeight(failWeight);
            settings.setPlotResetFraction(resetFraction);
            stack.insert(new PlotData(item, fixedXAxis, rollingWindow, passWeight, failWeight, resetFraction));
            return true;
        });
        gd.hideCancelButton();
        gd.setOKLabel("Close");
        gd.addHelp(HelpUrls.getUrl("fail-count-manager-plot"));
        gd.showDialog();
        clear = gd.wasCanceled();
    } finally {
        stack.close(clear);
    }
}
Also used : ConcurrentMonoStack(uk.ac.sussex.gdsc.core.utils.concurrent.ConcurrentMonoStack) NonBlockingExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog)

Aggregations

NonBlockingExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.NonBlockingExtendedGenericDialog)1 ConcurrentMonoStack (uk.ac.sussex.gdsc.core.utils.concurrent.ConcurrentMonoStack)1