mirror of
https://github.com/paulscherrerinstitute/ch.psi.imagej.hdf5.git
synced 2025-04-20 05:00:03 +02:00
Improved dataset selection
This commit is contained in:
parent
8cbdbd5041
commit
966884310b
@ -18,6 +18,7 @@ import java.awt.*;
|
|||||||
|
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.DefaultListCellRenderer;
|
import javax.swing.DefaultListCellRenderer;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JList;
|
import javax.swing.JList;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@ -66,9 +67,9 @@ public class HDF5Reader implements PlugIn {
|
|||||||
file.open();
|
file.open();
|
||||||
|
|
||||||
List<Dataset> datasets = HDF5Utilities.getDatasets(file);
|
List<Dataset> datasets = HDF5Utilities.getDatasets(file);
|
||||||
List<Dataset> selectedDatasets = selectDatasets(datasets);
|
SelectedDatasets selectedDatasets = selectDatasets(datasets);
|
||||||
|
|
||||||
for (Dataset var : selectedDatasets) {
|
for (Dataset var : selectedDatasets.getDatasets()) {
|
||||||
|
|
||||||
// Read dataset attributes and properties
|
// Read dataset attributes and properties
|
||||||
String datasetName = var.getName();
|
String datasetName = var.getName();
|
||||||
@ -254,18 +255,20 @@ public class HDF5Reader implements PlugIn {
|
|||||||
* @return List of datasets to visualize. If nothing selected the list will be empty
|
* @return List of datasets to visualize. If nothing selected the list will be empty
|
||||||
* @throws HDF5Exception
|
* @throws HDF5Exception
|
||||||
*/
|
*/
|
||||||
private List<Dataset> selectDatasets(List<Dataset> datasets) throws HDF5Exception {
|
private SelectedDatasets selectDatasets(List<Dataset> datasets) throws HDF5Exception {
|
||||||
|
|
||||||
List<Dataset> selectedDatasets = new ArrayList<>();
|
|
||||||
GenericDialog gd = new GenericDialog("Variable Name Selection");
|
GenericDialog gd = new GenericDialog("Variable Name Selection");
|
||||||
gd.addMessage("Please select variables to be loaded.\n");
|
gd.addMessage("Please select variables to be loaded.\n");
|
||||||
|
|
||||||
if (datasets.size() < 1) {
|
// Filter datasets that are not potential images / that cannot be displayed
|
||||||
IJ.error("The file does not contain datasets");
|
List<Dataset> fdatasets = new ArrayList<Dataset>();
|
||||||
} else {
|
for(Dataset d: datasets){
|
||||||
|
if(d.getRank()>=2 && d.getRank()<=5){
|
||||||
|
fdatasets.add(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO only display datasets >= 2D
|
JList<Dataset> list = new JList<>(fdatasets.toArray(new Dataset[fdatasets.size()]));
|
||||||
JList<Dataset> list = new JList<>(datasets.toArray(new Dataset[datasets.size()]));
|
|
||||||
list.setCellRenderer(new DefaultListCellRenderer() {
|
list.setCellRenderer(new DefaultListCellRenderer() {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
@ -283,14 +286,8 @@ public class HDF5Reader implements PlugIn {
|
|||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
|
panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
|
||||||
panel.add(scroll);
|
panel.add(scroll);
|
||||||
// JPanel lpanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
JCheckBox checkbox = new JCheckBox("Group Datasets");
|
||||||
// lpanel.add(new JLabel("Too much entries - Please enter the full path of the dataset to be displayed"));
|
panel.add(checkbox);
|
||||||
// panel.add(lpanel);
|
|
||||||
// JPanel tpanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
||||||
// tpanel.add(new JLabel("Dataset: "));
|
|
||||||
// JTextField tfield = new JTextField("",60);
|
|
||||||
// tpanel.add(tfield);
|
|
||||||
// panel.add(tpanel);
|
|
||||||
|
|
||||||
gd = new GenericDialog("Variable Name Selection");
|
gd = new GenericDialog("Variable Name Selection");
|
||||||
gd.add(panel);
|
gd.add(panel);
|
||||||
@ -298,9 +295,10 @@ public class HDF5Reader implements PlugIn {
|
|||||||
gd.pack();
|
gd.pack();
|
||||||
gd.showDialog();
|
gd.showDialog();
|
||||||
|
|
||||||
|
SelectedDatasets selectedDatasets = new SelectedDatasets();
|
||||||
if (!gd.wasCanceled()) {
|
if (!gd.wasCanceled()) {
|
||||||
selectedDatasets = list.getSelectedValuesList();
|
selectedDatasets.setDatasets(list.getSelectedValuesList());
|
||||||
}
|
selectedDatasets.setGroup(checkbox.isSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectedDatasets;
|
return selectedDatasets;
|
||||||
|
26
src/main/java/ch/psi/imagej/hdf5/SelectedDatasets.java
Normal file
26
src/main/java/ch/psi/imagej/hdf5/SelectedDatasets.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package ch.psi.imagej.hdf5;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import ncsa.hdf.object.Dataset;
|
||||||
|
|
||||||
|
public class SelectedDatasets {
|
||||||
|
|
||||||
|
private List<Dataset> datasets = new ArrayList<Dataset>();
|
||||||
|
private boolean group = false;
|
||||||
|
|
||||||
|
public List<Dataset> getDatasets() {
|
||||||
|
return datasets;
|
||||||
|
}
|
||||||
|
public void setDatasets(List<Dataset> datasets) {
|
||||||
|
this.datasets = datasets;
|
||||||
|
}
|
||||||
|
public boolean isGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
public void setGroup(boolean group) {
|
||||||
|
this.group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user