Skip to content
Snippets Groups Projects
Unverified Commit b77745a2 authored by Tobias Pietzsch's avatar Tobias Pietzsch Committed by GitHub
Browse files

Merge pull request #37 from bigdataviewer/volatiletypes

add missing primitive volatile types
parents 63282d7a 9bb84f91
No related branches found
No related tags found
No related merge requests found
......@@ -7,13 +7,13 @@
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
......@@ -573,7 +573,7 @@ public class BigDataViewer
return false;
}
protected void saveSettings()
public void saveSettings()
{
fileChooser.setSelectedFile( proposedSettingsFile );
final int returnVal = fileChooser.showSaveDialog( null );
......@@ -654,7 +654,7 @@ public class BigDataViewer
return conf;
}
protected void loadSettings()
public void loadSettings()
{
fileChooser.setSelectedFile( proposedSettingsFile );
final int returnVal = fileChooser.showOpenDialog( null );
......
/*
* #%L
* BigDataViewer core classes with minimal dependencies
* %%
* Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch,
* Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package net.imglib2.type.volatiles;
import net.imglib2.Volatile;
import net.imglib2.img.NativeImg;
import net.imglib2.img.NativeImgFactory;
import net.imglib2.img.basictypeaccess.ByteAccess;
import net.imglib2.img.basictypeaccess.volatiles.VolatileByteAccess;
import net.imglib2.img.basictypeaccess.volatiles.array.VolatileByteArray;
import net.imglib2.type.numeric.integer.ByteType;
import net.imglib2.util.Fraction;
/**
* A {@link Volatile} variant of {@link ByteType}. It uses an
* underlying {@link ByteType} that maps into a
* {@link VolatileByteAccess}.
*
* @author Stephan Saalfeld
*/
public class VolatileByteType extends AbstractVolatileNativeRealType< ByteType, VolatileByteType >
{
final protected NativeImg< ?, ? extends VolatileByteAccess > img;
private static class WrappedByteType extends ByteType
{
public WrappedByteType( final NativeImg<?, ? extends ByteAccess> img )
{
super( img );
}
public WrappedByteType( final ByteAccess access )
{
super( access );
}
public void setAccess( final ByteAccess access )
{
dataAccess = access;
}
}
// this is the constructor if you want it to read from an array
public VolatileByteType( final NativeImg< ?, ? extends VolatileByteAccess > img )
{
super( new WrappedByteType( img ), false );
this.img = img;
}
// this is the constructor if you want to specify the dataAccess
public VolatileByteType( final VolatileByteAccess access )
{
super( new WrappedByteType( access ), access.isValid() );
this.img = null;
}
// this is the constructor if you want it to be a variable
public VolatileByteType( final byte value )
{
this( new VolatileByteArray( 1, true ) );
set( value );
}
// this is the constructor if you want it to be a variable
public VolatileByteType()
{
this( ( byte )0 );
}
public void set( final byte value )
{
get().set( value );
}
@Override
public void updateContainer( final Object c )
{
final VolatileByteAccess a = img.update( c );
( (WrappedByteType) t ).setAccess( a );
setValid( a.isValid() );
}
@Override
public NativeImg< VolatileByteType, ? extends VolatileByteAccess > createSuitableNativeImg( final NativeImgFactory< VolatileByteType > storageFactory, final long[] dim )
{
// create the container
@SuppressWarnings( "unchecked" )
final NativeImg< VolatileByteType, ? extends VolatileByteAccess > container = ( NativeImg< VolatileByteType, ? extends VolatileByteAccess > ) storageFactory.createByteInstance( dim, new Fraction() );
// create a Type that is linked to the container
final VolatileByteType linkedType = new VolatileByteType( container );
// pass it to the NativeContainer
container.setLinkedType( linkedType );
return container;
}
@Override
public VolatileByteType duplicateTypeOnSameNativeImg()
{
return new VolatileByteType( img );
}
@Override
public VolatileByteType createVariable()
{
return new VolatileByteType();
}
@Override
public VolatileByteType copy()
{
final VolatileByteType v = createVariable();
v.set( this );
return v;
}
}
/*
* #%L
* BigDataViewer core classes with minimal dependencies
* %%
* Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch,
* Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package net.imglib2.type.volatiles;
import net.imglib2.Volatile;
import net.imglib2.img.NativeImg;
import net.imglib2.img.NativeImgFactory;
import net.imglib2.img.basictypeaccess.DoubleAccess;
import net.imglib2.img.basictypeaccess.volatiles.VolatileDoubleAccess;
import net.imglib2.img.basictypeaccess.volatiles.array.VolatileDoubleArray;
import net.imglib2.type.numeric.real.DoubleType;
import net.imglib2.util.Fraction;
/**
* A {@link Volatile} variant of {@link DoubleType}. It uses an
* underlying {@link DoubleType} that maps into a
* {@link VolatileDoubleAccess}.
*
* @author Stephan Saalfeld
*/
public class VolatileDoubleType extends AbstractVolatileNativeRealType< DoubleType, VolatileDoubleType >
{
final protected NativeImg< ?, ? extends VolatileDoubleAccess > img;
private static class WrappedDoubleType extends DoubleType
{
public WrappedDoubleType( final NativeImg<?, ? extends DoubleAccess> img )
{
super( img );
}
public WrappedDoubleType( final DoubleAccess access )
{
super( access );
}
public void setAccess( final DoubleAccess access )
{
dataAccess = access;
}
}
// this is the constructor if you want it to read from an array
public VolatileDoubleType( final NativeImg< ?, ? extends VolatileDoubleAccess > img )
{
super( new WrappedDoubleType( img ), false );
this.img = img;
}
// this is the constructor if you want to specify the dataAccess
public VolatileDoubleType( final VolatileDoubleAccess access )
{
super( new WrappedDoubleType( access ), access.isValid() );
this.img = null;
}
// this is the constructor if you want it to be a variable
public VolatileDoubleType( final double value )
{
this( new VolatileDoubleArray( 1, true ) );
set( value );
}
// this is the constructor if you want it to be a variable
public VolatileDoubleType()
{
this( 0 );
}
public void set( final double value )
{
get().set( value );
}
@Override
public void updateContainer( final Object c )
{
final VolatileDoubleAccess a = img.update( c );
( ( WrappedDoubleType )t ).setAccess( a );
setValid( a.isValid() );
}
@Override
public NativeImg< VolatileDoubleType, ? extends VolatileDoubleAccess > createSuitableNativeImg( final NativeImgFactory< VolatileDoubleType > storageFactory, final long[] dim )
{
// create the container
@SuppressWarnings( "unchecked" )
final NativeImg< VolatileDoubleType, ? extends VolatileDoubleAccess > container = ( NativeImg< VolatileDoubleType, ? extends VolatileDoubleAccess > ) storageFactory.createDoubleInstance( dim, new Fraction() );
// create a Type that is linked to the container
final VolatileDoubleType linkedType = new VolatileDoubleType( container );
// pass it to the NativeContainer
container.setLinkedType( linkedType );
return container;
}
@Override
public VolatileDoubleType duplicateTypeOnSameNativeImg()
{
return new VolatileDoubleType( img );
}
@Override
public VolatileDoubleType createVariable()
{
return new VolatileDoubleType();
}
@Override
public VolatileDoubleType copy()
{
final VolatileDoubleType v = createVariable();
v.set( this );
return v;
}
}
......@@ -29,6 +29,7 @@
*/
package net.imglib2.type.volatiles;
import net.imglib2.Volatile;
import net.imglib2.img.NativeImg;
import net.imglib2.img.NativeImgFactory;
import net.imglib2.img.basictypeaccess.FloatAccess;
......@@ -37,6 +38,13 @@ import net.imglib2.img.basictypeaccess.volatiles.array.VolatileFloatArray;
import net.imglib2.type.numeric.real.FloatType;
import net.imglib2.util.Fraction;
/**
* A {@link Volatile} variant of {@link FloatType}. It uses an
* underlying {@link FloatType} that maps into a
* {@link VolatileFloatAccess}.
*
* @author Stephan Saalfeld
*/
public class VolatileFloatType extends AbstractVolatileNativeRealType< FloatType, VolatileFloatType >
{
final protected NativeImg< ?, ? extends VolatileFloatAccess > img;
......
/*
* #%L
* BigDataViewer core classes with minimal dependencies
* %%
* Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch,
* Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package net.imglib2.type.volatiles;
import net.imglib2.Volatile;
import net.imglib2.img.NativeImg;
import net.imglib2.img.NativeImgFactory;
import net.imglib2.img.basictypeaccess.IntAccess;
import net.imglib2.img.basictypeaccess.volatiles.VolatileIntAccess;
import net.imglib2.img.basictypeaccess.volatiles.array.VolatileIntArray;
import net.imglib2.type.numeric.integer.IntType;
import net.imglib2.util.Fraction;
/**
* A {@link Volatile} variant of {@link IntType}. It uses an
* underlying {@link IntType} that maps into a
* {@link VolatileIntAccess}.
*
* @author Stephan Saalfeld
*/
public class VolatileIntType extends AbstractVolatileNativeRealType< IntType, VolatileIntType >
{
final protected NativeImg< ?, ? extends VolatileIntAccess > img;
private static class WrappedIntType extends IntType
{
public WrappedIntType( final NativeImg<?, ? extends IntAccess> img )
{
super( img );
}
public WrappedIntType( final IntAccess access )
{
super( access );
}
public void setAccess( final IntAccess access )
{
dataAccess = access;
}
}
// this is the constructor if you want it to read from an array
public VolatileIntType( final NativeImg< ?, ? extends VolatileIntAccess > img )
{
super( new WrappedIntType( img ), false );
this.img = img;
}
// this is the constructor if you want to specify the dataAccess
public VolatileIntType( final VolatileIntAccess access )
{
super( new WrappedIntType( access ), access.isValid() );
this.img = null;
}
// this is the constructor if you want it to be a variable
public VolatileIntType( final int value )
{
this( new VolatileIntArray( 1, true ) );
set( value );
}
// this is the constructor if you want it to be a variable
public VolatileIntType()
{
this( 0 );
}
public void set( final int value )
{
get().set( value );
}
@Override
public void updateContainer( final Object c )
{
final VolatileIntAccess a = img.update( c );
( (WrappedIntType) t ).setAccess( a );
setValid( a.isValid() );
}
@Override
public NativeImg< VolatileIntType, ? extends VolatileIntAccess > createSuitableNativeImg( final NativeImgFactory< VolatileIntType > storageFactory, final long[] dim )
{
// create the container
@SuppressWarnings( "unchecked" )
final NativeImg< VolatileIntType, ? extends VolatileIntAccess > container = ( NativeImg< VolatileIntType, ? extends VolatileIntAccess > ) storageFactory.createIntInstance( dim, new Fraction() );
// create a Type that is linked to the container
final VolatileIntType linkedType = new VolatileIntType( container );
// pass it to the NativeContainer
container.setLinkedType( linkedType );
return container;
}
@Override
public VolatileIntType duplicateTypeOnSameNativeImg()
{
return new VolatileIntType( img );
}
@Override
public VolatileIntType createVariable()
{
return new VolatileIntType();
}
@Override
public VolatileIntType copy()
{
final VolatileIntType v = createVariable();
v.set( this );
return v;
}
}
/*
* #%L
* BigDataViewer core classes with minimal dependencies
* %%
* Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch,
* Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package net.imglib2.type.volatiles;
import net.imglib2.Volatile;
import net.imglib2.img.NativeImg;
import net.imglib2.img.NativeImgFactory;
import net.imglib2.img.basictypeaccess.LongAccess;
import net.imglib2.img.basictypeaccess.volatiles.VolatileLongAccess;
import net.imglib2.img.basictypeaccess.volatiles.array.VolatileLongArray;
import net.imglib2.type.numeric.integer.LongType;
import net.imglib2.util.Fraction;
/**
* A {@link Volatile} variant of {@link LongType}. It uses an
* underlying {@link LongType} that maps into a
* {@link VolatileLongAccess}.
*
* @author Stephan Saalfeld
*/
public class VolatileLongType extends AbstractVolatileNativeRealType< LongType, VolatileLongType >
{
final protected NativeImg< ?, ? extends VolatileLongAccess > img;
private static class WrappedLongType extends LongType
{
public WrappedLongType( final NativeImg<?, ? extends LongAccess> img )
{
super( img );
}
public WrappedLongType( final LongAccess access )
{
super( access );
}
public void setAccess( final LongAccess access )
{
dataAccess = access;
}
}
// this is the constructor if you want it to read from an array
public VolatileLongType( final NativeImg< ?, ? extends VolatileLongAccess > img )
{
super( new WrappedLongType( img ), false );
this.img = img;
}
// this is the constructor if you want to specify the dataAccess
public VolatileLongType( final VolatileLongAccess access )
{
super( new WrappedLongType( access ), access.isValid() );
this.img = null;
}
// this is the constructor if you want it to be a variable
public VolatileLongType( final long value )
{
this( new VolatileLongArray( 1, true ) );
set( value );
}
// this is the constructor if you want it to be a variable
public VolatileLongType()
{
this( 0 );
}
public void set( final long value )
{
get().set( value );
}
@Override
public void updateContainer( final Object c )
{
final VolatileLongAccess a = img.update( c );
( (WrappedLongType) t ).setAccess( a );
setValid( a.isValid() );
}
@Override
public NativeImg< VolatileLongType, ? extends VolatileLongAccess > createSuitableNativeImg( final NativeImgFactory< VolatileLongType > storageFactory, final long[] dim )
{
// create the container
@SuppressWarnings( "unchecked" )
final NativeImg< VolatileLongType, ? extends VolatileLongAccess > container = ( NativeImg< VolatileLongType, ? extends VolatileLongAccess > ) storageFactory.createLongInstance( dim, new Fraction() );
// create a Type that is linked to the container
final VolatileLongType linkedType = new VolatileLongType( container );
// pass it to the NativeContainer
container.setLinkedType( linkedType );
return container;
}
@Override
public VolatileLongType duplicateTypeOnSameNativeImg()
{
return new VolatileLongType( img );
}
@Override
public VolatileLongType createVariable()
{
return new VolatileLongType();
}
@Override
public VolatileLongType copy()
{
final VolatileLongType v = createVariable();
v.set( this );
return v;
}
}
/*
* #%L
* BigDataViewer core classes with minimal dependencies
* %%
* Copyright (C) 2012 - 2016 Tobias Pietzsch, Stephan Saalfeld, Stephan Preibisch,
* Jean-Yves Tinevez, HongKee Moon, Johannes Schindelin, Curtis Rueden, John Bogovic
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* #L%
*/
package net.imglib2.type.volatiles;
import net.imglib2.Volatile;
import net.imglib2.img.NativeImg;
import net.imglib2.img.NativeImgFactory;
import net.imglib2.img.basictypeaccess.IntAccess;
import net.imglib2.img.basictypeaccess.volatiles.VolatileIntAccess;
import net.imglib2.img.basictypeaccess.volatiles.array.VolatileIntArray;
import net.imglib2.type.numeric.integer.UnsignedIntType;
import net.imglib2.util.Fraction;
/**
* A {@link Volatile} variant of {@link UnsignedIntType}. It uses an underlying
* {@link UnsignedIntType} that maps into a {@link VolatileIntAccess}.
*
* @author Stephan Saalfeld
*/
public class VolatileUnsignedIntType extends AbstractVolatileNativeRealType< UnsignedIntType, VolatileUnsignedIntType >
{
final protected NativeImg< ?, ? extends VolatileIntAccess > img;
private static class WrappedUnsignedIntType extends UnsignedIntType
{
public WrappedUnsignedIntType( final NativeImg<?, ? extends IntAccess> img )
{
super( img );
}
public WrappedUnsignedIntType( final IntAccess access )
{
super( access );
}
public void setAccess( final IntAccess access )
{
dataAccess = access;
}
}
// this is the constructor if you want it to read from an array
public VolatileUnsignedIntType( final NativeImg< ?, ? extends VolatileIntAccess > img )
{
super( new WrappedUnsignedIntType( img ), false );
this.img = img;
}
// this is the constructor if you want to specify the dataAccess
public VolatileUnsignedIntType( final VolatileIntAccess access )
{
super( new WrappedUnsignedIntType( access ), access.isValid() );
this.img = null;
}
// this is the constructor if you want it to be a variable
public VolatileUnsignedIntType( final int value )
{
this( new VolatileIntArray( 1, true ) );
set( value );
}
// this is the constructor if you want it to be a variable
public VolatileUnsignedIntType()
{
this( 0 );
}
public void set( final int value )
{
get().set( value );
}
@Override
public void updateContainer( final Object c )
{
final VolatileIntAccess a = img.update( c );
( ( WrappedUnsignedIntType ) t ).setAccess( a );
setValid( a.isValid() );
}
@Override
public NativeImg< VolatileUnsignedIntType, ? extends VolatileIntAccess > createSuitableNativeImg( final NativeImgFactory< VolatileUnsignedIntType > storageFactory, final long[] dim )
{
// create the container
@SuppressWarnings( "unchecked" )
final NativeImg< VolatileUnsignedIntType, ? extends VolatileIntAccess > container = ( NativeImg< VolatileUnsignedIntType, ? extends VolatileIntAccess > ) storageFactory.createIntInstance( dim, new Fraction() );
// create a Type that is linked to the container
final VolatileUnsignedIntType linkedType = new VolatileUnsignedIntType( container );
// pass it to the NativeContainer
container.setLinkedType( linkedType );
return container;
}
@Override
public VolatileUnsignedIntType duplicateTypeOnSameNativeImg()
{
return new VolatileUnsignedIntType( img );
}
@Override
public VolatileUnsignedIntType createVariable()
{
return new VolatileUnsignedIntType();
}
@Override
public VolatileUnsignedIntType copy()
{
final VolatileUnsignedIntType v = createVariable();
v.set( this );
return v;
}
}
......@@ -81,7 +81,7 @@ public class VolatileUnsignedLongType extends AbstractVolatileNativeRealType< Un
}
// this is the constructor if you want it to be a variable
public VolatileUnsignedLongType( final int value )
public VolatileUnsignedLongType( final long value )
{
this( new VolatileLongArray( 1, true ) );
set( value );
......@@ -93,7 +93,7 @@ public class VolatileUnsignedLongType extends AbstractVolatileNativeRealType< Un
this( 0 );
}
public void set( final int value )
public void set( final long value )
{
get().set( value );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment