Skip to content

Commit

Permalink
Implement Typed::getType where it makes sense
Browse files Browse the repository at this point in the history
  • Loading branch information
tpietzsch committed May 7, 2024
1 parent d67517c commit 17eaef2
Show file tree
Hide file tree
Showing 24 changed files with 212 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/main/java/net/imglib2/labeling/DefaultROIStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import net.imglib2.roi.AbstractIterableRegionOfInterest;
import net.imglib2.roi.IterableRegionOfInterest;
import net.imglib2.roi.RegionOfInterest;
import net.imglib2.type.logic.BitType;

/**
* A relatively conservative strategy suitable for blobby objects - retain the
Expand Down Expand Up @@ -329,6 +330,11 @@ public void move( final double[] displacement )
throw new UnsupportedOperationException( "yet to be implemented" );
}

@Override
public BitType getType()
{
return new BitType();
}
}

@Override
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/imglib2/labeling/NativeImgLabeling.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,10 @@ public Cursor< LabelingType< T > > localizingCursor( final Interval interval )

return new LabelingConvertedCursor< I, T >( c, generation, mapping );
}

@Override
public LabelingType< T > getType()
{
return new LabelingType<>( null, mapping, generation );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ public T get()
return randomAccess.get();
}

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

@Override
public void jumpFwd( final long steps )
{
Expand Down Expand Up @@ -402,6 +408,12 @@ public long size()
return getCachedSize();
}

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

@Override
public T firstElement()
{
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/net/imglib2/roi/BinaryMaskRegionOfInterest.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ public TT get()
return src.get();
}

@Override
public TT getType()
{
return src.getType();
}

@Override
public void fwd()
{
Expand Down Expand Up @@ -215,6 +221,12 @@ public TT firstElement()
return src.get();
}

@Override
public TT getType()
{
return src.getType();
}

@Override
public Object iterationOrder()
{
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/imglib2/roi/RegionOfInterest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,10 @@ public interface RegionOfInterest extends RealRandomAccessibleRealInterval< BitT
void move( double displacement, int d );

void move( double[] displacement );

@Override
default BitType getType()
{
return new BitType();
}
}
16 changes: 14 additions & 2 deletions src/main/java/net/imglib2/roi/boundary/Boundary.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand Down Expand Up @@ -135,6 +135,12 @@ public RandomAccess< BoolType > randomAccess( final Interval interval )
return randomAccess();
}

@Override
public BoolType getType()
{
return new BoolType();
}

private final class BoundaryIterable extends AbstractWrappedInterval< Interval > implements IterableInterval< Void >
{
BoundaryIterable()
Expand Down Expand Up @@ -177,6 +183,12 @@ public Void firstElement()
{
return cursor().next();
}

@Override
public Void getType()
{
return null;
}
}

private final class BoundaryCursor extends Point implements Cursor< Void >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ public BoolType get()
return type;
}

@Override
public BoolType getType()
{
return type;
}

@Override
public BoundaryRandomAccess4< T > copy()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ public BoolType get()
return type;
}

@Override
public BoolType getType()
{
return type;
}

@Override
public BoundaryRandomAccess8< T > copy()
{
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/imglib2/roi/geom/integer/IterableLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ public Cursor< Void > localizingCursor()
return new LineCursor();
}

@Override
public Void getType()
{
return null;
}

private final class LineCursor implements Cursor< Void >
{

Expand Down
18 changes: 18 additions & 0 deletions src/main/java/net/imglib2/roi/labeling/ImgLabeling.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ public LabelingType< T > get()
return type;
}

@Override
public LabelingType< T > getType()
{
return type;
}

@Override
public LabelingConvertedRandomAccess copy()
{
Expand All @@ -191,6 +197,12 @@ public LabelingType< T > get()
return type;
}

@Override
public LabelingType< T > getType()
{
return type;
}

@Override
public LabelingConvertedCursor copy()
{
Expand Down Expand Up @@ -228,6 +240,12 @@ public LabelingType< T > firstElement()
return cursor().next();
}

@Override
public LabelingType< T > getType()
{
return new LabelingType<>( null, mapping, generation );
}

@Override
public Iterator< LabelingType< T > > iterator()
{
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/net/imglib2/roi/labeling/LabelRegion.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ public RandomAccess< BoolType > randomAccess( final Interval interval )
return new OutOfBoundsConstantValue<>( this, new BoolType( false ) );
}

@Override
public BoolType getType()
{
return new BoolType();
}

@Override
public PositionableIterableInterval< Void > inside()
{
Expand Down Expand Up @@ -218,6 +224,12 @@ public Void firstElement()
return null;
}

@Override
public Void getType()
{
return null;
}

@Override
public Object iterationOrder()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public BoolType get()
return type;
}

@Override
public BoolType getType()
{
return type;
}

@Override
public LabelRegionRandomAccess< T > copy()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,9 @@ public RandomAccess< B > randomAccess( final Interval interval )
return randomAccess();
}

@Override
public B getType()
{
return type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,10 @@ public RandomAccess< B > randomAccess( final Interval interval )
{
return randomAccess();
}

@Override
public B getType()
{
return type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public B get()
return type;
}

@Override
public B getType()
{
return type;
}

@Override
public MaskPredicateRandomAccess< B > copy()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ public B get()
return type;
}

@Override
public B getType()
{
return type;
}

@Override
public MaskPredicateRealRandomAccess< B > copy()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,9 @@ public RealRandomAccess< B > realRandomAccess( final RealInterval interval )
return realRandomAccess();
}

@Override
public B getType()
{
return type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,10 @@ public RealRandomAccess< B > realRandomAccess( final RealInterval interval )
{
return realRandomAccess();
}

@Override
public B getType()
{
return type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ public RandomAccess< T > randomAccess( final Interval interval )
return sourceInterval.randomAccess( interval );
}

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

@Override
public IterableInterval< Void > inside()
{
Expand Down Expand Up @@ -140,5 +146,11 @@ public Cursor< Void > localizingCursor()
{
return cursor();
}

@Override
public Void getType()
{
return null;
}
}
}
12 changes: 12 additions & 0 deletions src/main/java/net/imglib2/roi/util/IterableRegionOnBooleanRAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ public RandomAccess< T > randomAccess( final Interval interval )
return sourceInterval.randomAccess( interval );
}

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

@Override
public IterableInterval< Void > inside()
{
Expand Down Expand Up @@ -139,5 +145,11 @@ public Cursor< Void > localizingCursor()
{
return new TrueCursor< T >( sourceIterable.localizingCursor(), size );
}

@Override
public Void getType()
{
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ public Cursor< T > localizingCursor()
return new PositionableIterableIntervalCursor( source.localizingCursor() );
}

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

class PositionableIterableIntervalCursor extends OffsetLocalizable< Cursor< T > > implements Cursor< T >
{
public PositionableIterableIntervalCursor( final Cursor< T > cursor )
Expand All @@ -119,6 +125,12 @@ public T get()
return source.get();
}

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

@Override
public void jumpFwd( final long steps )
{
Expand Down
Loading

0 comments on commit 17eaef2

Please sign in to comment.