Permalink
Browse files

Update RealOperators to use generics

This allows the operator classes to be used for BitType or BoolType.
  • Loading branch information...
awalter17 committed Jan 27, 2017
1 parent 9323653 commit 8ee318bc516e0b165277967446b749f2a1832423
@@ -38,7 +38,7 @@
import net.imglib2.RealPositionable;
import net.imglib2.RealRandomAccess;
import net.imglib2.RealRandomAccessibleRealInterval;
import net.imglib2.type.logic.BoolType;
import net.imglib2.type.BooleanType;
/**
* This is an abstract class as base for all binary operators which allow
@@ -50,24 +50,24 @@
* @version 1.0.0 Jan 14, 2016
*
*/
public abstract class AbstractRealBinaryOperator extends AbstractRealInterval implements RealBinaryOperator
public abstract class AbstractRealBinaryOperator< B extends BooleanType< B > > extends AbstractRealInterval implements RealBinaryOperator< B >
{
protected final RealRandomAccessibleRealInterval< BoolType > leftOperand;
protected final RealRandomAccessibleRealInterval< B > leftOperand;
protected final RealRandomAccessibleRealInterval< BoolType > rightOperand;
protected final RealRandomAccessibleRealInterval< B > rightOperand;
public AbstractRealBinaryOperator( final RealRandomAccessibleRealInterval< BoolType > leftOperand, final RealRandomAccessibleRealInterval< BoolType > rightOperand )
public AbstractRealBinaryOperator( final RealRandomAccessibleRealInterval< B > leftOperand, final RealRandomAccessibleRealInterval< B > rightOperand )
{
super( leftOperand.numDimensions() );
this.leftOperand = leftOperand;
this.rightOperand = rightOperand;
}
@Override
public abstract RealRandomAccess< BoolType > realRandomAccess();
public abstract RealRandomAccess< B > realRandomAccess();
@Override
public RealRandomAccess< BoolType > realRandomAccess( final RealInterval interval )
public RealRandomAccess< B > realRandomAccess( final RealInterval interval )
{
return realRandomAccess();
}
@@ -113,13 +113,13 @@ public void realMax( final RealPositionable realMax )
}
@Override
public RealRandomAccessibleRealInterval< BoolType > getA()
public RealRandomAccessibleRealInterval< B > getA()
{
return leftOperand;
}
@Override
public RealRandomAccessibleRealInterval< BoolType > getB()
public RealRandomAccessibleRealInterval< B > getB()
{
return rightOperand;
}
@@ -36,6 +36,7 @@
import net.imglib2.RealPoint;
import net.imglib2.RealRandomAccess;
import net.imglib2.RealRandomAccessibleRealInterval;
import net.imglib2.type.BooleanType;
import net.imglib2.type.logic.BoolType;
import net.imglib2.util.Util;
@@ -45,23 +46,23 @@
*
* @author Alison Walter
*/
public abstract class AbstractRealBinaryOperatorRealRandomAccess extends RealPoint implements RealBinaryOperatorRealRandomAccess
public abstract class AbstractRealBinaryOperatorRealRandomAccess< B extends BooleanType< B > > extends RealPoint implements RealBinaryOperatorRealRandomAccess< B >
{
private final RealRandomAccess< BoolType > leftOperandRA;
private final RealRandomAccess< B > leftOperandRA;
private final RealRandomAccess< BoolType > rightOperandRA;
private final RealRandomAccess< B > rightOperandRA;
protected final BoolType type;
protected final B type;
public AbstractRealBinaryOperatorRealRandomAccess( final RealRandomAccessibleRealInterval< BoolType > leftOperand, final RealRandomAccessibleRealInterval< BoolType > rightOperand )
public AbstractRealBinaryOperatorRealRandomAccess( final RealRandomAccessibleRealInterval< B > leftOperand, final RealRandomAccessibleRealInterval< B > rightOperand )
{
super( leftOperand.numDimensions() );
this.leftOperandRA = leftOperand.realRandomAccess();
this.rightOperandRA = rightOperand.realRandomAccess();
type = new BoolType();
type = Util.getTypeFromRealInterval( leftOperand ).copy();
}
protected AbstractRealBinaryOperatorRealRandomAccess( final RealBinaryOperatorRealRandomAccess rborra )
protected AbstractRealBinaryOperatorRealRandomAccess( final RealBinaryOperatorRealRandomAccess< B > rborra )
{
super( rborra.numDimensions() );
leftOperandRA = rborra.getLeftOperandRealRandomAccess();
@@ -70,27 +71,27 @@ protected AbstractRealBinaryOperatorRealRandomAccess( final RealBinaryOperatorRe
}
@Override
public RealRandomAccess< BoolType > getLeftOperandRealRandomAccess()
public RealRandomAccess< B > getLeftOperandRealRandomAccess()
{
return leftOperandRA;
}
@Override
public RealRandomAccess< BoolType > getRightOperandRealRandomAccess()
public RealRandomAccess< B > getRightOperandRealRandomAccess()
{
return rightOperandRA;
}
@Override
public RealRandomAccess< BoolType > copyRealRandomAccess()
public RealRandomAccess< B > copyRealRandomAccess()
{
return copy();
}
@Override
public abstract BoolType get();
public abstract B get();
@Override
public abstract RealRandomAccess< BoolType > copy();
public abstract RealRandomAccess< B > copy();
}
@@ -35,6 +35,7 @@
import net.imglib2.RealRandomAccess;
import net.imglib2.RealRandomAccessibleRealInterval;
import net.imglib2.type.BooleanType;
import net.imglib2.type.logic.BoolType;
/**
@@ -46,26 +47,26 @@
* @version 1.0.0 Jan 14, 2016
*
*/
public class RealBinaryExclusiveOr extends AbstractRealBinaryOperator
public class RealBinaryExclusiveOr< B extends BooleanType< B > > extends AbstractRealBinaryOperator< B >
{
public RealBinaryExclusiveOr( final RealRandomAccessibleRealInterval< BoolType > leftOperand, final RealRandomAccessibleRealInterval< BoolType > rightOperand )
public RealBinaryExclusiveOr( final RealRandomAccessibleRealInterval< B > leftOperand, final RealRandomAccessibleRealInterval< B > rightOperand )
{
super( leftOperand, rightOperand );
}
@Override
public RealRandomAccess< BoolType > realRandomAccess()
public RealRandomAccess< B > realRandomAccess()
{
return new RealBinaryExclusiveOrRealRandomAccess( leftOperand, rightOperand );
}
private class RealBinaryExclusiveOrRealRandomAccess extends AbstractRealBinaryOperatorRealRandomAccess
private class RealBinaryExclusiveOrRealRandomAccess extends AbstractRealBinaryOperatorRealRandomAccess< B >
{
private final RealRandomAccess< BoolType > leftRRA;
private final RealRandomAccess< B > leftRRA;
private final RealRandomAccess< BoolType > rightRRA;
private final RealRandomAccess< B > rightRRA;
public RealBinaryExclusiveOrRealRandomAccess( final RealRandomAccessibleRealInterval< BoolType > leftOperand, final RealRandomAccessibleRealInterval< BoolType > rightOperand )
public RealBinaryExclusiveOrRealRandomAccess( final RealRandomAccessibleRealInterval< B > leftOperand, final RealRandomAccessibleRealInterval< B > rightOperand )
{
super( leftOperand, rightOperand );
leftRRA = getLeftOperandRealRandomAccess();
@@ -80,7 +81,7 @@ private RealBinaryExclusiveOrRealRandomAccess( final RealBinaryExclusiveOrRealRa
}
@Override
public BoolType get()
public B get()
{
leftRRA.setPosition( this );
rightRRA.setPosition( this );
@@ -35,6 +35,7 @@
import net.imglib2.RealRandomAccess;
import net.imglib2.RealRandomAccessibleRealInterval;
import net.imglib2.type.BooleanType;
import net.imglib2.type.logic.BoolType;
/**
@@ -47,26 +48,26 @@
* @version 1.0.0 Jan 14, 2016
*
*/
public class RealBinaryIntersection extends AbstractRealBinaryOperator
public class RealBinaryIntersection< B extends BooleanType< B > > extends AbstractRealBinaryOperator< B >
{
public RealBinaryIntersection( final RealRandomAccessibleRealInterval< BoolType > leftOperand, final RealRandomAccessibleRealInterval< BoolType > rightOperand )
public RealBinaryIntersection( final RealRandomAccessibleRealInterval< B > leftOperand, final RealRandomAccessibleRealInterval< B > rightOperand )
{
super( leftOperand, rightOperand );
}
@Override
public RealRandomAccess< BoolType > realRandomAccess()
public RealRandomAccess< B > realRandomAccess()
{
return new RealBinaryIntersectionRealRandomAccess( leftOperand, rightOperand );
}
private class RealBinaryIntersectionRealRandomAccess extends AbstractRealBinaryOperatorRealRandomAccess
private class RealBinaryIntersectionRealRandomAccess extends AbstractRealBinaryOperatorRealRandomAccess< B >
{
private final RealRandomAccess< BoolType > leftRRA;
private final RealRandomAccess< B > leftRRA;
private final RealRandomAccess< BoolType > rightRRA;
private final RealRandomAccess< B > rightRRA;
public RealBinaryIntersectionRealRandomAccess( final RealRandomAccessibleRealInterval< BoolType > leftOperand, final RealRandomAccessibleRealInterval< BoolType > rightOperand )
public RealBinaryIntersectionRealRandomAccess( final RealRandomAccessibleRealInterval< B > leftOperand, final RealRandomAccessibleRealInterval< B > rightOperand )
{
super( leftOperand, rightOperand );
leftRRA = getLeftOperandRealRandomAccess();
@@ -81,7 +82,7 @@ private RealBinaryIntersectionRealRandomAccess( final RealBinaryIntersectionReal
}
@Override
public BoolType get()
public B get()
{
leftRRA.setPosition( this );
rightRRA.setPosition( this );
@@ -35,7 +35,7 @@
package net.imglib2.roi.operators;
import net.imglib2.RealRandomAccessibleRealInterval;
import net.imglib2.type.logic.BoolType;
import net.imglib2.type.BooleanType;
import net.imglib2.util.Pair;
/**
@@ -45,5 +45,5 @@
*
* @author Alison Walter
*/
public interface RealBinaryOperator extends RealRandomAccessibleRealInterval< BoolType >, Pair< RealRandomAccessibleRealInterval< BoolType >, RealRandomAccessibleRealInterval< BoolType > >
public interface RealBinaryOperator< B extends BooleanType< B > > extends RealRandomAccessibleRealInterval< B >, Pair< RealRandomAccessibleRealInterval< B >, RealRandomAccessibleRealInterval< B > >
{}
@@ -34,17 +34,17 @@
package net.imglib2.roi.operators;
import net.imglib2.RealRandomAccess;
import net.imglib2.type.logic.BoolType;
import net.imglib2.type.BooleanType;
/**
* Represents a {@link RealRandomAccess} for combined regions of interest.
*
* @author Alison Walter
*/
public interface RealBinaryOperatorRealRandomAccess extends RealRandomAccess< BoolType >
public interface RealBinaryOperatorRealRandomAccess< B extends BooleanType< B > > extends RealRandomAccess< B >
{
RealRandomAccess< BoolType > getLeftOperandRealRandomAccess();
RealRandomAccess< B > getLeftOperandRealRandomAccess();
RealRandomAccess< BoolType > getRightOperandRealRandomAccess();
RealRandomAccess< B > getRightOperandRealRandomAccess();
}
@@ -35,7 +35,7 @@
import net.imglib2.RealRandomAccess;
import net.imglib2.RealRandomAccessibleRealInterval;
import net.imglib2.type.logic.BoolType;
import net.imglib2.type.BooleanType;
/**
* This class represents the difference of two regions of interest.
@@ -45,26 +45,26 @@
* @version 1.0.0 Jan 14, 2016
*
*/
public class RealBinarySubtraction extends AbstractRealBinaryOperator
public class RealBinarySubtraction< B extends BooleanType< B > > extends AbstractRealBinaryOperator< B >
{
public RealBinarySubtraction( final RealRandomAccessibleRealInterval< BoolType > leftOperand, final RealRandomAccessibleRealInterval< BoolType > rightOperand )
public RealBinarySubtraction( final RealRandomAccessibleRealInterval< B > leftOperand, final RealRandomAccessibleRealInterval< B > rightOperand )
{
super( leftOperand, rightOperand );
}
@Override
public RealRandomAccess< BoolType > realRandomAccess()
public RealRandomAccess< B > realRandomAccess()
{
return new RealBinarySubtractionRealRandomAccess( leftOperand, rightOperand );
}
private class RealBinarySubtractionRealRandomAccess extends AbstractRealBinaryOperatorRealRandomAccess
private class RealBinarySubtractionRealRandomAccess extends AbstractRealBinaryOperatorRealRandomAccess< B >
{
private final RealRandomAccess< BoolType > leftRRA;
private final RealRandomAccess< B > leftRRA;
private final RealRandomAccess< BoolType > rightRRA;
private final RealRandomAccess< B > rightRRA;
public RealBinarySubtractionRealRandomAccess( final RealRandomAccessibleRealInterval< BoolType > leftOperand, final RealRandomAccessibleRealInterval< BoolType > rightOperand )
public RealBinarySubtractionRealRandomAccess( final RealRandomAccessibleRealInterval< B > leftOperand, final RealRandomAccessibleRealInterval< B > rightOperand )
{
super( leftOperand, rightOperand );
leftRRA = getLeftOperandRealRandomAccess();
@@ -79,7 +79,7 @@ private RealBinarySubtractionRealRandomAccess( final RealBinarySubtractionRealRa
}
@Override
public BoolType get()
public B get()
{
leftRRA.setPosition( this );
rightRRA.setPosition( this );
@@ -35,6 +35,7 @@
import net.imglib2.RealRandomAccess;
import net.imglib2.RealRandomAccessibleRealInterval;
import net.imglib2.type.BooleanType;
import net.imglib2.type.logic.BoolType;
/**
@@ -47,26 +48,26 @@
* @version 1.0.0 Jan 14, 2016
*
*/
public class RealBinaryUnion extends AbstractRealBinaryOperator
public class RealBinaryUnion< B extends BooleanType< B > > extends AbstractRealBinaryOperator< B >
{
public RealBinaryUnion( final RealRandomAccessibleRealInterval< BoolType > leftOperand, final RealRandomAccessibleRealInterval< BoolType > rightOperand )
public RealBinaryUnion( final RealRandomAccessibleRealInterval< B > leftOperand, final RealRandomAccessibleRealInterval< B > rightOperand )
{
super( leftOperand, rightOperand );
}
@Override
public RealRandomAccess< BoolType > realRandomAccess()
public RealRandomAccess< B > realRandomAccess()
{
return new RealBinaryUnionRealRandomAccess( leftOperand, rightOperand );
}
private class RealBinaryUnionRealRandomAccess extends AbstractRealBinaryOperatorRealRandomAccess
private class RealBinaryUnionRealRandomAccess extends AbstractRealBinaryOperatorRealRandomAccess< B >
{
private final RealRandomAccess< BoolType > leftRRA;
private final RealRandomAccess< B > leftRRA;
private final RealRandomAccess< BoolType > rightRRA;
private final RealRandomAccess< B > rightRRA;
public RealBinaryUnionRealRandomAccess( final RealRandomAccessibleRealInterval< BoolType > leftOperand, final RealRandomAccessibleRealInterval< BoolType > rightOperand )
public RealBinaryUnionRealRandomAccess( final RealRandomAccessibleRealInterval< B > leftOperand, final RealRandomAccessibleRealInterval< B > rightOperand )
{
super( leftOperand, rightOperand );
leftRRA = getLeftOperandRealRandomAccess();
@@ -81,7 +82,7 @@ private RealBinaryUnionRealRandomAccess( final RealBinaryUnionRealRandomAccess r
}
@Override
public BoolType get()
public B get()
{
leftRRA.setPosition( this );
rightRRA.setPosition( this );
Oops, something went wrong.

0 comments on commit 8ee318b

Please sign in to comment.