Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/net/imglib2/RandomAccessibleInterval.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/imglib2/RealRandomAccessible.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}.
* <p>
Expand Down Expand Up @@ -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 -------------------------------------------------------
Expand All @@ -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() ) );
}
Expand All @@ -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 ) );
}
Expand All @@ -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 ) );
}
Expand All @@ -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 ) );
}
Expand All @@ -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 ) );
}
Expand All @@ -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() ) );
}
Expand All @@ -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() ) ) );
}
Expand Down Expand Up @@ -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 ) );
}
Expand All @@ -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 ) );
}
Expand All @@ -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 ) );
}
Expand All @@ -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 ) );
}
Expand All @@ -325,11 +324,11 @@ default RandomAccessibleIntervalView< T > invertAxis( int axis )
* @param <T>
* pixel type ot the {@code RandomAccessible} to be extended
*/
class Extension< T >
class Extension< T, V extends RandomAccessibleIntervalView< T, V >>
{
final OutOfBoundsFactory< T, RandomAccessibleIntervalView< T > > factory;
final OutOfBoundsFactory< T, RandomAccessibleIntervalView< T, V > > factory;

private Extension( OutOfBoundsFactory< T, RandomAccessibleIntervalView< T > > factory )
private Extension( OutOfBoundsFactory< T, RandomAccessibleIntervalView< T, V > > factory )
{
this.factory = factory;
}
Expand All @@ -339,7 +338,7 @@ private Extension( OutOfBoundsFactory< T, RandomAccessibleIntervalView< T > > fa
* <p>
* 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<>() );
}
Expand All @@ -349,17 +348,17 @@ public static < T > Extension< T > border()
* <p>
* 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 > >() );
}

/**
* Create {@code Extension} using {@link OutOfBoundsConstantValueFactory}.
* <p>
* 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 ) );
}
Expand All @@ -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 &gt; 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 ) );
}
Expand All @@ -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 ) );
}
Expand All @@ -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<>() );
}
Expand All @@ -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 ) );
}
Expand Down Expand Up @@ -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() ) ) );
}
Expand All @@ -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 ) );
Expand All @@ -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 <U>
* 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -------------------------------------------------------
Expand All @@ -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 ) );
}
Expand Down Expand Up @@ -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 ) );
}
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/net/imglib2/view/fluent/RealRandomAccessibleView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 -------------------------------------------------------
Expand Down Expand Up @@ -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 ) );
}
Expand All @@ -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 ) );
}
Expand All @@ -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;
}
Expand Down