Skip to content

adds Closeable interface to image loaders with a close method #142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import bdv.util.MipmapTransforms;
import ch.systemsx.cisd.hdf5.HDF5Factory;
import ch.systemsx.cisd.hdf5.IHDF5Reader;

import java.io.Closeable;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -76,7 +78,7 @@
import static bdv.img.hdf5.Util.getResolutionsPath;
import static bdv.img.hdf5.Util.getSubdivisionsPath;

public class Hdf5ImageLoader implements ViewerImgLoader, MultiResolutionImgLoader
public class Hdf5ImageLoader implements ViewerImgLoader, MultiResolutionImgLoader, Closeable
{
protected File hdf5File;

Expand Down Expand Up @@ -239,6 +241,7 @@ private void open()
* after {@link #close()} will cause the hdf5 file to be reopened (with a
* new cache).
*/
@Override
public void close()
{
if ( isOpen )
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/bdv/img/n5/N5ImageLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import bdv.img.cache.VolatileGlobalCellCache;
import bdv.util.ConstantRandomAccessible;
import bdv.util.MipmapTransforms;

import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
Expand Down Expand Up @@ -100,7 +102,7 @@
import static bdv.img.n5.BdvN5Format.DOWNSAMPLING_FACTORS_KEY;
import static bdv.img.n5.BdvN5Format.getPathName;

public class N5ImageLoader implements ViewerImgLoader, MultiResolutionImgLoader
public class N5ImageLoader implements ViewerImgLoader, MultiResolutionImgLoader, Closeable
{
private final File n5File;

Expand Down Expand Up @@ -192,6 +194,7 @@ private void open()
* after {@link #close()} will cause the n5 to be reopened (with a
* new cache).
*/
@Override
public void close()
{
if ( isOpen )
Expand Down