Search in sources :

Example 1 with CoordinateProvider

use of uk.ac.sussex.gdsc.smlm.utils.CoordinateProvider in project GDSC-SMLM by aherbert.

the class TraceMatchCalculator method refresh.

private static WindowAndPainter refresh(AtomicReference<WindowAndPainter> ref, boolean pairs, TextWindow resultsWindow, MemoryPeakResults results1) {
    // Produce a pairs output
    final WindowAndPainter wap = ConcurrencyUtils.refresh(ref, // Test the window is showing
    w -> ImageJUtils.isShowing(w.textWindow), // Create
    () -> {
        final String title = TITLE + ((pairs) ? " Pairs" : " Triples");
        final String header = pairs ? createPairsHeader() : createTriplesHeader();
        final TextWindow window = new TextWindow(title, header, "", 900, 300);
        // Position relative to results window
        final Point p = resultsWindow.getLocation();
        p.y += resultsWindow.getHeight();
        window.setLocation(p);
        final CoordinateProvider coordinateProvider = line -> {
            // Extract the startT and x,y coordinates from the first pulse in the line
            final int[] index = { 0, 5, 12 };
            final String[] fields = line.split("\t");
            for (final int i : index) {
                if (i < fields.length) {
                    if (fields[i].equals("-")) {
                        continue;
                    }
                    final int startT = Integer.parseInt(fields[i]);
                    final double x = Double.parseDouble(fields[i + 2]);
                    final double y = Double.parseDouble(fields[i + 3]);
                    return new double[] { startT, x, y };
                }
            }
            return null;
        };
        final ImageRoiPainter painter = new ImageRoiPainter(window.getTextPanel(), results1.getSource().getOriginal().getName(), coordinateProvider);
        final WindowAndPainter result = new WindowAndPainter(window, painter);
        // Free memory on close
        window.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosed(WindowEvent event) {
                ref.compareAndSet(result, null);
                super.windowClosed(event);
            }
        });
        return result;
    });
    wap.textWindow.getTextPanel().clear();
    wap.painter.setTitle(results1.getSource().getOriginal().getName());
    return wap;
}
Also used : CoordinateProvider(uk.ac.sussex.gdsc.smlm.utils.CoordinateProvider) TextWindow(ij.text.TextWindow) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) WindowManager(ij.WindowManager) Point(java.awt.Point) HashMap(java.util.HashMap) ImageRoiPainter(uk.ac.sussex.gdsc.smlm.ij.utils.ImageRoiPainter) AtomicReference(java.util.concurrent.atomic.AtomicReference) MatchResult(uk.ac.sussex.gdsc.core.match.MatchResult) ArrayList(java.util.ArrayList) MemoryPeakResults(uk.ac.sussex.gdsc.smlm.results.MemoryPeakResults) MathUtils(uk.ac.sussex.gdsc.core.utils.MathUtils) LinkedList(java.util.LinkedList) XyrResultProcedure(uk.ac.sussex.gdsc.smlm.results.procedures.XyrResultProcedure) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) InputSource(uk.ac.sussex.gdsc.smlm.ij.plugins.ResultsManager.InputSource) Pulse(uk.ac.sussex.gdsc.core.match.Pulse) DistanceUnit(uk.ac.sussex.gdsc.smlm.data.config.UnitProtos.DistanceUnit) Coordinate(uk.ac.sussex.gdsc.core.match.Coordinate) WindowAdapter(java.awt.event.WindowAdapter) ConcurrencyUtils(uk.ac.sussex.gdsc.core.utils.concurrent.ConcurrencyUtils) WindowEvent(java.awt.event.WindowEvent) Consumer(java.util.function.Consumer) List(java.util.List) Counter(uk.ac.sussex.gdsc.smlm.results.count.Counter) PointPair(uk.ac.sussex.gdsc.core.match.PointPair) ImageJUtils(uk.ac.sussex.gdsc.core.ij.ImageJUtils) IJ(ij.IJ) MatchCalculator(uk.ac.sussex.gdsc.core.match.MatchCalculator) Nullable(uk.ac.sussex.gdsc.core.annotation.Nullable) PlugIn(ij.plugin.PlugIn) Collections(java.util.Collections) ImageRoiPainter(uk.ac.sussex.gdsc.smlm.ij.utils.ImageRoiPainter) TextWindow(ij.text.TextWindow) CoordinateProvider(uk.ac.sussex.gdsc.smlm.utils.CoordinateProvider) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Point(java.awt.Point)

Aggregations

IJ (ij.IJ)1 WindowManager (ij.WindowManager)1 PlugIn (ij.plugin.PlugIn)1 TextWindow (ij.text.TextWindow)1 Point (java.awt.Point)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Consumer (java.util.function.Consumer)1 Nullable (uk.ac.sussex.gdsc.core.annotation.Nullable)1 ImageJUtils (uk.ac.sussex.gdsc.core.ij.ImageJUtils)1 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)1 Coordinate (uk.ac.sussex.gdsc.core.match.Coordinate)1 MatchCalculator (uk.ac.sussex.gdsc.core.match.MatchCalculator)1