Skip to content

Commit

Permalink
Override II default methods 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 17eaef2 commit 4a9a547
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/net/imglib2/roi/labeling/LabelRegion.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class LabelRegion< T > extends PositionableInterval implements Positionab

private final ArrayList< TIntArrayList > itcodes;

private long size;
private long insideSize;

private final RealPoint centerOfMass;

Expand All @@ -93,7 +93,7 @@ public LabelRegion( final LabelRegions< T > regions, final LabelRegionProperties
this.regionProperties = regionProperties;
this.label = label;
expectedGeneration = regionProperties.update();
size = regionProperties.getSize();
insideSize = regionProperties.getSize();
itcodes = regionProperties.getItcodes();
centerOfMass = RealPoint.wrap( regionProperties.getCenterOfMass() );
inside = new LabelRegionIterable();
Expand All @@ -109,7 +109,7 @@ protected LabelRegion( final LabelRegion< T > other )
this.regionProperties = other.regionProperties;
this.label = other.label;
this.expectedGeneration = other.expectedGeneration;
this.size = other.size;
this.insideSize = other.insideSize;
this.itcodes = other.itcodes;
this.centerOfMass = other.centerOfMass;
this.inside = new LabelRegionIterable();
Expand Down Expand Up @@ -153,7 +153,7 @@ private void update()
initialMin[ d ] = bbmin[ d ];
initialMax[ d ] = bbmax[ d ];
}
size = regionProperties.getSize();
insideSize = regionProperties.getSize();
}
}

Expand Down Expand Up @@ -215,7 +215,7 @@ public LabelRegionCursor localizingCursor()
@Override
public long size()
{
return LabelRegion.this.size();
return LabelRegion.this.insideSize();
}

@Override
Expand Down Expand Up @@ -267,10 +267,10 @@ public long max( final int d )
}
}

public long size()
private long insideSize()
{
update();
return size;
return insideSize;
}

@Override
Expand Down
24 changes: 24 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,30 @@ public RandomAccess< T > randomAccess( final Interval interval )
return sourceInterval.randomAccess( interval );
}

@Override
public Cursor< T > cursor()
{
return sourceInterval.cursor();
}

@Override
public Cursor< T > localizingCursor()
{
return sourceInterval.localizingCursor();
}

@Override
public Object iterationOrder()
{
return sourceInterval.iterationOrder();
}

@Override
public long size()
{
return sourceInterval.size();
}

@Override
public T getType()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,30 @@ public RandomAccess< T > randomAccess( final Interval interval )
return new RA( source.randomAccess( Intervals.translate( interval, currentOffset ) ), currentOffset );
}

@Override
public Cursor< T > cursor()
{
return new C( source.cursor(), currentOffset );
}

@Override
public Cursor< T > localizingCursor()
{
return new C( source.localizingCursor(), currentOffset );
}

@Override
public Object iterationOrder()
{
return this;
}

@Override
public long size()
{
return source.size();
}

@Override
public T getType()
{
Expand Down Expand Up @@ -116,6 +140,56 @@ public RA copy()
}
}

private final class C extends OffsetLocalizable< Cursor< T > > implements Cursor< T >
{
public C( final Cursor< T > cursor, final long[] offset )
{
super( cursor, offset );
}

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

@Override
public void jumpFwd( final long steps )
{
source.jumpFwd( steps );
}

@Override
public void fwd()
{
source.fwd();
}

@Override
public void reset()
{
source.reset();
}

@Override
public boolean hasNext()
{
return source.hasNext();
}

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

@Override
public C copy()
{
return new C( source.copy(), offset );
}
}

@Override
public PositionableWrappedIterableRegion< T > copy()
{
Expand Down

0 comments on commit 4a9a547

Please sign in to comment.