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;
}
Aggregations