Skip to content
Snippets Groups Projects
Commit 2758832a authored by Tobias Pietzsch's avatar Tobias Pietzsch
Browse files

abstract base class for ViewerImgLoader implementations

parent bb7c085a
Branches
Tags
No related merge requests found
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 );
}
}
......@@ -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;
}
}
......@@ -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;
}
}
......@@ -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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment