diff --git a/src/main/java/bdv/AbstractViewerImgLoader.java b/src/main/java/bdv/AbstractViewerImgLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..fb1aad336b80a9cee1e5dac4462f3fe940aab85a --- /dev/null +++ b/src/main/java/bdv/AbstractViewerImgLoader.java @@ -0,0 +1,53 @@ +package bdv; + +import java.io.File; + +import mpicbg.spim.data.View; +import net.imglib2.RandomAccessibleInterval; +import net.imglib2.Volatile; +import net.imglib2.type.numeric.real.FloatType; + +import org.jdom2.Element; + +public abstract class AbstractViewerImgLoader< T, V extends Volatile< T > > implements ViewerImgLoader< T, V > +{ + protected final T type; + + protected final V volatileType; + + public AbstractViewerImgLoader( final T type, final V volatileType ) + { + this.type = type; + this.volatileType = volatileType; + } + + @Override + public T getImageType() + { + return type; + } + + @Override + public V getVolatileImageType() + { + return volatileType; + } + + @Override + public Element toXml( final File basePath ) + { + throw new UnsupportedOperationException( "not implemented" ); + } + + @Override + public RandomAccessibleInterval< FloatType > getFloatImage( final View view ) + { + throw new UnsupportedOperationException( "not implemented" ); + } + + @Override + public RandomAccessibleInterval< T > getImage( final View view ) + { + return getImage( view, 0 ); + } +} diff --git a/src/main/java/bdv/img/catmaid/CatmaidImageLoader.java b/src/main/java/bdv/img/catmaid/CatmaidImageLoader.java index 165c9fc28f3337e6804789032daeda5748f4ce02..f7b839f0e384667fa62859ae40f160e3d3ccde28 100644 --- a/src/main/java/bdv/img/catmaid/CatmaidImageLoader.java +++ b/src/main/java/bdv/img/catmaid/CatmaidImageLoader.java @@ -9,19 +9,18 @@ import net.imglib2.img.basictypeaccess.volatiles.array.VolatileIntArray; import net.imglib2.img.cell.CellImg; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.ARGBType; -import net.imglib2.type.numeric.real.FloatType; import net.imglib2.type.volatiles.VolatileARGBType; import org.jdom2.Element; -import bdv.ViewerImgLoader; +import bdv.AbstractViewerImgLoader; import bdv.img.cache.VolatileCell; import bdv.img.cache.VolatileGlobalCellCache; import bdv.img.cache.VolatileGlobalCellCache.LoadingStrategy; import bdv.img.cache.VolatileImgCells; import bdv.img.cache.VolatileImgCells.CellCache; -public class CatmaidImageLoader implements ViewerImgLoader< ARGBType, VolatileARGBType > +public class CatmaidImageLoader extends AbstractViewerImgLoader< ARGBType, VolatileARGBType > { private long width; @@ -49,6 +48,11 @@ public class CatmaidImageLoader implements ViewerImgLoader< ARGBType, VolatileAR protected VolatileGlobalCellCache< VolatileIntArray > cache; + public CatmaidImageLoader() + { + super( new ARGBType(), new VolatileARGBType() ); + } + @Override public void init( final Element elem, final File basePath ) { @@ -95,24 +99,6 @@ public class CatmaidImageLoader implements ViewerImgLoader< ARGBType, VolatileAR return i; } - @Override - public Element toXml( final File basePath ) - { - throw new UnsupportedOperationException( "not implemented" ); - } - - @Override - public RandomAccessibleInterval< FloatType > getFloatImage( final View view ) - { - throw new UnsupportedOperationException( "not implemented" ); - } - - @Override - public RandomAccessibleInterval< ARGBType > getImage( final View view ) - { - return getImage( view, 0 ); - } - @Override public RandomAccessibleInterval< ARGBType > getImage( final View view, final int level ) { @@ -164,21 +150,4 @@ public class CatmaidImageLoader implements ViewerImgLoader< ARGBType, VolatileAR { return cache; } - - private final ARGBType type = new ARGBType(); - - private final VolatileARGBType volatileType = new VolatileARGBType(); - - @Override - public ARGBType getImageType() - { - return type; - } - - @Override - public VolatileARGBType getVolatileImageType() - { - return volatileType; - } - } diff --git a/src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java b/src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java index 4191a14bad0fd8f7d83e2c1a10b0cdda169f365d..d339e6fdcd24e61741cd5651fbd5fc4a18ff9eb1 100644 --- a/src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java +++ b/src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java @@ -18,13 +18,12 @@ import net.imglib2.img.cell.CellImg; import net.imglib2.sampler.special.ConstantRandomAccessible; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.integer.UnsignedShortType; -import net.imglib2.type.numeric.real.FloatType; import net.imglib2.type.volatiles.VolatileUnsignedShortType; import net.imglib2.view.Views; import org.jdom2.Element; -import bdv.ViewerImgLoader; +import bdv.AbstractViewerImgLoader; import bdv.img.cache.VolatileCell; import bdv.img.cache.VolatileGlobalCellCache; import bdv.img.cache.VolatileGlobalCellCache.LoadingStrategy; @@ -34,7 +33,7 @@ import ch.systemsx.cisd.hdf5.HDF5DataSetInformation; import ch.systemsx.cisd.hdf5.HDF5Factory; import ch.systemsx.cisd.hdf5.IHDF5Reader; -public class Hdf5ImageLoader implements ViewerImgLoader< UnsignedShortType, VolatileUnsignedShortType > +public class Hdf5ImageLoader extends AbstractViewerImgLoader< UnsignedShortType, VolatileUnsignedShortType > { protected File hdf5File; @@ -84,6 +83,7 @@ public class Hdf5ImageLoader implements ViewerImgLoader< UnsignedShortType, Vola public Hdf5ImageLoader( final ArrayList< Partition > hdf5Partitions ) { + super( new UnsignedShortType(), new VolatileUnsignedShortType() ); hdf5File = null; hdf5Reader = null; cache = null; @@ -104,6 +104,7 @@ public class Hdf5ImageLoader implements ViewerImgLoader< UnsignedShortType, Vola public Hdf5ImageLoader( final File hdf5File, final ArrayList< Partition > hdf5Partitions, final boolean doOpen ) { + super( new UnsignedShortType(), new VolatileUnsignedShortType() ); this.hdf5File = hdf5File; perSetupMipmapResolutions = new ArrayList< double[][] >(); perSetupSubdivisions = new ArrayList< int[][] >(); @@ -219,18 +220,6 @@ public class Hdf5ImageLoader implements ViewerImgLoader< UnsignedShortType, Vola return partitions; } - @Override - public RandomAccessibleInterval< FloatType > getFloatImage( final View view ) - { - throw new UnsupportedOperationException( "currently not used" ); - } - - @Override - public RandomAccessibleInterval< UnsignedShortType > getImage( final View view ) - { - return getImage( view, 0 ); - } - @Override public RandomAccessibleInterval< UnsignedShortType > getImage( final View view, final int level ) { @@ -402,20 +391,4 @@ public class Hdf5ImageLoader implements ViewerImgLoader< UnsignedShortType, Vola } } } - - private final UnsignedShortType type = new UnsignedShortType(); - - private final VolatileUnsignedShortType volatileType = new VolatileUnsignedShortType(); - - @Override - public UnsignedShortType getImageType() - { - return type; - } - - @Override - public VolatileUnsignedShortType getVolatileImageType() - { - return volatileType; - } } diff --git a/src/main/java/bdv/img/remote/RemoteImageLoader.java b/src/main/java/bdv/img/remote/RemoteImageLoader.java index 6ae2a0bb8760456d04b1194beb05175e88a47a85..a34b4d4240b9825f8ab03a9b54a1168db06e1140 100644 --- a/src/main/java/bdv/img/remote/RemoteImageLoader.java +++ b/src/main/java/bdv/img/remote/RemoteImageLoader.java @@ -14,14 +14,13 @@ import net.imglib2.img.cell.CellImg; import net.imglib2.sampler.special.ConstantRandomAccessible; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.integer.UnsignedShortType; -import net.imglib2.type.numeric.real.FloatType; import net.imglib2.type.volatiles.VolatileUnsignedShortType; import net.imglib2.util.IntervalIndexer; import net.imglib2.view.Views; import org.jdom2.Element; -import bdv.ViewerImgLoader; +import bdv.AbstractViewerImgLoader; import bdv.img.cache.VolatileCell; import bdv.img.cache.VolatileGlobalCellCache; import bdv.img.cache.VolatileGlobalCellCache.LoadingStrategy; @@ -30,7 +29,7 @@ import bdv.img.cache.VolatileImgCells.CellCache; import com.google.gson.Gson; -public class RemoteImageLoader implements ViewerImgLoader< UnsignedShortType, VolatileUnsignedShortType > +public class RemoteImageLoader extends AbstractViewerImgLoader< UnsignedShortType, VolatileUnsignedShortType > { protected String baseUrl; @@ -40,6 +39,11 @@ public class RemoteImageLoader implements ViewerImgLoader< UnsignedShortType, Vo protected VolatileGlobalCellCache< VolatileShortArray > cache; + public RemoteImageLoader() + { + super( new UnsignedShortType(), new VolatileUnsignedShortType() ); + } + private void open() throws IOException { final URL url = new URL( baseUrl + "?p=init" ); @@ -70,24 +74,6 @@ public class RemoteImageLoader implements ViewerImgLoader< UnsignedShortType, Vo } } - @Override - public Element toXml( final File basePath ) - { - throw new UnsupportedOperationException( "not implemented" ); - } - - @Override - public RandomAccessibleInterval< FloatType > getFloatImage( final View view ) - { - throw new UnsupportedOperationException( "not implemented" ); - } - - @Override - public RandomAccessibleInterval< UnsignedShortType > getImage( final View view ) - { - return getImage( view, 0 ); - } - @Override public RandomAccessibleInterval< UnsignedShortType > getImage( final View view, final int level ) { @@ -221,20 +207,4 @@ public class RemoteImageLoader implements ViewerImgLoader< UnsignedShortType, Vo final CellImg< T, VolatileShortArray, VolatileCell< VolatileShortArray > > img = new CellImg< T, VolatileShortArray, VolatileCell< VolatileShortArray > >( null, cells ); return img; } - - private final UnsignedShortType type = new UnsignedShortType(); - - private final VolatileUnsignedShortType volatileType = new VolatileUnsignedShortType(); - - @Override - public UnsignedShortType getImageType() - { - return type; - } - - @Override - public VolatileUnsignedShortType getVolatileImageType() - { - return volatileType; - } }