Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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 pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>net.imglib2</groupId>
<artifactId>imglib2</artifactId>
<version>6.4.1-SNAPSHOT</version>
<version>7.0.0-SNAPSHOT</version>

<name>ImgLib2 Core Library</name>
<description>A multidimensional, type-agnostic image processing library.</description>
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/net/imglib2/IterableRealInterval.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
*
* @author Stephan Saalfeld
*/
public interface IterableRealInterval< T > extends RealInterval, Iterable< T >
public interface IterableRealInterval< T > extends RealInterval, Iterable< T >, Typed< T >
{
/**
* <p>
Expand Down Expand Up @@ -118,6 +118,24 @@ default T firstElement() // TODO: fix places where it is not necessary to implem
return iterator().next();
}

/**
* Get an instance of {@code T}.
* <p>
* It should not be assumed that the returned {@code T} instance is an
* independent copy. In particular, repeated calls to {@code getType()} may
* return the same instance.
* <p>
* The default implementation returns {@link #firstElement}. Derived classes
* may choose different implementations for improved performance.
*
* @return an instance of {@code T}
*/
@Override
default T getType()
{
return firstElement();
}

/**
* Returns the iteration order of this {@link IterableRealInterval}. If the
* returned object equals ({@link Object#equals(Object)}) the iteration
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/net/imglib2/KDTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ public Cursor copy()
{
return new Cursor( source.copy() );
}

@Override
public RealLocalizable getType()
{
return source;
}
}

@Override
Expand Down Expand Up @@ -182,6 +188,12 @@ public KDTreeNode< T > getRoot()
return new KDTreeNode<>( this ).setNodeIndex( impl.root() );
}

@Override
public T getType()
{
return treeData.getType();
}

@Override
public int numDimensions()
{
Expand Down Expand Up @@ -232,6 +244,12 @@ public boolean hasNext()
return nodeIndex() < impl.size() - 1;
}

@Override
public T getType()
{
return treeData.getType();
}

@Override
public KDTreeCursor copy()
{
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/imglib2/KDTreeNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ public T get()
return values.apply( nodeIndex );
}

@Override
public T getType()
{
return tree.getType();
}

@Override
public KDTreeNode< T > copy()
{
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/imglib2/PointSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ public T get()
return sampleSupplier.get();
}

@Override
public T getType()
{
return get();
}

@Override
public PointSample< T > copy()
{
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/net/imglib2/PointSampleList.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ public T get()
return sample;
}

@Override
public T getType()
{
return sample;
}

@Override
public void fwd()
{
Expand Down Expand Up @@ -228,4 +234,10 @@ public long size()
{
return samples.size();
}

@Override
public T getType()
{
return samples.get( 0 );
}
}
12 changes: 11 additions & 1 deletion src/main/java/net/imglib2/RandomAccessible.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
* @author Stephan Saalfeld
* @author Tobias Pietzsch
*/
public interface RandomAccessible< T > extends EuclideanSpace
public interface RandomAccessible< T > extends EuclideanSpace, Typed< T >
{
/**
* Create a random access sampler for integer coordinates.
Expand Down Expand Up @@ -180,4 +180,14 @@ default T getAt( final Localizable position )
{
return randomAccess().setPositionAndGet( position );
}

/*
* NB: We cannot have a default implementation here because of
* https://bugs.openjdk.org/browse/JDK-7120669
*/
// @Override
// default T getType()
// {
// return randomAccess().get();
// }
}
15 changes: 14 additions & 1 deletion src/main/java/net/imglib2/RandomAccessibleInterval.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

package net.imglib2;

import net.imglib2.util.Intervals;

/**
* <p>
* <em>f</em>:{x&isin;Z<sup><em>n</em></sup>|[min,max]&rarr;T}
Expand All @@ -58,6 +60,17 @@
* </p>
*
* @author Stephan Saalfeld
* @author Philipp Hanslovsky
*/
public interface RandomAccessibleInterval< T > extends RandomAccessible< T >, Interval
{}
{
/*
* NB: We cannot have a default implementation here because of
* https://bugs.openjdk.org/browse/JDK-7120669
*/
// @Override
// default T getType()
// {
// return getAt( Intervals.minAsLongArray( this ) );
// }
}
6 changes: 6 additions & 0 deletions src/main/java/net/imglib2/RealPointSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ public T get()
return sampleSupplier.get();
}

@Override
public T getType()
{
return get();
}

@Override
public RealPointSample< T > copy()
{
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/net/imglib2/RealPointSampleList.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ public T get()
return sample;
}

@Override
public T getType()
{
return sample;
}

@Override
public void fwd()
{
Expand Down Expand Up @@ -212,6 +218,12 @@ public long size()
return samples.size();
}

@Override
public T getType()
{
return samples.get( 0 );
}

@Override
public double realMax( final int d )
{
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/net/imglib2/RealRandomAccessible.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
*
* @author Stephan Saalfeld
*/
public interface RealRandomAccessible< T > extends EuclideanSpace
public interface RealRandomAccessible< T > extends EuclideanSpace, Typed< T >
{
/**
* Create a random access sampler for real coordinates.
Expand Down Expand Up @@ -119,4 +119,14 @@ default T getAt( final RealLocalizable position )
{
return realRandomAccess().setPositionAndGet( position );
}

/*
* NB: We cannot have a default implementation here because of
* https://bugs.openjdk.org/browse/JDK-7120669
*/
// @Override
// default T getType()
// {
// return realRandomAccess().get();
// }
}
14 changes: 13 additions & 1 deletion src/main/java/net/imglib2/RealRandomAccessibleRealInterval.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

package net.imglib2;

import net.imglib2.util.Intervals;

/**
* <p>
* <em>f</em>:{x&isin;R<sup><em>n</em></sup>|[min,max]&rarr;T}
Expand All @@ -60,4 +62,14 @@
* @author Stephan Saalfeld
*/
public interface RealRandomAccessibleRealInterval< T > extends RealRandomAccessible< T >, RealInterval
{}
{
/*
* NB: We cannot have a default implementation here because of
* https://bugs.openjdk.org/browse/JDK-7120669
*/
// @Override
// default T getType()
// {
// return getAt( Intervals.minAsDoubleArray( this ) );
// }
}
8 changes: 7 additions & 1 deletion src/main/java/net/imglib2/Sampler.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* @author Stephan Preibisch
* @author Stephan Saalfeld
*/
public interface Sampler< T >
public interface Sampler< T > extends Typed< T >
{
/**
* Access the actual <em>T</em> instance providing access to a pixel,
Expand All @@ -73,4 +73,10 @@ public interface Sampler< T >
* {@link ArrayCursor} for example)
*/
Sampler< T > copy();

@Override
default T getType()
{
return get();
}
}
15 changes: 15 additions & 0 deletions src/main/java/net/imglib2/Typed.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.imglib2;

public interface Typed< T >
{
/**
* Get an instance of {@code T}.
* <p>
* It should not be assumed that the returned {@code T} instance is an
* independent copy. In particular, repeated calls to {@code getType()} may
* return the same instance.
*
* @return an instance of {@code T}
*/
T getType();
}
Loading