diff --git a/pom.xml b/pom.xml
index 6bd3a84..2fa9aed 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.scijava
pom-scijava
- 34.0.0
+ 37.0.0
@@ -113,7 +113,7 @@ Jean-Yves Tinevez and Michael Zinsmaier.
sign,deploy-to-scijava
- 6.1.0
+ 7.0.0
diff --git a/src/main/java/net/imglib2/cache/IoSync.java b/src/main/java/net/imglib2/cache/IoSync.java
index 896bdf9..49f7301 100644
--- a/src/main/java/net/imglib2/cache/IoSync.java
+++ b/src/main/java/net/imglib2/cache/IoSync.java
@@ -75,7 +75,7 @@
* @param
* value type
* @param
- * value data type
+ * value data type, see {@link CacheRemover}
*
* @author Tobias Pietzsch
*/
diff --git a/src/main/java/net/imglib2/cache/img/DiskCellCache.java b/src/main/java/net/imglib2/cache/img/DiskCellCache.java
index fc7bef5..464d252 100644
--- a/src/main/java/net/imglib2/cache/img/DiskCellCache.java
+++ b/src/main/java/net/imglib2/cache/img/DiskCellCache.java
@@ -55,6 +55,7 @@
import net.imglib2.cache.IoSync;
import net.imglib2.img.cell.Cell;
import net.imglib2.img.cell.CellGrid;
+import net.imglib2.img.cell.CellGrid.CellDimensionsAndSteps;
import net.imglib2.util.Fraction;
import net.imglib2.util.Intervals;
@@ -125,16 +126,14 @@ public Cell< A > get( final Long key ) throws Exception
if ( new File( filename ).exists() )
{
final long[] cellMin = new long[ n ];
- final int[] cellDims = new int[ n ];
- grid.getCellDimensions( index, cellMin, cellDims );
- final long numEntities = entitiesPerPixel.mulCeil( Intervals.numElements( cellDims ) );
+ final CellDimensionsAndSteps dimsAndSteps = grid.getCellDimensions( index, cellMin );
+ final long numEntities = entitiesPerPixel.mulCeil( dimsAndSteps.numPixels() );
final long bytesize = numEntities * accessIo.getBytesPerElement();
- try (
- final RandomAccessFile mmFile = new RandomAccessFile( filename, "r" ); )
+ try ( final RandomAccessFile mmFile = new RandomAccessFile( filename, "r" ) )
{
final MappedByteBuffer in = mmFile.getChannel().map( MapMode.READ_ONLY, 0, bytesize );
final A access = accessIo.load( in, ( int ) numEntities );
- return new Cell<>( cellDims, cellMin, access );
+ return new Cell<>( dimsAndSteps, cellMin, access );
}
}
else
@@ -154,9 +153,8 @@ public Cell< A > reconstruct( final Long key, final A valueData )
{
final long index = key;
final long[] cellMin = new long[ n ];
- final int[] cellDims = new int[ n ];
- grid.getCellDimensions( index, cellMin, cellDims );
- return new Cell<>( cellDims, cellMin, valueData );
+ final CellDimensionsAndSteps dimsAndSteps = grid.getCellDimensions( index, cellMin );
+ return new Cell<>( dimsAndSteps, cellMin, valueData );
}
@Override
diff --git a/src/main/java/net/imglib2/cache/img/EmptyCellCacheLoader.java b/src/main/java/net/imglib2/cache/img/EmptyCellCacheLoader.java
index 06c6ed0..9a65fa2 100644
--- a/src/main/java/net/imglib2/cache/img/EmptyCellCacheLoader.java
+++ b/src/main/java/net/imglib2/cache/img/EmptyCellCacheLoader.java
@@ -41,10 +41,10 @@
import net.imglib2.img.basictypeaccess.array.ArrayDataAccess;
import net.imglib2.img.cell.Cell;
import net.imglib2.img.cell.CellGrid;
+import net.imglib2.img.cell.CellGrid.CellDimensionsAndSteps;
import net.imglib2.type.NativeType;
import net.imglib2.type.PrimitiveType;
import net.imglib2.util.Fraction;
-import net.imglib2.util.Intervals;
/**
* A {@link CacheLoader} that produces empty cells of {@link ArrayDataAccess}
@@ -84,10 +84,9 @@ public Cell< A > get( final Long key ) throws Exception
{
final long index = key;
final long[] cellMin = new long[ grid.numDimensions() ];
- final int[] cellDims = new int[ grid.numDimensions() ];
- grid.getCellDimensions( index, cellMin, cellDims );
- final long numEntities = entitiesPerPixel.mulCeil( Intervals.numElements( cellDims ) );
- return new Cell<>( cellDims, cellMin, creator.createArray( ( int ) numEntities ) );
+ final CellDimensionsAndSteps dimsAndSteps = grid.getCellDimensions( index, cellMin );
+ final long numEntities = entitiesPerPixel.mulCeil( dimsAndSteps.numPixels() );
+ return new Cell<>( dimsAndSteps, cellMin, creator.createArray( ( int ) numEntities ) );
}
public static < T extends NativeType< T >, A extends ArrayDataAccess< A > > EmptyCellCacheLoader< A > get(
diff --git a/src/main/java/net/imglib2/cache/img/LoadedCellCacheLoader.java b/src/main/java/net/imglib2/cache/img/LoadedCellCacheLoader.java
index f598e19..1090c18 100644
--- a/src/main/java/net/imglib2/cache/img/LoadedCellCacheLoader.java
+++ b/src/main/java/net/imglib2/cache/img/LoadedCellCacheLoader.java
@@ -58,6 +58,7 @@
import net.imglib2.img.basictypeaccess.array.ShortArray;
import net.imglib2.img.cell.Cell;
import net.imglib2.img.cell.CellGrid;
+import net.imglib2.img.cell.CellGrid.CellDimensionsAndSteps;
import net.imglib2.type.NativeType;
import net.imglib2.type.PrimitiveType;
import net.imglib2.util.Fraction;
@@ -115,14 +116,13 @@ public Cell< A > get( final Long key ) throws Exception
{
final long index = key;
final long[] cellMin = new long[ grid.numDimensions() ];
- final int[] cellDims = new int[ grid.numDimensions() ];
- grid.getCellDimensions( index, cellMin, cellDims );
- final long numEntities = entitiesPerPixel.mulCeil( Intervals.numElements( cellDims ) );
+ final CellDimensionsAndSteps dimsAndSteps = grid.getCellDimensions( index, cellMin );
+ final long numEntities = entitiesPerPixel.mulCeil( dimsAndSteps.numPixels() );
final A array = creator.createArray( ( int ) numEntities );
@SuppressWarnings( { "rawtypes", "unchecked" } )
- final SingleCellArrayImg< T, ? > img = new SingleCellArrayImg( cellDims, cellMin, wrapper.wrap( array ), wrapper.wrapDirty( array ), type );
+ final SingleCellArrayImg< T, ? > img = new SingleCellArrayImg( dimsAndSteps.dimensions(), cellMin, wrapper.wrap( array ), wrapper.wrapDirty( array ), type );
loader.load( img );
- return new Cell<>( cellDims, cellMin, array );
+ return new Cell<>( dimsAndSteps, cellMin, array );
}
public static < T extends NativeType< T >, A extends ArrayDataAccess< A > > LoadedCellCacheLoader< T, A > get(
@@ -143,7 +143,7 @@ public static < T extends NativeType< T >, A extends ArrayDataAccess< A > > Load
{
final A creator = ArrayDataAccessFactory.get( primitiveType, flags );
final ArrayDataAccessWrapper< A, ? > wrapper = getWrapper( primitiveType, flags );
- return creator == null ? null : new LoadedCellCacheLoader<>( grid, type, creator, wrapper, loader );
+ return new LoadedCellCacheLoader<>( grid, type, creator, wrapper, loader );
}
@SuppressWarnings( "unchecked" )
diff --git a/src/main/java/net/imglib2/cache/img/RandomAccessibleCacheLoader.java b/src/main/java/net/imglib2/cache/img/RandomAccessibleCacheLoader.java
index dd09ba0..bf1603c 100644
--- a/src/main/java/net/imglib2/cache/img/RandomAccessibleCacheLoader.java
+++ b/src/main/java/net/imglib2/cache/img/RandomAccessibleCacheLoader.java
@@ -36,6 +36,7 @@
import static net.imglib2.img.basictypeaccess.AccessFlags.DIRTY;
import static net.imglib2.img.basictypeaccess.AccessFlags.VOLATILE;
+import java.util.Arrays;
import java.util.Set;
import java.util.function.Function;
@@ -78,11 +79,11 @@
import net.imglib2.img.basictypeaccess.volatiles.array.VolatileShortArray;
import net.imglib2.img.cell.Cell;
import net.imglib2.img.cell.CellGrid;
+import net.imglib2.img.cell.CellGrid.CellDimensionsAndSteps;
import net.imglib2.type.NativeType;
import net.imglib2.type.PrimitiveType;
import net.imglib2.type.NativeTypeFactory;
import net.imglib2.util.Fraction;
-import net.imglib2.util.Intervals;
import net.imglib2.view.Views;
/**
@@ -151,22 +152,19 @@ public Cell< CA > get( final Long key ) throws Exception
final int n = grid.numDimensions();
final long[] cellMin = new long[ n ];
- final int[] cellDims = new int[ n ];
final long[] cellMax = new long[ n ];
-
- grid.getCellDimensions( index, cellMin, cellDims );
- final long numEntities = entitiesPerPixel.mulCeil( Intervals.numElements( cellDims ) );
+ final CellDimensionsAndSteps dimsAndSteps = grid.getCellDimensions( index, cellMin );
+ Arrays.setAll( cellMax, d -> cellMin[ d ] + dimsAndSteps.dimensions()[ d ] - 1 );
+ final long numEntities = entitiesPerPixel.mulCeil( dimsAndSteps.numPixels() );
final A data = creator.createArray( ( int ) numEntities );
final T t = createType( data );
t.updateIndex( 0 );
- for ( int d = 0; d < n; ++d )
- cellMax[ d ] = cellMin[ d ] + cellDims[ d ] - 1;
for ( final T s : Views.interval( source, cellMin, cellMax ) )
{
t.set( s );
t.incIndex();
}
- return new Cell<>( cellDims, cellMin, rewrap.apply( data ) );
+ return new Cell<>( dimsAndSteps, cellMin, rewrap.apply( data ) );
}
public static < T extends NativeType< T >, A extends ArrayDataAccess< A >, CA extends ArrayDataAccess< CA > > RandomAccessibleCacheLoader< T, A, CA > get(
diff --git a/src/main/java/net/imglib2/cache/img/SingleCellArrayImg.java b/src/main/java/net/imglib2/cache/img/SingleCellArrayImg.java
index 74c3925..c3bd14b 100644
--- a/src/main/java/net/imglib2/cache/img/SingleCellArrayImg.java
+++ b/src/main/java/net/imglib2/cache/img/SingleCellArrayImg.java
@@ -178,6 +178,12 @@ public RandomAccess< T > randomAccess( final Interval interval )
return randomAccess();
}
+ @Override
+ public T getType()
+ {
+ return linkedType;
+ }
+
class CellArrayRandomAccess extends AbstractLocalizable implements RandomAccess< T >
{
final T type;
@@ -208,6 +214,12 @@ public T get()
return type;
}
+ @Override
+ public T getType()
+ {
+ return type;
+ }
+
@Override
public void fwd( final int d )
{
@@ -363,6 +375,12 @@ public T get()
return type;
}
+ @Override
+ public T getType()
+ {
+ return type;
+ }
+
@Override
public boolean hasNext()
{
@@ -450,6 +468,12 @@ public T get()
return type;
}
+ @Override
+ public T getType()
+ {
+ return type;
+ }
+
@Override
public void fwd()
{
diff --git a/src/main/java/net/imglib2/cache/img/optional/AccessOptions.java b/src/main/java/net/imglib2/cache/img/optional/AccessOptions.java
index 546d5b0..276f457 100644
--- a/src/main/java/net/imglib2/cache/img/optional/AccessOptions.java
+++ b/src/main/java/net/imglib2/cache/img/optional/AccessOptions.java
@@ -33,8 +33,10 @@
*/
package net.imglib2.cache.img.optional;
+import java.util.Set;
import java.util.function.BiConsumer;
import net.imglib2.Dirty;
+import net.imglib2.img.basictypeaccess.AccessFlags;
import org.scijava.optional.Options;
import org.scijava.optional.Values;
@@ -67,6 +69,13 @@ default T volatileAccesses( final boolean volatil )
return setValue( "volatileAccesses", volatil );
}
+ default T accessFlags( final Set< AccessFlags > flags )
+ {
+ final boolean dirty = flags.contains( AccessFlags.DIRTY );
+ final boolean volatil = flags.contains( AccessFlags.VOLATILE );
+ return ( ( AccessOptions< T > ) dirtyAccesses( dirty ) ).volatileAccesses( volatil );
+ }
+
interface Val extends Values
{
default void forEach( BiConsumer< String, Object > action )
diff --git a/src/main/java/net/imglib2/cache/ref/GuardedStrongRefLoaderRemoverCache.java b/src/main/java/net/imglib2/cache/ref/GuardedStrongRefLoaderRemoverCache.java
index 5475c45..8e8ef71 100644
--- a/src/main/java/net/imglib2/cache/ref/GuardedStrongRefLoaderRemoverCache.java
+++ b/src/main/java/net/imglib2/cache/ref/GuardedStrongRefLoaderRemoverCache.java
@@ -72,6 +72,8 @@
* key type
* @param
* value type
+ * @param
+ * value data type, see {@link CacheRemover}
*
* @author Tobias Pietzsch
*/
diff --git a/src/main/java/net/imglib2/cache/util/IntervalKeyLoaderAsLongKeyLoader.java b/src/main/java/net/imglib2/cache/util/IntervalKeyLoaderAsLongKeyLoader.java
index 2da5bde..0125544 100644
--- a/src/main/java/net/imglib2/cache/util/IntervalKeyLoaderAsLongKeyLoader.java
+++ b/src/main/java/net/imglib2/cache/util/IntervalKeyLoaderAsLongKeyLoader.java
@@ -33,8 +33,8 @@
*/
package net.imglib2.cache.util;
+import java.util.Arrays;
import java.util.function.Function;
-import java.util.stream.IntStream;
import net.imglib2.FinalInterval;
import net.imglib2.Interval;
@@ -79,10 +79,10 @@ public Cell< A > get( final Long key )
final int n = grid.numDimensions();
final long[] cellMin = new long[ n ];
- final int[] cellDims = new int[ n ];
- grid.getCellDimensions( index, cellMin, cellDims );
- final long[] cellMax = IntStream.range( 0, n ).mapToLong( d -> cellMin[ d ] + cellDims[ d ] - 1 ).toArray();
- final A result = intervalKeyLoader.apply( new FinalInterval( cellMin, cellMax ) );
- return new Cell<>( cellDims, cellMin, result );
+ final long[] cellMax = new long[ n ];
+ final CellGrid.CellDimensionsAndSteps dimsAndSteps = grid.getCellDimensions( index, cellMin );
+ Arrays.setAll( cellMax, d -> cellMin[ d ] + dimsAndSteps.dimensions()[ d ] - 1 );
+ final A result = intervalKeyLoader.apply( FinalInterval.wrap( cellMin, cellMax ) );
+ return new Cell<>( dimsAndSteps, cellMin, result );
}
}