diff --git a/view-simulation-results/src/main/java/org/vcell/N5/N5ImageHandler.java b/view-simulation-results/src/main/java/org/vcell/N5/N5ImageHandler.java index b2695e0..be9fe6c 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/N5ImageHandler.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/N5ImageHandler.java @@ -11,8 +11,7 @@ import org.scijava.plugin.Parameter; import org.scijava.plugin.Plugin; import org.vcell.N5.UI.MainPanel; -import org.vcell.N5.UI.N5ExportTable; -import org.vcell.N5.retrieving.LoadingFactory; +import org.vcell.N5.retrieving.LoadingManager; import org.vcell.N5.retrieving.SimResultsLoader; import java.io.*; @@ -34,12 +33,12 @@ public class N5ImageHandler implements Command { public static MainPanel exportTable; public static String exportedMetaDataPath = System.getProperty("user.home") + "/.vcell/exportMetaData.json"; private static ExportDataRepresentation.FormatExportDataRepresentation exampleJSONData; - public static LoadingFactory loadingFactory; + public static LoadingManager loadingManager; @Override public void run() { initializeLogService(); - loadingFactory = new LoadingFactory(); + loadingManager = new LoadingManager(); exportTable = new MainPanel(); setExampleJSONData(); // N5ImageHandler.logService.setLevel(LogService.DEBUG); diff --git a/view-simulation-results/src/main/java/org/vcell/N5/UI/N5ExportTable.java b/view-simulation-results/src/main/java/org/vcell/N5/UI/N5ExportTable.java index f9de4e0..b75cf70 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/UI/N5ExportTable.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/UI/N5ExportTable.java @@ -1,5 +1,6 @@ package org.vcell.N5.UI; +import ij.ImagePlus; import org.scijava.log.Logger; import org.vcell.N5.ExportDataRepresentation; import org.vcell.N5.N5ImageHandler; @@ -41,7 +42,7 @@ public N5ExportTable(){} public void initialize(ControlButtonsPanel controlButtonsPanel, ExportDetailsPanel exportDetailsPanel){ this.controlPanel = controlButtonsPanel; this.exportDetailsPanel = exportDetailsPanel; - N5ImageHandler.loadingFactory.addSimLoadingListener(this); + N5ImageHandler.loadingManager.addSimLoadingListener(this); n5ExportTableModel = new N5ExportTableModel(); exportListTable = new JTable(n5ExportTableModel); this.setViewportView(exportListTable); @@ -181,7 +182,7 @@ public void openSelectedRows(boolean inMemory){ SimResultsLoader simResultsLoader = new SimResultsLoader(uri, rowData.savedFileName, row, rowData.jobID); filesToOpen.add(simResultsLoader); } - N5ImageHandler.loadingFactory.openN5FileDataset(filesToOpen, inMemory); + N5ImageHandler.loadingManager.openN5FileDataset(filesToOpen, inMemory); } public void copySelectedRowLink(){ @@ -227,7 +228,7 @@ public void valueChanged(ListSelectionEvent e) { public void removeFromLoadingRows(){ int row = exportListTable.getSelectedRow(); - N5ImageHandler.loadingFactory.stopOpeningSimulation(n5ExportTableModel.tableData.get(row).jobID); + N5ImageHandler.loadingManager.stopOpeningSimulation(n5ExportTableModel.tableData.get(row).jobID); loadingRowsJobID.remove(row); exportListTable.repaint(); } @@ -239,10 +240,11 @@ public void simIsLoading(int itemRow, String exportID) { } @Override - public void simFinishedLoading(int itemRow, String exportID) { + public void simFinishedLoading(int itemRow, String exportID, ImagePlus imagePlus) { loadingRowsJobID.remove(itemRow); exportListTable.repaint(); controlPanel.allowCancel(false); + imagePlus.show(); } static class N5ExportTableModel extends AbstractTableModel { diff --git a/view-simulation-results/src/main/java/org/vcell/N5/UI/RemoteFileSelection.java b/view-simulation-results/src/main/java/org/vcell/N5/UI/RemoteFileSelection.java index 6f0f827..ec9c518 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/UI/RemoteFileSelection.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/UI/RemoteFileSelection.java @@ -96,7 +96,7 @@ public String getS3URL(){ @Override public void actionPerformed(ActionEvent e) { SimResultsLoader simResultsLoader = new SimResultsLoader(getS3URL(), "", -1, ""); - N5ImageHandler.loadingFactory.openN5FileDataset(new ArrayList(){{add(simResultsLoader);}}, false); + N5ImageHandler.loadingManager.openN5FileDataset(new ArrayList(){{add(simResultsLoader);}}, false); this.setVisible(false); } } diff --git a/view-simulation-results/src/main/java/org/vcell/N5/analysis/TemporalAnalysisGUI.java b/view-simulation-results/src/main/java/org/vcell/N5/analysis/TemporalAnalysisGUI.java index 5a10dcf..f673a79 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/analysis/TemporalAnalysisGUI.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/analysis/TemporalAnalysisGUI.java @@ -75,7 +75,7 @@ public void displayGUI(){ 0, 0, 0, 5, saveToFile.getSelectedFile() ); - N5ImageHandler.loadingFactory.addSimLoadingListener(dataReduction); + N5ImageHandler.loadingManager.addSimLoadingListener(dataReduction); }); thread.start(); } diff --git a/view-simulation-results/src/main/java/org/vcell/N5/retrieving/LoadingFactory.java b/view-simulation-results/src/main/java/org/vcell/N5/retrieving/LoadingManager.java similarity index 91% rename from view-simulation-results/src/main/java/org/vcell/N5/retrieving/LoadingFactory.java rename to view-simulation-results/src/main/java/org/vcell/N5/retrieving/LoadingManager.java index a673257..63a75d9 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/retrieving/LoadingFactory.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/retrieving/LoadingManager.java @@ -18,7 +18,7 @@ import java.util.ArrayList; import java.util.HashMap; -public class LoadingFactory implements SimLoadingEventCreator { +public class LoadingManager implements SimLoadingEventCreator { private static final EventListenerList eventListenerList = new EventListenerList(); private final ControlButtonsPanel controlButtonsPanel = MainPanel.controlButtonsPanel; @@ -35,6 +35,7 @@ public void openN5FileDataset(ArrayList filesToOpen, boolean o for (int i = 0; i < filesToOpen.size(); i++){ SimResultsLoader simResultsLoader = filesToOpen.get(i); Thread openThread = new Thread(() -> { + ImagePlus imagePlus = null; try{ simResultsLoader.createS3ClientAndReader(); notifySimIsLoading(simResultsLoader); @@ -44,12 +45,11 @@ public void openN5FileDataset(ArrayList filesToOpen, boolean o rangeSelector = new RangeSelector(dimensions.get(2), dimensions.get(3), dimensions.get(4), simResultsLoader.userSetFileName); rangeSelector.displayRangeMenu(); if (!rangeSelector.cancel){ - openInMemory(simResultsLoader, rangeSelector); + imagePlus = openInMemory(simResultsLoader, rangeSelector); } rangeSelector.dispose(); } else{ - ImagePlus imagePlus = simResultsLoader.getImgPlusFromN5File(); - imagePlus.show(); + imagePlus = simResultsLoader.getImgPlusFromN5File(); } } catch (RuntimeException e) { @@ -65,7 +65,7 @@ public void openN5FileDataset(ArrayList filesToOpen, boolean o } finally { MainPanel.changeCursor(new Cursor(Cursor.DEFAULT_CURSOR)); controlButtonsPanel.enableCriticalButtons(true); - notifySimIsDoneLoading(simResultsLoader); + notifySimIsDoneLoading(simResultsLoader, imagePlus); synchronized (openSimulationsLock){ openingSimulations.remove(simResultsLoader.exportID); } @@ -79,7 +79,7 @@ public void openN5FileDataset(ArrayList filesToOpen, boolean o } } - private void openInMemory(SimResultsLoader simResultsLoader, RangeSelector rangeSelector) throws IOException { + private ImagePlus openInMemory(SimResultsLoader simResultsLoader, RangeSelector rangeSelector) throws IOException { ImagePlus imagePlus = simResultsLoader.getImgPlusFromN5File(); long start = System.currentTimeMillis(); logger.debug("Loading Virtual N5 File " + simResultsLoader.userSetFileName + " Into Memory"); @@ -87,7 +87,7 @@ private void openInMemory(SimResultsLoader simResultsLoader, RangeSelector range rangeSelector.endZ, rangeSelector.startT, rangeSelector.endT); long end = System.currentTimeMillis(); logger.debug("Loaded Virtual N5 File " + simResultsLoader.userSetFileName + " Into Memory taking: " + ((end - start)/ 1000) + "s"); - imagePlus.show(); + return imagePlus; } public void stopOpeningSimulation(String exportID){ @@ -145,9 +145,9 @@ public void notifySimIsLoading(SimResultsLoader simResultsLoader) { } @Override - public void notifySimIsDoneLoading(SimResultsLoader simResultsLoader) { + public void notifySimIsDoneLoading(SimResultsLoader simResultsLoader, ImagePlus imagePlus) { for (SimLoadingListener simLoadingListener: eventListenerList.getListeners(SimLoadingListener.class)){ - simLoadingListener.simFinishedLoading(simResultsLoader.rowNumber, simResultsLoader.exportID); + simLoadingListener.simFinishedLoading(simResultsLoader.rowNumber, simResultsLoader.exportID, imagePlus); } } } diff --git a/view-simulation-results/src/main/java/org/vcell/N5/retrieving/SimLoadingEventCreator.java b/view-simulation-results/src/main/java/org/vcell/N5/retrieving/SimLoadingEventCreator.java index 2a0a357..a69ac7e 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/retrieving/SimLoadingEventCreator.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/retrieving/SimLoadingEventCreator.java @@ -1,10 +1,12 @@ package org.vcell.N5.retrieving; +import ij.ImagePlus; + public interface SimLoadingEventCreator { public void addSimLoadingListener(SimLoadingListener simLoadingListener); public void notifySimIsLoading(SimResultsLoader simResultsLoader); - public void notifySimIsDoneLoading(SimResultsLoader simResultsLoader); + public void notifySimIsDoneLoading(SimResultsLoader simResultsLoader, ImagePlus imagePlus); } diff --git a/view-simulation-results/src/main/java/org/vcell/N5/retrieving/SimLoadingListener.java b/view-simulation-results/src/main/java/org/vcell/N5/retrieving/SimLoadingListener.java index d2ddf09..a53f46d 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/retrieving/SimLoadingListener.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/retrieving/SimLoadingListener.java @@ -1,11 +1,13 @@ package org.vcell.N5.retrieving; +import ij.ImagePlus; + import java.util.EventListener; public interface SimLoadingListener extends EventListener { public void simIsLoading(int itemRow, String exportID); - public void simFinishedLoading(int itemRow, String exportID); + public void simFinishedLoading(int itemRow, String exportID, ImagePlus imagePlus); }