From 0ed5e337e11ae63ca38f8810ce5b42c3037d69bc Mon Sep 17 00:00:00 2001 From: tpietzsch Date: Tue, 7 May 2024 21:22:07 +0200 Subject: [PATCH] simplify --- src/main/java/net/imglib2/img/Img.java | 6 +---- .../java/net/imglib2/img/cell/CellGrid.java | 24 +----------------- src/main/java/net/imglib2/util/Grid.java | 25 +------------------ .../java/net/imglib2/view/IntervalView.java | 9 +++---- .../IterableRandomAccessibleInterval.java | 4 +-- 5 files changed, 8 insertions(+), 60 deletions(-) diff --git a/src/main/java/net/imglib2/img/Img.java b/src/main/java/net/imglib2/img/Img.java index 868414b95..d96b5938e 100644 --- a/src/main/java/net/imglib2/img/Img.java +++ b/src/main/java/net/imglib2/img/Img.java @@ -34,7 +34,6 @@ package net.imglib2.img; -import net.imglib2.IterableInterval; import net.imglib2.RandomAccessibleInterval; /** @@ -45,10 +44,7 @@ * @author Stephan Saalfeld * @author Stephan Preibisch */ -public interface Img< T > - extends - RandomAccessibleInterval< T >, - IterableInterval< T > +public interface Img< T > extends RandomAccessibleInterval< T > { /** * Get a {@link ImgFactory} that creates {@link Img}s of the same kind as diff --git a/src/main/java/net/imglib2/img/cell/CellGrid.java b/src/main/java/net/imglib2/img/cell/CellGrid.java index 3456a5b9a..29b88a91a 100644 --- a/src/main/java/net/imglib2/img/cell/CellGrid.java +++ b/src/main/java/net/imglib2/img/cell/CellGrid.java @@ -35,11 +35,8 @@ import java.util.Arrays; -import net.imglib2.Cursor; import net.imglib2.FinalInterval; -import net.imglib2.FlatIterationOrder; import net.imglib2.Interval; -import net.imglib2.IterableInterval; import net.imglib2.Localizable; import net.imglib2.Point; import net.imglib2.Positionable; @@ -48,7 +45,6 @@ import net.imglib2.util.IntervalIndexer; import net.imglib2.util.Intervals; import net.imglib2.util.Util; -import net.imglib2.view.RandomAccessibleIntervalCursor; /** * Defines {@link AbstractCellImg} geometry and translates between image, cell, @@ -708,7 +704,7 @@ public RandomAccess< Interval > copy() } } - public class CellIntervals implements RandomAccessibleInterval< Interval >, IterableInterval< Interval > + public class CellIntervals implements RandomAccessibleInterval< Interval > { private final long size = Intervals.numElements( numCells ); @@ -742,30 +738,12 @@ public RandomAccess< Interval > randomAccess( final Interval interval ) return randomAccess(); } - @Override - public Cursor< Interval > cursor() - { - return new RandomAccessibleIntervalCursor<>( this ); - } - - @Override - public Cursor< Interval > localizingCursor() - { - return cursor(); - } - @Override public long size() { return size; } - @Override - public FlatIterationOrder iterationOrder() - { - return new FlatIterationOrder( this ); - } - @Override public Interval getType() { diff --git a/src/main/java/net/imglib2/util/Grid.java b/src/main/java/net/imglib2/util/Grid.java index cb66b7d19..61fdb7a91 100644 --- a/src/main/java/net/imglib2/util/Grid.java +++ b/src/main/java/net/imglib2/util/Grid.java @@ -34,19 +34,14 @@ package net.imglib2.util; import java.util.Arrays; -import java.util.Iterator; -import net.imglib2.Cursor; import net.imglib2.FinalInterval; -import net.imglib2.FlatIterationOrder; import net.imglib2.Interval; -import net.imglib2.IterableInterval; import net.imglib2.Point; import net.imglib2.Positionable; import net.imglib2.RandomAccess; import net.imglib2.RandomAccessibleInterval; import net.imglib2.img.cell.CellGrid; -import net.imglib2.view.RandomAccessibleIntervalCursor; /** * Defines a regular grid on an interval and translates between interval and grid @@ -499,7 +494,7 @@ public RandomAccess< Interval > copy() } } - public class CellIntervals implements RandomAccessibleInterval< Interval >, IterableInterval< Interval > + public class CellIntervals implements RandomAccessibleInterval< Interval > { private final long size = Intervals.numElements( numCells ); @@ -533,30 +528,12 @@ public RandomAccess< Interval > randomAccess( final Interval interval ) return randomAccess(); } - @Override - public Cursor< Interval > cursor() - { - return new RandomAccessibleIntervalCursor<>( this ); - } - - @Override - public Cursor< Interval > localizingCursor() - { - return cursor(); - } - @Override public long size() { return size; } - @Override - public FlatIterationOrder iterationOrder() - { - return new FlatIterationOrder( this ); - } - @Override public Interval getType() { diff --git a/src/main/java/net/imglib2/view/IntervalView.java b/src/main/java/net/imglib2/view/IntervalView.java index cef1a3413..804839a57 100644 --- a/src/main/java/net/imglib2/view/IntervalView.java +++ b/src/main/java/net/imglib2/view/IntervalView.java @@ -38,6 +38,7 @@ import net.imglib2.AbstractInterval; import net.imglib2.Cursor; +import net.imglib2.FinalInterval; import net.imglib2.Interval; import net.imglib2.IterableInterval; import net.imglib2.RandomAccess; @@ -54,7 +55,7 @@ * created through the {@link Views#interval(RandomAccessible, Interval)} method * instead. */ -public class IntervalView< T > extends AbstractInterval implements RandomAccessibleInterval< T >, IterableInterval< T >, View +public class IntervalView< T > extends AbstractInterval implements RandomAccessibleInterval< T >, View { /** * The source {@link RandomAccessible}. @@ -101,11 +102,7 @@ public IntervalView( final RandomAccessible< T > source, final Interval interval */ public IntervalView( final RandomAccessible< T > source, final long[] min, final long[] max ) { - super( min, max ); - assert ( source.numDimensions() == min.length ); - - this.source = source; - this.fullViewRandomAccessible = null; + this( source, FinalInterval.wrap( min, max ) ); } /** diff --git a/src/main/java/net/imglib2/view/IterableRandomAccessibleInterval.java b/src/main/java/net/imglib2/view/IterableRandomAccessibleInterval.java index 64760af44..3aad9bdd8 100644 --- a/src/main/java/net/imglib2/view/IterableRandomAccessibleInterval.java +++ b/src/main/java/net/imglib2/view/IterableRandomAccessibleInterval.java @@ -53,7 +53,7 @@ public class IterableRandomAccessibleInterval< T > extends AbstractWrappedInterv { public static < T > IterableRandomAccessibleInterval< T > create( final RandomAccessibleInterval< T > interval ) { - return new IterableRandomAccessibleInterval< T >( interval ); + return new IterableRandomAccessibleInterval<>( interval ); } public IterableRandomAccessibleInterval( final RandomAccessibleInterval< T > interval ) @@ -76,7 +76,7 @@ public FlatIterationOrder iterationOrder() @Override public Cursor< T > cursor() { - return new RandomAccessibleIntervalCursor< T >( sourceInterval ); + return new RandomAccessibleIntervalCursor<>( sourceInterval ); } @Override