diff --git a/src/main/java/net/imglib2/RandomAccessibleInterval.java b/src/main/java/net/imglib2/RandomAccessibleInterval.java index fa31c75ae..d21763831 100644 --- a/src/main/java/net/imglib2/RandomAccessibleInterval.java +++ b/src/main/java/net/imglib2/RandomAccessibleInterval.java @@ -118,7 +118,7 @@ default Object iterationOrder() * views} into this {@code RandomAccessibleInterval}. */ @Override - default RandomAccessibleIntervalView< T > view() + default RandomAccessibleIntervalView< T, ? > view() { return RandomAccessibleIntervalView.wrap( this ); } diff --git a/src/main/java/net/imglib2/RealRandomAccessible.java b/src/main/java/net/imglib2/RealRandomAccessible.java index cd6d80ca3..212f8d632 100644 --- a/src/main/java/net/imglib2/RealRandomAccessible.java +++ b/src/main/java/net/imglib2/RealRandomAccessible.java @@ -139,7 +139,7 @@ default T getAt( final RealLocalizable position ) * @return gateway for creating light-weight views into this {@code * RealRandomAccessible}. */ - default RealRandomAccessibleView< T > realView() + default RealRandomAccessibleView< T, ? > realView() { return RealRandomAccessibleView.wrap( this ); } diff --git a/src/main/java/net/imglib2/view/fluent/RandomAccessibleIntervalView.java b/src/main/java/net/imglib2/view/fluent/RandomAccessibleIntervalView.java index f80ca24b4..4f5c484f7 100644 --- a/src/main/java/net/imglib2/view/fluent/RandomAccessibleIntervalView.java +++ b/src/main/java/net/imglib2/view/fluent/RandomAccessibleIntervalView.java @@ -33,9 +33,6 @@ */ package net.imglib2.view.fluent; -import java.util.function.Function; -import java.util.function.Supplier; - import net.imglib2.Cursor; import net.imglib2.FlatIterationOrder; import net.imglib2.RandomAccessible; @@ -55,6 +52,8 @@ import net.imglib2.view.IterableRandomAccessibleInterval; import net.imglib2.view.Views; +import java.util.function.Supplier; + /** * Gateway for creating light-weight views on a {@code RandomAccessibleInterval}. *
@@ -86,14 +85,14 @@
* @author Michael Innerberger
* @see Views
*/
-public interface RandomAccessibleIntervalView< T > extends RandomAccessibleView< T, RandomAccessibleIntervalView< T > >, RandomAccessibleInterval< T >
+public interface RandomAccessibleIntervalView< T , V extends RandomAccessibleIntervalView< T , V >> extends RandomAccessibleView< T, V >, RandomAccessibleInterval< T >
{
@Override
RandomAccessibleInterval< T > delegate();
- static < T > RandomAccessibleIntervalView< T > wrap( final RandomAccessibleInterval< T > delegate )
+ static < T, V extends RandomAccessibleIntervalView< T, V > > RandomAccessibleIntervalView< T, ? > wrap( final RandomAccessibleInterval< T > delegate )
{
- return () -> delegate;
+ return (RandomAccessibleIntervalView< T, V >) () -> delegate;
}
// -- Views methods -------------------------------------------------------
@@ -108,7 +107,7 @@ static < T > RandomAccessibleIntervalView< T > wrap( final RandomAccessibleInter
*
* @return a view with flat iteration order
*/
- default RandomAccessibleIntervalView< T > flatIterable()
+ default RandomAccessibleIntervalView< T, ? > flatIterable()
{
return wrap( Views.flatIterable( delegate() ) );
}
@@ -126,7 +125,7 @@ default RandomAccessibleIntervalView< T > flatIterable()
* @return a view on the given slice
*/
@Override
- default RandomAccessibleIntervalView< T > slice( int d, long pos )
+ default RandomAccessibleIntervalView< T, ? > slice( int d, long pos )
{
return wrap( Views.hyperSlice( delegate(), d, pos ) );
}
@@ -147,7 +146,7 @@ default RandomAccessibleIntervalView< T > slice( int d, long pos )
*
* @return a view with an additional dimension
*/
- default RandomAccessibleIntervalView< T > addDimension( long minOfNewDim, long maxOfNewDim )
+ default RandomAccessibleIntervalView< T, ? > addDimension( long minOfNewDim, long maxOfNewDim )
{
return wrap( Views.addDimension( delegate(), minOfNewDim, maxOfNewDim ) );
}
@@ -164,7 +163,7 @@ default RandomAccessibleIntervalView< T > addDimension( long minOfNewDim, long m
* @return a translated view
*/
@Override
- default RandomAccessibleIntervalView< T > translate( long... translation )
+ default RandomAccessibleIntervalView< T, ? > translate( long... translation )
{
return wrap( Views.translate( delegate(), translation ) );
}
@@ -182,7 +181,7 @@ default RandomAccessibleIntervalView< T > translate( long... translation )
* @return an inverse-translated view
*/
@Override
- default RandomAccessibleIntervalView< T > translateInverse( long... translation )
+ default RandomAccessibleIntervalView< T, ? > translateInverse( long... translation )
{
return wrap( Views.translateInverse( delegate(), translation ) );
}
@@ -193,7 +192,7 @@ default RandomAccessibleIntervalView< T > translateInverse( long... translation
*
* @return a view that is translated to the origin
*/
- default RandomAccessibleIntervalView< T > zeroMin()
+ default RandomAccessibleIntervalView< T, ? > zeroMin()
{
return wrap( Views.zeroMin( delegate() ) );
}
@@ -213,7 +212,7 @@ default RandomAccessibleIntervalView< T > zeroMin()
* @return a subsampled view
*/
@Override
- default RandomAccessibleIntervalView< T > subsample( final long... steps )
+ default RandomAccessibleIntervalView< T, ? > subsample( final long... steps )
{
return wrap( Views.subsample( delegate(), Util.expandArray( steps, numDimensions() ) ) );
}
@@ -242,7 +241,7 @@ default RandomAccessibleIntervalView< T > subsample( final long... steps )
* @return a view rotated 90 degrees
*/
@Override
- default RandomAccessibleIntervalView< T > rotate( int fromAxis, int toAxis )
+ default RandomAccessibleIntervalView< T, ? > rotate( int fromAxis, int toAxis )
{
return wrap( Views.rotate( delegate(), fromAxis, toAxis ) );
}
@@ -259,7 +258,7 @@ default RandomAccessibleIntervalView< T > rotate( int fromAxis, int toAxis )
* @return a view with permuted axes
*/
@Override
- default RandomAccessibleIntervalView< T > permute( int fromAxis, int toAxis )
+ default RandomAccessibleIntervalView< T, ? > permute( int fromAxis, int toAxis )
{
return wrap( Views.permute( delegate(), fromAxis, toAxis ) );
}
@@ -280,7 +279,7 @@ default RandomAccessibleIntervalView< T > permute( int fromAxis, int toAxis )
* @return a view with permuted axes
*/
@Override
- default RandomAccessibleIntervalView< T > moveAxis( int fromAxis, int toAxis )
+ default RandomAccessibleIntervalView< T, ? > moveAxis( int fromAxis, int toAxis )
{
return wrap( Views.moveAxis( delegate(), fromAxis, toAxis ) );
}
@@ -303,7 +302,7 @@ default RandomAccessibleIntervalView< T > moveAxis( int fromAxis, int toAxis )
* @return a view with {@code axis} inverted
*/
@Override
- default RandomAccessibleIntervalView< T > invertAxis( int axis )
+ default RandomAccessibleIntervalView< T, ? > invertAxis( int axis )
{
return wrap( Views.invertAxis( delegate(), axis ) );
}
@@ -325,11 +324,11 @@ default RandomAccessibleIntervalView< T > invertAxis( int axis )
* @param
* Out-of-bounds pixels are created by repeating border pixels.
*/
- public static < T > Extension< T > border()
+ public static < T, V extends RandomAccessibleIntervalView< T, V > > Extension< T, V > border()
{
return new Extension<>(new OutOfBoundsBorderFactory<>() );
}
@@ -349,9 +348,9 @@ public static < T > Extension< T > border()
*
* All out-of-bounds pixels have value zero.
*/
- public static < T extends Type< T > & SetZero > Extension< T > zero()
+ public static < T extends Type< T > & SetZero, V extends RandomAccessibleIntervalView< T, V >> Extension< T, V > zero()
{
- return new Extension<>( new OutOfBoundsZeroFactory< T, RandomAccessibleIntervalView< T > >() );
+ return new Extension<>( new OutOfBoundsZeroFactory< T, RandomAccessibleIntervalView< T, V > >() );
}
/**
@@ -359,7 +358,7 @@ public static < T extends Type< T > & SetZero > Extension< T > zero()
*
* All out-of-bounds pixels have the provided {@code value}.
*/
- public static < T > Extension< T > value( T value )
+ public static < T, V extends RandomAccessibleIntervalView< T, V > > Extension< T, V > value( T value )
{
return new Extension<>(new OutOfBoundsConstantValueFactory<>( value ) );
}
@@ -371,7 +370,7 @@ public static < T > Extension< T > value( T value )
* are not repeated. Note that this requires that all dimensions of the
* source must be > 1.
*/
- public static < T > Extension< T > mirrorSingle()
+ public static < T, V extends RandomAccessibleIntervalView< T, V > > Extension< T, V > mirrorSingle()
{
return new Extension<>(new OutOfBoundsMirrorFactory<>( OutOfBoundsMirrorFactory.Boundary.SINGLE ) );
}
@@ -382,7 +381,7 @@ public static < T > Extension< T > mirrorSingle()
* Out-of-bounds pixels are created by mirroring, where boundary pixels
* are repeated.
*/
- public static < T > Extension< T > mirrorDouble()
+ public static < T, V extends RandomAccessibleIntervalView< T, V > > Extension< T, V > mirrorDouble()
{
return new Extension<>(new OutOfBoundsMirrorFactory<>( OutOfBoundsMirrorFactory.Boundary.DOUBLE ) );
}
@@ -393,7 +392,7 @@ public static < T > Extension< T > mirrorDouble()
* Out-of-bounds pixels are created by periodically repeating the source
* image.
*/
- public static < T > Extension< T > periodic()
+ public static < T, V extends RandomAccessibleIntervalView< T, V > > Extension< T, V > periodic()
{
return new Extension<>(new OutOfBoundsPeriodicFactory<>() );
}
@@ -419,7 +418,7 @@ public static < T > Extension< T > periodic()
*
* @return an extended (unbounded) view
*/
- default RandomAccessibleView< T, ? > extend( Extension< T > extension )
+ default RandomAccessibleView< T, ? > extend( Extension< T, V > extension )
{
return RandomAccessibleView.wrap( Views.extend( this, extension.factory ) );
}
@@ -455,7 +454,7 @@ public static < T > Extension< T > periodic()
*
* @return an expanded view
*/
- default RandomAccessibleIntervalView< T > expand( Extension< T > extension, long... border )
+ default RandomAccessibleIntervalView< T, ? > expand( Extension< T, V > extension, long... border )
{
return RandomAccessibleIntervalView.wrap( Views.expand( this, extension.factory, Util.expandArray( border, numDimensions() ) ) );
}
@@ -479,7 +478,7 @@ default RandomAccessibleIntervalView< T > expand( Extension< T > extension, long
* @return a converted view
*/
@Override
- default < U > RandomAccessibleIntervalView< U > convert(
+ default < U > RandomAccessibleIntervalView< U, ? > convert(
final Supplier< U > targetSupplier, final Converter< ? super T, ? super U > converter )
{
return wrap( Converters.convert2( delegate(), converter, targetSupplier ) );
@@ -505,34 +504,16 @@ default < U > RandomAccessibleIntervalView< U > convert(
* @return a converted view
*/
@Override
- default < U > RandomAccessibleIntervalView< U > convert(
+ default < U > RandomAccessibleIntervalView< U, ? > convert(
final Supplier< U > targetSupplier, final Supplier< Converter< ? super T, ? super U > > converterSupplier )
{
return wrap( Converters.convert2( delegate(), converterSupplier, targetSupplier ) );
}
- /**
- * Apply the specified {@code function} to this {@code
- * RandomAccessibleInterval} and return the result.
- *
- * @param function
- * function to evaluate on this {@code RandomAccessibleInterval}
- * @param
- * the type of the result of the function
- *
- * @return {@code function.apply(this)}
- */
- @Override
- default < U > U use( Function< ? super RandomAccessibleIntervalView< T >, U > function )
- {
- return function.apply( this );
- }
-
-
// -- RandomAccessibleInterval --------------------------------------------
@Override
- default RandomAccessibleIntervalView< T > view()
+ default RandomAccessibleIntervalView< T, V > view()
{
return this;
}
diff --git a/src/main/java/net/imglib2/view/fluent/RandomAccessibleView.java b/src/main/java/net/imglib2/view/fluent/RandomAccessibleView.java
index 6e0534edb..24c7d3d4a 100644
--- a/src/main/java/net/imglib2/view/fluent/RandomAccessibleView.java
+++ b/src/main/java/net/imglib2/view/fluent/RandomAccessibleView.java
@@ -87,9 +87,9 @@ public interface RandomAccessibleView< T, V extends RandomAccessibleView< T, V >
{
RandomAccessible< T > delegate();
- static < T, V extends RandomAccessibleView< T, V > > RandomAccessibleView< T, V > wrap( final RandomAccessible< T > delegate )
+ static < T, V extends RandomAccessibleView< T, V >> RandomAccessibleView< T, ? > wrap( final RandomAccessible< T > delegate )
{
- return ( RandomAccessibleView< T, V > ) () -> delegate;
+ return (RandomAccessibleView< T, V >) () -> delegate;
}
// -- Views methods -------------------------------------------------------
@@ -109,7 +109,7 @@ static < T, V extends RandomAccessibleView< T, V > > RandomAccessibleView< T, V
*
* @return a view on the given interval
*/
- default RandomAccessibleIntervalView< T > interval( Interval interval )
+ default RandomAccessibleIntervalView< T, ? > interval( Interval interval )
{
return RandomAccessibleIntervalView.wrap( Views.interval( delegate(), interval ) );
}
@@ -354,7 +354,7 @@ public static < T extends RealType< T > > Interpolation< T > lanczos()
*
* @return an interpolated view
*/
- default RealRandomAccessibleView< T > interpolate( final Interpolation< T > interpolation )
+ default RealRandomAccessibleView< T, ? > interpolate( final Interpolation< T > interpolation )
{
return RealRandomAccessibleView.wrap( Views.interpolate( delegate(), interpolation.factory ) );
}
diff --git a/src/main/java/net/imglib2/view/fluent/RealRandomAccessibleView.java b/src/main/java/net/imglib2/view/fluent/RealRandomAccessibleView.java
index 1852f9590..41fe02b3a 100644
--- a/src/main/java/net/imglib2/view/fluent/RealRandomAccessibleView.java
+++ b/src/main/java/net/imglib2/view/fluent/RealRandomAccessibleView.java
@@ -72,13 +72,13 @@
* @author Michael Innerberger
* @see Views
*/
-public interface RealRandomAccessibleView< T > extends RealRandomAccessible< T >
+public interface RealRandomAccessibleView< T, V extends RealRandomAccessibleView< T, V > > extends RealRandomAccessible< T >
{
RealRandomAccessible< T > delegate();
- static < T > RealRandomAccessibleView< T > wrap( final RealRandomAccessible< T > delegate )
+ static < T, V extends RealRandomAccessibleView< T, V >> RealRandomAccessibleView< T, ? > wrap( final RealRandomAccessible< T > delegate )
{
- return () -> delegate;
+ return (RealRandomAccessibleView< T, V >) () -> delegate;
}
// -- Views methods -------------------------------------------------------
@@ -113,9 +113,9 @@ static < T > RealRandomAccessibleView< T > wrap( final RealRandomAccessible< T >
*
* @return a converted view
*/
- default < U > RealRandomAccessibleView< U > convert(
+ default < U > RealRandomAccessibleView< U, ? > convert(
final Supplier< U > targetSupplier,
- final Converter< ? super T, ? super U > converter )
+ final Converter< ? super T, ? super U > converter)
{
return wrap( Converters.convert2( delegate(), converter, targetSupplier ) );
}
@@ -139,9 +139,9 @@ default < U > RealRandomAccessibleView< U > convert(
*
* @return a converted view
*/
- default < U > RealRandomAccessibleView< U > convert(
+ default < U > RealRandomAccessibleView< U, ? > convert(
final Supplier< U > targetSupplier,
- final Supplier< Converter< ? super T, ? super U > > converterSupplier )
+ final Supplier< Converter< ? super T, ? super U > > converterSupplier)
{
return wrap( Converters.convert2( delegate(), converterSupplier, targetSupplier ) );
}
@@ -157,16 +157,16 @@ default < U > RealRandomAccessibleView< U > convert(
*
* @return {@code function.apply(this)}
*/
- default < U > U use( Function< ? super RealRandomAccessibleView< T >, U > function )
+ default < U > U use( Function< ? super V, U > function )
{
- return function.apply( this );
+ return function.apply( (V) this );
}
// -- RealRandomAccessible ------------------------------------------------
@Override
- default RealRandomAccessibleView< T > realView()
+ default RealRandomAccessibleView< T, ? > realView()
{
return this;
}