From 18a266a703067ea24cd1387ef73d69281214dae7 Mon Sep 17 00:00:00 2001 From: tpietzsch Date: Fri, 5 Apr 2024 11:52:34 +0200 Subject: [PATCH] Clean up net.imglib2.converter a bit --- .../AbstractConvertedIterableInterval.java | 10 +-------- ...ertedIterableRandomAccessibleInterval.java | 16 +++----------- ...ractConvertedRandomAccessibleInterval.java | 15 ++++++------- .../BiConvertedRandomAccessibleInterval.java | 18 ++-------------- .../ConvertedRandomAccessibleInterval.java | 21 ++++--------------- ...ertedIterableRandomAccessibleInterval.java | 1 + ...riteConvertedRandomAccessibleInterval.java | 21 ++++--------------- 7 files changed, 23 insertions(+), 79 deletions(-) diff --git a/src/main/java/net/imglib2/converter/AbstractConvertedIterableInterval.java b/src/main/java/net/imglib2/converter/AbstractConvertedIterableInterval.java index 7f9b9dff2..25b75be23 100644 --- a/src/main/java/net/imglib2/converter/AbstractConvertedIterableInterval.java +++ b/src/main/java/net/imglib2/converter/AbstractConvertedIterableInterval.java @@ -34,15 +34,13 @@ package net.imglib2.converter; -import java.util.Iterator; - import net.imglib2.AbstractWrappedInterval; import net.imglib2.IterableInterval; import net.imglib2.View; /** * TODO - * + * */ abstract public class AbstractConvertedIterableInterval< A, B > extends AbstractWrappedInterval< IterableInterval< A > > implements IterableInterval< B >, View { @@ -62,10 +60,4 @@ public Object iterationOrder() { return sourceInterval.iterationOrder(); } - - @Override - abstract public AbstractConvertedCursor< A, B > cursor(); - - @Override - abstract public AbstractConvertedCursor< A, B > localizingCursor(); } diff --git a/src/main/java/net/imglib2/converter/AbstractConvertedIterableRandomAccessibleInterval.java b/src/main/java/net/imglib2/converter/AbstractConvertedIterableRandomAccessibleInterval.java index b1a2255fc..e2cfef782 100644 --- a/src/main/java/net/imglib2/converter/AbstractConvertedIterableRandomAccessibleInterval.java +++ b/src/main/java/net/imglib2/converter/AbstractConvertedIterableRandomAccessibleInterval.java @@ -45,21 +45,16 @@ /** * TODO - * + * */ -abstract public class AbstractConvertedIterableRandomAccessibleInterval< A, B, S extends RandomAccessible< A > & IterableInterval< A > > extends AbstractWrappedInterval< S > implements IterableInterval< B >, RandomAccessibleInterval< B >, View +abstract public class AbstractConvertedIterableRandomAccessibleInterval< A, B, S extends IterableInterval< A > > + extends AbstractWrappedInterval< S > implements RandomAccessibleInterval< B >, View { public AbstractConvertedIterableRandomAccessibleInterval( final S source ) { super( source ); } - @Override - abstract public AbstractConvertedRandomAccess< A, B > randomAccess(); - - @Override - abstract public AbstractConvertedRandomAccess< A, B > randomAccess( Interval interval ); - @Override public long size() { @@ -72,9 +67,4 @@ public Object iterationOrder() return sourceInterval.iterationOrder(); } - @Override - abstract public AbstractConvertedCursor< A, B > cursor(); - - @Override - abstract public AbstractConvertedCursor< A, B > localizingCursor(); } diff --git a/src/main/java/net/imglib2/converter/AbstractConvertedRandomAccessibleInterval.java b/src/main/java/net/imglib2/converter/AbstractConvertedRandomAccessibleInterval.java index 075e26fa0..8e386e179 100644 --- a/src/main/java/net/imglib2/converter/AbstractConvertedRandomAccessibleInterval.java +++ b/src/main/java/net/imglib2/converter/AbstractConvertedRandomAccessibleInterval.java @@ -45,19 +45,20 @@ */ abstract public class AbstractConvertedRandomAccessibleInterval< A, B > extends AbstractWrappedInterval< RandomAccessibleInterval< A > > implements RandomAccessibleInterval< B >, View { - - protected final RandomAccessibleInterval< A > source; - public AbstractConvertedRandomAccessibleInterval( final RandomAccessibleInterval< A > source ) { super( source ); - this.source = source; } @Override - abstract public AbstractConvertedRandomAccess< A, B > randomAccess(); + public long size() + { + return sourceInterval.size(); + } @Override - abstract public AbstractConvertedRandomAccess< A, B > randomAccess( Interval interval ); - + public Object iterationOrder() + { + return sourceInterval.iterationOrder(); + } } diff --git a/src/main/java/net/imglib2/converter/read/BiConvertedRandomAccessibleInterval.java b/src/main/java/net/imglib2/converter/read/BiConvertedRandomAccessibleInterval.java index ed84b1546..5bae598b9 100644 --- a/src/main/java/net/imglib2/converter/read/BiConvertedRandomAccessibleInterval.java +++ b/src/main/java/net/imglib2/converter/read/BiConvertedRandomAccessibleInterval.java @@ -36,12 +36,11 @@ import java.util.function.Supplier; -import net.imglib2.AbstractWrappedInterval; import net.imglib2.Cursor; import net.imglib2.Interval; import net.imglib2.IterableInterval; import net.imglib2.RandomAccessibleInterval; -import net.imglib2.View; +import net.imglib2.converter.AbstractConvertedRandomAccessibleInterval; import net.imglib2.converter.BiConverter; import net.imglib2.type.Type; @@ -49,7 +48,7 @@ * TODO * */ -public class BiConvertedRandomAccessibleInterval< A, B, C > extends AbstractWrappedInterval< RandomAccessibleInterval< A > > implements RandomAccessibleInterval< C >, View +public class BiConvertedRandomAccessibleInterval< A, B, C > extends AbstractConvertedRandomAccessibleInterval< A, C > { protected final RandomAccessibleInterval< B > sourceIntervalB; @@ -166,17 +165,4 @@ public BiConvertedCursor< A, B, C > localizingCursor() { return new BiConvertedCursor<>( sourceInterval.localizingCursor(), sourceIntervalB.cursor(), converterSupplier, convertedSupplier ); } - - @Override - public long size() - { - return sourceInterval.size(); - } - - @Override - public Object iterationOrder() - { - return sourceInterval.iterationOrder(); - } - } diff --git a/src/main/java/net/imglib2/converter/read/ConvertedRandomAccessibleInterval.java b/src/main/java/net/imglib2/converter/read/ConvertedRandomAccessibleInterval.java index 385c119cb..8066e5d1f 100644 --- a/src/main/java/net/imglib2/converter/read/ConvertedRandomAccessibleInterval.java +++ b/src/main/java/net/imglib2/converter/read/ConvertedRandomAccessibleInterval.java @@ -36,11 +36,10 @@ import java.util.function.Supplier; -import net.imglib2.AbstractWrappedInterval; import net.imglib2.Cursor; import net.imglib2.Interval; import net.imglib2.RandomAccessibleInterval; -import net.imglib2.View; +import net.imglib2.converter.AbstractConvertedRandomAccessibleInterval; import net.imglib2.converter.Converter; import net.imglib2.type.Type; @@ -48,7 +47,7 @@ * TODO * */ -public class ConvertedRandomAccessibleInterval< A, B > extends AbstractWrappedInterval< RandomAccessibleInterval< A > > implements RandomAccessibleInterval< B >, View +public class ConvertedRandomAccessibleInterval< A, B > extends AbstractConvertedRandomAccessibleInterval< A, B > { final protected Supplier< Converter< ? super A, ? super B > > converterSupplier; @@ -75,13 +74,13 @@ public ConvertedRandomAccessibleInterval( @Override public ConvertedRandomAccess< A, B > randomAccess() { - return new ConvertedRandomAccess< A, B >( sourceInterval.randomAccess(), converterSupplier, convertedSupplier ); + return new ConvertedRandomAccess<>( sourceInterval.randomAccess(), converterSupplier, convertedSupplier ); } @Override public ConvertedRandomAccess< A, B > randomAccess( final Interval interval ) { - return new ConvertedRandomAccess< A, B >( sourceInterval.randomAccess( interval ), converterSupplier, convertedSupplier ); + return new ConvertedRandomAccess<>( sourceInterval.randomAccess( interval ), converterSupplier, convertedSupplier ); } /** @@ -147,16 +146,4 @@ public Cursor< B > localizingCursor() { return new ConvertedCursor<>( sourceInterval.localizingCursor(), converterSupplier, convertedSupplier ); } - - @Override - public long size() - { - return sourceInterval.size(); - } - - @Override - public Object iterationOrder() - { - return sourceInterval.iterationOrder(); - } } diff --git a/src/main/java/net/imglib2/converter/readwrite/WriteConvertedIterableRandomAccessibleInterval.java b/src/main/java/net/imglib2/converter/readwrite/WriteConvertedIterableRandomAccessibleInterval.java index ddfb63fe8..6294a09d8 100644 --- a/src/main/java/net/imglib2/converter/readwrite/WriteConvertedIterableRandomAccessibleInterval.java +++ b/src/main/java/net/imglib2/converter/readwrite/WriteConvertedIterableRandomAccessibleInterval.java @@ -45,6 +45,7 @@ * TODO * */ +// TODO: Deprecate this? Every RandomAccessibleInterval is now a IterableInterval. So, does this add anything over WriteConvertedRandomAccessibleInterval? public class WriteConvertedIterableRandomAccessibleInterval< A, B, S extends RandomAccessible< A > & IterableInterval< A > > extends AbstractConvertedIterableRandomAccessibleInterval< A, B, S > { private final Supplier< SamplerConverter< ? super A, B > > converterSupplier; diff --git a/src/main/java/net/imglib2/converter/readwrite/WriteConvertedRandomAccessibleInterval.java b/src/main/java/net/imglib2/converter/readwrite/WriteConvertedRandomAccessibleInterval.java index 5f2678c70..03be3341f 100644 --- a/src/main/java/net/imglib2/converter/readwrite/WriteConvertedRandomAccessibleInterval.java +++ b/src/main/java/net/imglib2/converter/readwrite/WriteConvertedRandomAccessibleInterval.java @@ -36,16 +36,15 @@ import java.util.function.Supplier; -import net.imglib2.AbstractWrappedInterval; import net.imglib2.Cursor; import net.imglib2.Interval; import net.imglib2.RandomAccessibleInterval; +import net.imglib2.converter.AbstractConvertedRandomAccessibleInterval; /** * TODO - * */ -public class WriteConvertedRandomAccessibleInterval< A, B > extends AbstractWrappedInterval< RandomAccessibleInterval< A > > implements RandomAccessibleInterval< B > +public class WriteConvertedRandomAccessibleInterval< A, B > extends AbstractConvertedRandomAccessibleInterval< A, B > { private final Supplier< SamplerConverter< ? super A, B > > converterSupplier; @@ -67,13 +66,13 @@ public WriteConvertedRandomAccessibleInterval( @Override public WriteConvertedRandomAccess< A, B > randomAccess() { - return new WriteConvertedRandomAccess< A, B >( sourceInterval.randomAccess(), converterSupplier ); + return new WriteConvertedRandomAccess<>( sourceInterval.randomAccess(), converterSupplier ); } @Override public WriteConvertedRandomAccess< A, B > randomAccess( final Interval interval ) { - return new WriteConvertedRandomAccess< A, B >( sourceInterval.randomAccess( interval ), converterSupplier ); + return new WriteConvertedRandomAccess<>( sourceInterval.randomAccess( interval ), converterSupplier ); } @Override @@ -93,16 +92,4 @@ public Cursor< B > localizingCursor() { return new WriteConvertedCursor<>( sourceInterval.localizingCursor(), converterSupplier ); } - - @Override - public long size() - { - return sourceInterval.size(); - } - - @Override - public Object iterationOrder() - { - return sourceInterval.iterationOrder(); - } }