diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 93263ca..7943feb 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,60 +21,9 @@ jobs: build: runs-on: ubuntu-latest - env: - AWS_ACCESS_KEY_ID: jj - AWS_SECRET_ACCESS_KEY: jj - AWS_DEFAULT_REGION: 'site2-low' - AWS_ENDPOINT_URL: "http://127.0.0.1:4000" - - - -# https://docs.github.com/en/actions/using-containerized-services/about-service-containers - services: - s3proxy: - image: andrewgaul/s3proxy - ports: - - 4000:80 - env: - JCLOUDS_FILESYSTEM_BASEDIR: /data - JCLOUDS_PROVIDER: filesystem - JCLOUDS_REGIONS: site2-low - S3PROXY_IDENTITY: jj - S3PROXY_CREDENTIAL: jj - - LOG_LEVEL: info - S3PROXY_ENDPOINT: http://0.0.0.0:80 - S3PROXY_AUTHORIZATION: "aws-v2-or-v4" - S3PROXY_VIRTUALHOST: "" - S3PROXY_KEYSTORE_PATH: keystore.jks - S3PROXY_KEYSTORE_PASSWORD: password - S3PROXY_CORS_ALLOW_ALL: false - S3PROXY_CORS_ALLOW_ORIGINS: "" - S3PROXY_CORS_ALLOW_METHODS: "" - S3PROXY_CORS_ALLOW_HEADERS: "" - S3PROXY_IGNORE_UNKNOWN_HEADERS: false - S3PROXY_ENCRYPTED_BLOBSTORE: "" - S3PROXY_ENCRYPTED_BLOBSTORE_PASSWORD: "" - S3PROXY_ENCRYPTED_BLOBSTORE_SALT: "" - - JCLOUDS_ENDPOINT: "" - JCLOUDS_REGION: "" - JCLOUDS_IDENTITY: remote-identity - JCLOUDS_CREDENTIAL: remote-credential - JCLOUDS_KEYSTONE_VERSION: "" - JCLOUDS_KEYSTONE_SCOPE: "" - JCLOUDS_KEYSTONE_PROJECT_DOMAIN_NAME: "" - volumes: - - /dockerImage/data:/data - steps: - uses: actions/checkout@v3 - - name: Put test resources in S3Proxy Container - run: | - aws s3 mb s3://nfive - aws s3 cp ${{ github.workspace }}/view-simulation-results/src/test/resources/nfive s3://nfive --recursive - - name: Set up JDK 8 uses: actions/setup-java@v3 with: @@ -82,10 +31,6 @@ jobs: distribution: 'temurin' cache: maven - #Before building the Repo a docker container needs to intialized such that the test cases can work properly -# https://github.com/addnab/docker-run-action - - - name: Build with Maven run: mvn -B package --file pom.xml diff --git a/view-simulation-results/src/main/java/org/vcell/N5/ExportDataRepresentation.java b/view-simulation-results/src/main/java/org/vcell/N5/ExportDataRepresentation.java index ac91c68..5e24112 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/ExportDataRepresentation.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/ExportDataRepresentation.java @@ -1,5 +1,6 @@ package org.vcell.N5; +import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.Stack; @@ -24,18 +25,20 @@ public FormatExportDataRepresentation(HashMap differentParameterValues; - public String savedFileName; + public final String exportDate; + public final String uri; + public final String jobID; + public final String dataID; + public final String simulationName; + public final String applicationName; + public final String biomodelName; + public final String variables; + public final String startAndEndTime; + + public final ArrayList differentParameterValues; + public final String savedFileName; + + public final ArrayList imageROIReferences; public int zSlices; public int tSlices; @@ -43,7 +46,7 @@ public static class SimulationExportDataRepresentation { public SimulationExportDataRepresentation(String exportDate, String uri, String jobID, String dataID, String simulationName, String applicationName, String biomodelName, String variables, String startAndEndTime, - ArrayList differentParameterValues, String savedFileName){ + ArrayList differentParameterValues, String savedFileName, ArrayList imageROIReferences){ this.exportDate = exportDate; this.uri = uri; this.jobID = jobID; @@ -55,6 +58,7 @@ public SimulationExportDataRepresentation(String exportDate, String uri, String this.startAndEndTime = startAndEndTime; this.differentParameterValues = differentParameterValues; this.savedFileName = savedFileName; + this.imageROIReferences = imageROIReferences; } } diff --git a/view-simulation-results/src/main/java/org/vcell/N5/UI/ControlButtonsPanel.java b/view-simulation-results/src/main/java/org/vcell/N5/UI/ControlButtonsPanel.java index ebbc9fb..17c3974 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/UI/ControlButtonsPanel.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/UI/ControlButtonsPanel.java @@ -22,7 +22,6 @@ public class ControlButtonsPanel extends JPanel implements ActionListener { // private final JButton openLocal = new JButton("Open N5 Local"); private final JButton questionMark; - public final JCheckBox includeExampleExports; public final JCheckBox displayAdvancedFeatures; private N5ExportTable n5ExportTable; @@ -31,9 +30,6 @@ public class ControlButtonsPanel extends JPanel implements ActionListener { private PanelState panelState = PanelState.NOTHING_OR_LOADING_IMAGE; public ControlButtonsPanel(){ - includeExampleExports = new JCheckBox("Show Example Exports"); - includeExampleExports.setSelected(!N5ImageHandler.exportedDataExists()); - displayAdvancedFeatures = new JCheckBox("Advanced Features"); openOrCancel = new JButton("Open Virtual Stack"); @@ -54,7 +50,6 @@ public ControlButtonsPanel(){ JPanel bottomRow = new JPanel(new GridBagLayout()); - bottomRow.add(includeExampleExports); gridBagConstraints.gridx = 1; bottomRow.add(displayAdvancedFeatures, gridBagConstraints); gridBagConstraints.gridx = 2; @@ -86,7 +81,6 @@ public ControlButtonsPanel(){ questionMark.addActionListener(this); advancedFeatures.useN5Link.addActionListener(this); // openLocal.addActionListener(this); - includeExampleExports.addActionListener(this); displayAdvancedFeatures.addActionListener(this); dataReduction.addActionListener(this); advancedFeatures.openInMemory.addActionListener(this); @@ -130,8 +124,6 @@ public void actionPerformed(ActionEvent e) { new HelpExplanation().displayHelpMenu(); } else if (e.getSource().equals(advancedFeatures.useN5Link)) { remoteFileSelection.setVisible(true); - } else if (e.getSource().equals(includeExampleExports)){ - n5ExportTable.updateTableData(); } else if (e.getSource().equals(displayAdvancedFeatures)) { advancedFeatures.setVisible(displayAdvancedFeatures.isSelected()); } diff --git a/view-simulation-results/src/main/java/org/vcell/N5/UI/Filters/TimeFilter.java b/view-simulation-results/src/main/java/org/vcell/N5/UI/Filters/TimeFilter.java index 6a29fd7..eb3152a 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/UI/Filters/TimeFilter.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/UI/Filters/TimeFilter.java @@ -57,10 +57,6 @@ public TimeFilter(){ public void actionPerformed(ActionEvent e) { if (e.getSource().equals(anyInterval) || e.getSource().equals(todayInterval) || e.getSource().equals(monthInterval) || e.getSource().equals(yearlyInterval)) { - if(MainPanel.controlButtonsPanel.includeExampleExports.isSelected()){ - n5ExportTable.updateTableData(); - return; - } n5ExportTable.updateTableData(); } } 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 ca79296..87bc0c5 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 @@ -9,8 +9,6 @@ import org.vcell.N5.retrieving.SimResultsLoader; import javax.swing.*; -import javax.swing.border.Border; -import javax.swing.border.EtchedBorder; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.table.AbstractTableModel; @@ -24,14 +22,16 @@ import java.util.*; import java.util.concurrent.TimeUnit; -public class N5ExportTable extends JScrollPane implements ListSelectionListener, SimLoadingListener { - public N5ExportTableModel n5ExportTableModel; +public class N5ExportTable extends JTabbedPane implements ListSelectionListener, SimLoadingListener { + private N5ExportTableModel n5ExportTableModel; private JTable exportListTable; - - private final Border lowerEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); - private final Border exampleBorder = BorderFactory.createTitledBorder(lowerEtchedBorder, "Example Exports"); + private JTable exampleExportListTable; private final Map loadingRowsJobID = new HashMap<>(); + private final JScrollPane personalExportsPanel = new JScrollPane(); + private final JScrollPane exampleExportsPanel = new JScrollPane(); + + private ControlButtonsPanel controlPanel; private ExportDetailsPanel exportDetailsPanel; private TimeFilter timeFilter; @@ -49,7 +49,12 @@ public void initialize(ControlButtonsPanel controlButtonsPanel, ExportDetailsPan N5ImageHandler.loadingManager.addSimLoadingListener(this); n5ExportTableModel = new N5ExportTableModel(); exportListTable = new JTable(n5ExportTableModel); - this.setViewportView(exportListTable); + exampleExportListTable = new JTable(n5ExportTableModel); + personalExportsPanel.setViewportView(exportListTable); + exampleExportsPanel.setViewportView(exampleExportListTable); + + this.addTab("Personal Exports", personalExportsPanel); + this.addTab("Example Exports", exampleExportsPanel); DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer(){ @@ -70,12 +75,14 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole int columns = n5ExportTableModel.getColumnCount(); for (int i = 0; i < columns; i++){ exportListTable.getColumnModel().getColumn(i).setCellRenderer(cellRenderer); + exampleExportListTable.getColumnModel().getColumn(i).setCellRenderer(cellRenderer); } this.setPreferredSize(new Dimension(500, 400)); - this.setBorder(BorderFactory.createTitledBorder(lowerEtchedBorder, "Export Table")); exportListTable.getSelectionModel().addListSelectionListener(this); + exampleExportListTable.getSelectionModel().addListSelectionListener(this); + this.setSelectedIndex(N5ImageHandler.exportedDataExists() ? 0 : 1); updateTableData(""); automaticRefresh(); } @@ -95,13 +102,9 @@ public void updateTableData(String strFilter){ void updateTableData(LocalDateTime oldestTimeAllowed, String strFilter){ n5ExportTableModel.resetData(); - if (!controlPanel.includeExampleExports.isSelected()){ - this.setBorder(BorderFactory.createTitledBorder(lowerEtchedBorder, "Personal Exports")); - } else { - this.setBorder(exampleBorder); - } try { - ExportDataRepresentation.FormatExportDataRepresentation formatExportData = N5ImageHandler.exportedDataExists() && !controlPanel.includeExampleExports.isSelected() ? + boolean hasPersonalExports = N5ImageHandler.exportedDataExists() && this.getSelectedIndex() == 0; + ExportDataRepresentation.FormatExportDataRepresentation formatExportData = hasPersonalExports ? N5ImageHandler.getJsonData() : N5ImageHandler.getExampleJSONData(); Stack jobStack = (Stack) formatExportData.formatJobIDs.clone(); @@ -123,7 +126,7 @@ private void automaticRefresh(){ try { while(true){ ExportDataRepresentation.FormatExportDataRepresentation formatExportData = N5ImageHandler.getJsonData(); - if (formatExportData != null && !controlPanel.includeExampleExports.isSelected()){ + if (formatExportData != null && this.getSelectedIndex() == 0){ ExportDataRepresentation.SimulationExportDataRepresentation mostRecentTableEntry = !n5ExportTableModel.tableData.isEmpty() ? n5ExportTableModel.tableData.getFirst() : null; Stack jobStack = formatExportData.formatJobIDs; boolean isUpdated = false; @@ -156,10 +159,11 @@ private void automaticRefresh(){ public void openSelectedRows(boolean openInMemory, boolean performDataReduction, SimResultsLoader.OpenTag openTag){ ArrayList filesToOpen = new ArrayList<>(); - for(int row: exportListTable.getSelectedRows()){ + JTable currentTable = getCurrentTable(); + for(int row: currentTable.getSelectedRows()){ String uri = n5ExportTableModel.getRowData(row).uri; ExportDataRepresentation.SimulationExportDataRepresentation rowData = n5ExportTableModel.getRowData(row); - SimResultsLoader simResultsLoader = new SimResultsLoader(uri, rowData.savedFileName, row, rowData.jobID, openTag); + SimResultsLoader simResultsLoader = new SimResultsLoader(uri, rowData.savedFileName, row, rowData.jobID, openTag, rowData.imageROIReferences); filesToOpen.add(simResultsLoader); } N5ImageHandler.loadingManager.openN5FileDataset(filesToOpen, openInMemory, @@ -167,7 +171,8 @@ public void openSelectedRows(boolean openInMemory, boolean performDataReduction, } public void copySelectedRowLink(){ - ExportDataRepresentation.SimulationExportDataRepresentation selectedRow = n5ExportTableModel.getRowData(exportListTable.getSelectedRow()); + JTable currentTable = getCurrentTable(); + ExportDataRepresentation.SimulationExportDataRepresentation selectedRow = n5ExportTableModel.getRowData(currentTable.getSelectedRow()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(new StringSelection(selectedRow.uri), null); } @@ -192,9 +197,10 @@ else if (n5ExportTableModel.getRowData(currentRow).jobID.equals(expectedJobID) & @Override public void valueChanged(ListSelectionEvent e) { - int row = exportListTable.getSelectedRow(); + JTable currentTable = getCurrentTable(); + int row = currentTable.getSelectedRow(); exportDetailsPanel.resetExportDetails(); - if (row > exportListTable.getRowCount() || row < 0){ + if (row > currentTable.getRowCount() || row < 0){ controlPanel.disableAllContextDependentButtons(); return; } @@ -206,24 +212,33 @@ public void valueChanged(ListSelectionEvent e) { controlPanel.updateButtonsToMatchState(loadingRow != -1); } + @Override + public void setSelectedIndex(int index) { + super.setSelectedIndex(index); + updateTableData(); + } + public void stopSelectedImageFromLoading(){ - int row = exportListTable.getSelectedRow(); + JTable currentTable = getCurrentTable(); + int row = currentTable.getSelectedRow(); N5ImageHandler.loadingManager.stopLoadingImage(n5ExportTableModel.tableData.get(row).jobID); loadingRowsJobID.remove(row); - exportListTable.repaint(); + currentTable.repaint(); } public void removeSpecificRowFromLoadingRows(int rowNumber){ + JTable currentTable = getCurrentTable(); int realRowNumber = findLoadingRow(rowNumber, rowNumber); loadingRowsJobID.remove(realRowNumber); controlPanel.updateButtonsToMatchState(false); - exportListTable.repaint(); + currentTable.repaint(); } @Override public void simIsLoading(int itemRow, String exportID) { + JTable currentTable = getCurrentTable(); loadingRowsJobID.put(itemRow, exportID); - exportListTable.repaint(); + currentTable.repaint(); } @Override @@ -234,6 +249,18 @@ public void simFinishedLoading(SimResultsLoader loadedResults) { } } + /** + * Required, for there is one table for examples and another for personal exports. The same table + * can not be used for both tabs, because a JComponent can have only one parent. + */ + private JTable getCurrentTable(){ + return this.getSelectedIndex() == 0 ? exportListTable : exampleExportListTable; + } + + public N5ExportTableModel getN5ExportTableModel(){ + return n5ExportTableModel; + } + public static class N5ExportTableModel extends AbstractTableModel { public final ArrayList headers = new ArrayList(){{ add("BioModel"); 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 eadf2bd..a283a0f 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 @@ -95,7 +95,7 @@ public String getS3URL(){ @Override public void actionPerformed(ActionEvent e) { - SimResultsLoader simResultsLoader = new SimResultsLoader(getS3URL(), "", -1, "", SimResultsLoader.OpenTag.VIEW); + SimResultsLoader simResultsLoader = new SimResultsLoader(getS3URL(), "", -1, "", SimResultsLoader.OpenTag.VIEW, new ArrayList<>()); N5ImageHandler.loadingManager.openN5FileDataset(new ArrayList(){{add(simResultsLoader);}}, false, false); diff --git a/view-simulation-results/src/main/java/org/vcell/N5/reduction/DataReductionWriter.java b/view-simulation-results/src/main/java/org/vcell/N5/reduction/DataReductionWriter.java index 65c5509..ab9cde6 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/reduction/DataReductionWriter.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/reduction/DataReductionWriter.java @@ -141,7 +141,7 @@ public void initializeDataSheets(){ public void addMetaData(SimResultsLoader loadedResults){ synchronized (metaDataLock){ N5ExportTable n5ExportTable = MainPanel.n5ExportTable; - ExportDataRepresentation.SimulationExportDataRepresentation data = n5ExportTable.n5ExportTableModel.getRowData(loadedResults.rowNumber); + ExportDataRepresentation.SimulationExportDataRepresentation data = n5ExportTable.getN5ExportTableModel().getRowData(loadedResults.rowNumber); ArrayList newMetaData = new ArrayList<>(); newMetaData.add(loadedResults.userSetFileName); newMetaData.add(data.biomodelName); diff --git a/view-simulation-results/src/main/java/org/vcell/N5/reduction/GUI/AvailableROIs.java b/view-simulation-results/src/main/java/org/vcell/N5/reduction/GUI/AvailableROIs.java new file mode 100644 index 0000000..1fbca07 --- /dev/null +++ b/view-simulation-results/src/main/java/org/vcell/N5/reduction/GUI/AvailableROIs.java @@ -0,0 +1,89 @@ +package org.vcell.N5.reduction.GUI; + +import ij.gui.Roi; +import ij.plugin.frame.RoiManager; + +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Arrays; + +public class AvailableROIs extends JDialog implements ActionListener { + private final JButton okayButton = new JButton("Okay"); + private final JButton cancelButton = new JButton("Cancel"); + private final ROIDataModel roiDataModel = new ROIDataModel(); + private final JTable table = new JTable(roiDataModel); + private int[] selectedRows = new int[0]; + + public AvailableROIs(){ + JScrollPane scrollPane = new JScrollPane(table); + + JPanel buttonPanel = new JPanel(); + okayButton.addActionListener(this); + cancelButton.addActionListener(this); + buttonPanel.add(okayButton); + buttonPanel.add(cancelButton); + + this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS)); + + this.add(scrollPane); + this.add(buttonPanel); + this.setSize(300, 300); + this.setModal(true); + this.setVisible(true); + + + } + + public ArrayList getSelectedRows(){ + ArrayList selectedRois = new ArrayList<>(); + for (int selectedRow : selectedRows){ + selectedRois.add(roiDataModel.rois.get(selectedRow)); + } + return selectedRois; + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(okayButton)){ + selectedRows = table.getSelectedRows(); + this.dispose(); + } else if (e.getSource().equals(cancelButton)){ + this.dispose(); + } + } + + private static class ROIDataModel extends DefaultTableModel{ + private final ArrayList rois; + public ROIDataModel(){ + rois = new ArrayList<>(); + rois.addAll(Arrays.asList(RoiManager.getRoiManager().getRoisAsArray())); + } + + @Override + public int getRowCount() { + if (rois == null){ + return 0; + } + return rois.size(); + } + + @Override + public String getColumnName(int column) { + return "Available ROI's From ROI Manager"; + } + + @Override + public int getColumnCount() { + return 1; + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + return rois.get(rowIndex).getName(); + } + } + +} diff --git a/view-simulation-results/src/main/java/org/vcell/N5/reduction/GUI/RoiSelection.java b/view-simulation-results/src/main/java/org/vcell/N5/reduction/GUI/RoiSelection.java index 731ded8..4b167f9 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/reduction/GUI/RoiSelection.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/reduction/GUI/RoiSelection.java @@ -2,6 +2,7 @@ import ij.gui.Roi; import ij.io.RoiDecoder; +import ij.plugin.frame.RoiManager; import javax.swing.*; import java.awt.*; @@ -25,7 +26,7 @@ public RoiSelection(DataReductionGUI parentGUI){ JList simROITable = new JList<>(simTableModel); JFileChooser simROIFileChooser = new JFileChooser(); this.add(createROIInput(simROITable, simTableModel, simROIFileChooser, "Sim")); - this.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Apply 2D ROI Files")); + this.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Apply ROI")); this.parentGUI = parentGUI; } @@ -41,7 +42,8 @@ private JPanel createROIInput(JList jList, ROIDataModel roiDataModel, addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - ArrayList roiList = fillROIList(fileChooser); + AvailableROIs availableROIs = new AvailableROIs(); + ArrayList roiList = availableROIs.getSelectedRows(); for (Roi roi : roiList){ roiDataModel.addRow(roi); } diff --git a/view-simulation-results/src/main/java/org/vcell/N5/retrieving/SimResultsLoader.java b/view-simulation-results/src/main/java/org/vcell/N5/retrieving/SimResultsLoader.java index c005edf..94a4f1e 100644 --- a/view-simulation-results/src/main/java/org/vcell/N5/retrieving/SimResultsLoader.java +++ b/view-simulation-results/src/main/java/org/vcell/N5/retrieving/SimResultsLoader.java @@ -10,11 +10,15 @@ import com.google.gson.GsonBuilder; import com.google.gson.internal.LinkedTreeMap; import ij.ImagePlus; +import ij.gui.Roi; +import ij.io.RoiDecoder; import ij.plugin.ContrastEnhancer; import ij.plugin.Duplicator; +import ij.plugin.frame.RoiManager; import net.imglib2.cache.img.CachedCellImg; import net.imglib2.img.display.imagej.ImageJFunctions; import net.imglib2.type.numeric.real.DoubleType; +import org.apache.commons.io.IOUtils; import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.ssl.SSLContexts; @@ -32,10 +36,9 @@ import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; -import java.io.File; -import java.io.IOException; -import java.io.UnsupportedEncodingException; +import java.io.*; import java.net.URI; +import java.net.URL; import java.net.URLDecoder; import java.security.KeyManagementException; import java.security.KeyStoreException; @@ -45,6 +48,7 @@ public class SimResultsLoader { private File selectedLocalFile; + private ArrayList roiReferences; private URI uri; private String dataSetChosen; private static final String defaultS3Region = "site2-low"; @@ -62,11 +66,14 @@ public class SimResultsLoader { public SimResultsLoader(){ openTag = OpenTag.TEST; } - public SimResultsLoader(String stringURI, String userSetFileName, int rowNumber, String exportID, OpenTag openTag){ + public SimResultsLoader(String stringURI, String userSetFileName, int rowNumber, String exportID, OpenTag openTag, ArrayList roiReference){ this(stringURI, userSetFileName, openTag); this.rowNumber = rowNumber; this.exportID = exportID; + this.roiReferences = roiReference; } + + // Mostly for tests public SimResultsLoader(String stringURI, String userSetFileName, OpenTag openTag){ uri = URI.create(stringURI); this.userSetFileName = userSetFileName; @@ -165,6 +172,22 @@ public void loadImageFromN5File() { imagePlus.setZ(Math.floorDiv(imagePlus.getNSlices(), 2)); imagePlus.setT(Math.floorDiv(imagePlus.getNFrames(), 2)); + // There is ROI's referenced with this image + if (roiReferences != null){ + for (URL roiReference : roiReferences){ + try (InputStream input = roiReference.openStream()) { + final File tempFile = File.createTempFile("imagej-roi", "tmp"); + try (FileOutputStream out = new FileOutputStream(tempFile)) { + IOUtils.copy(input, out); + } + Roi roi = RoiDecoder.open(tempFile.getAbsolutePath()); + imagePlus.setRoi(roi); + tempFile.delete(); + } catch (IOException e) { + logger.debug("Can't open stream to roi reference: " + roiReference); + } + } + } new ContrastEnhancer().stretchHistogram(imagePlus, 1); }