mirror of
https://github.com/paulscherrerinstitute/ch.psi.imagej.hdf5.git
synced 2025-04-21 13:40:02 +02:00
tried to implement close of file CTRLHA-109
This commit is contained in:
parent
c46aa1f1ec
commit
9ab9b8b355
@ -213,7 +213,7 @@ public class HDF5Reader implements PlugIn {
|
||||
|
||||
if(selectedDatasets.isVirtualStack()){
|
||||
logger.info("Use virtual stack");
|
||||
stack = new VirtualStackHDF5(var);
|
||||
stack = new VirtualStackHDF5(file, var);
|
||||
}
|
||||
else{
|
||||
if(selectedDatasets.getSlice()!=null){
|
||||
|
@ -64,6 +64,7 @@ public class SelectionPanel extends JPanel {
|
||||
add(checkbox);
|
||||
|
||||
checkBoxVirtualStack = new JCheckBox("Virtual Stack");
|
||||
checkBoxVirtualStack.setSelected(true);
|
||||
add(checkBoxVirtualStack);
|
||||
|
||||
panel = new JPanel();
|
||||
|
@ -4,6 +4,7 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import ncsa.hdf.object.Dataset;
|
||||
import ncsa.hdf.object.h5.H5File;
|
||||
import ij.ImageStack;
|
||||
import ij.process.ByteProcessor;
|
||||
import ij.process.ColorProcessor;
|
||||
@ -18,10 +19,12 @@ public class VirtualStackHDF5 extends ImageStack {
|
||||
|
||||
private int bitDepth = 0;
|
||||
private Dataset dataset;
|
||||
private H5File file;
|
||||
|
||||
public VirtualStackHDF5(Dataset dataset){
|
||||
public VirtualStackHDF5(H5File file, Dataset dataset){
|
||||
super((int) dataset.getDims()[2], (int) dataset.getDims()[1]);
|
||||
this.dataset = dataset;
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
/** Does noting. */
|
||||
@ -154,4 +157,18 @@ public class VirtualStackHDF5 extends ImageStack {
|
||||
public int getBitDepth() {
|
||||
return bitDepth;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
|
||||
logger.info("Closing HDF5 file");
|
||||
try{
|
||||
file.close();
|
||||
}
|
||||
catch(Exception e){
|
||||
logger.log(Level.WARNING, "Unable to close HDF5 file", e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user