Class BitType
- java.lang.Object
-
- net.imglib2.type.numeric.complex.AbstractComplexType<T>
-
- net.imglib2.type.numeric.real.AbstractRealType<T>
-
- net.imglib2.type.numeric.integer.AbstractIntegerType<BitType>
-
- net.imglib2.type.logic.BitType
-
- All Implemented Interfaces:
java.lang.Comparable<BitType>
,BooleanType<BitType>
,NativeType<BitType>
,ComplexType<BitType>
,IntegerType<BitType>
,NumericType<BitType>
,RealType<BitType>
,Add<BitType>
,Div<BitType>
,Mul<BitType>
,MulFloatingPoint
,SetOne
,SetZero
,Sub<BitType>
,ValueEquals<BitType>
,Type<BitType>
public class BitType extends AbstractIntegerType<BitType> implements BooleanType<BitType>, NativeType<BitType>, IntegerType<BitType>
TODO- Author:
- Stephan Preibisch, Stephan Saalfeld
-
-
Field Summary
Fields Modifier and Type Field Description protected LongAccess
dataAccess
protected int
i
protected NativeImg<?,? extends LongAccess>
img
-
Constructor Summary
Constructors Constructor Description BitType()
BitType(boolean value)
BitType(LongAccess access)
BitType(NativeImg<?,? extends LongAccess> bitStorage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(BitType c)
void
and(BitType c)
int
compareTo(BitType c)
BitType
copy()
NativeImg<BitType,? extends LongAccess>
createSuitableNativeImg(NativeImgFactory<BitType> storageFactory, long[] dim)
TheNativeType
creates theNativeImg
used for storing image data; based on the given storage strategy and its size.BitType
createVariable()
Creates a newType
variable which can only store one value.void
dec()
void
decIndex()
Decrement the index into the current data array.void
decIndex(int decrement)
Decrease the index into the current data array bydecrement
steps.void
div(BitType c)
BitType
duplicateTypeOnSameNativeImg()
Creates a newNativeType
which stores in the same physical array.boolean
get()
java.math.BigInteger
getBigInteger()
int
getBitsPerPixel()
Fraction
getEntitiesPerPixel()
Get the number of entities in the storage array required to store one pixel value.int
getIndex()
Get the current index into the current data array.int
getInteger()
long
getIntegerLong()
double
getMaxValue()
double
getMinValue()
void
inc()
void
incIndex()
Increment the index into the current data array.void
incIndex(int increment)
Increases the index into the current data array byincrement
steps.void
mul(double c)
void
mul(float c)
void
mul(BitType c)
void
not()
void
or(BitType c)
void
set(boolean value)
void
set(BitType c)
Sets the value of anotherType
.void
setBigInteger(java.math.BigInteger b)
void
setInteger(int f)
void
setInteger(long f)
void
setOne()
void
setZero()
void
sub(BitType c)
java.lang.String
toString()
void
updateContainer(java.lang.Object c)
This method is used by an accessor (e.g., aCursor
) to request an update of the current data array.void
updateIndex(int index)
Set the index into the current data array.boolean
valueEquals(BitType t)
void
xor(BitType c)
-
Methods inherited from class net.imglib2.type.numeric.integer.AbstractIntegerType
getMinIncrement, getRealDouble, getRealFloat, hashCode, setReal, setReal
-
Methods inherited from class net.imglib2.type.numeric.real.AbstractRealType
equals, getImaginaryDouble, getImaginaryFloat, getPhaseDouble, getPhaseFloat, getPowerDouble, getPowerFloat, setImaginary, setImaginary
-
Methods inherited from class net.imglib2.type.numeric.complex.AbstractComplexType
complexConjugate, setComplexNumber, setComplexNumber
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.imglib2.type.numeric.ComplexType
complexConjugate, getImaginaryDouble, getImaginaryFloat, getPhaseDouble, getPhaseFloat, getPowerDouble, getPowerFloat, getRealDouble, getRealFloat, setComplexNumber, setComplexNumber, setImaginary, setImaginary, setReal, setReal
-
Methods inherited from interface net.imglib2.type.numeric.RealType
getMinIncrement
-
-
-
-
Field Detail
-
i
protected int i
-
img
protected final NativeImg<?,? extends LongAccess> img
-
dataAccess
protected LongAccess dataAccess
-
-
Constructor Detail
-
BitType
public BitType(NativeImg<?,? extends LongAccess> bitStorage)
-
BitType
public BitType(boolean value)
-
BitType
public BitType(LongAccess access)
-
BitType
public BitType()
-
-
Method Detail
-
createSuitableNativeImg
public NativeImg<BitType,? extends LongAccess> createSuitableNativeImg(NativeImgFactory<BitType> storageFactory, long[] dim)
Description copied from interface:NativeType
TheNativeType
creates theNativeImg
used for storing image data; based on the given storage strategy and its size. It basically only decides here which BasicType it uses (float, int, byte, bit, ...) and how many entities per pixel it needs (e.g. 2 floats per pixel for a complex number). This enables the separation of containers and the basic types.- Specified by:
createSuitableNativeImg
in interfaceNativeType<BitType>
- Parameters:
storageFactory
- which storage strategy is useddim
- the dimensions- Returns:
- the instantiated
NativeImg
where only theType
knows the BasicType it contains.
-
updateContainer
public void updateContainer(java.lang.Object c)
Description copied from interface:NativeType
This method is used by an accessor (e.g., aCursor
) to request an update of the current data array.As an example consider a
CellCursor
moving on aCellImg
. The cursor maintains aNativeType
which provides access to the image data. When the cursor moves from one cell to the next, the underlying data array of theNativeType
must be switched to the data array of the new cell.To achieve this, the
CellCursor
callsupdateContainer()
with itself as the argument.updateContainer()
in turn will callNativeImg.update(Object)
on it's container, passing along the reference to the cursor. In this example, the container would be aCellImg
. While theNativeType
does not know about the type of the cursor, the container does.CellImg
knows that it is passed aCellCursor
instance, which can be used to figure out the current cell and the underlying data array, which is then returned to theNativeType
.The idea behind this concept is maybe not obvious. The
NativeType
knows which basic type is used (float, int, byte, ...). However, it does not know how the data is stored (ArrayImg
,CellImg
, ...). This prevents the need for multiple implementations ofNativeType
.- Specified by:
updateContainer
in interfaceNativeType<BitType>
- Parameters:
c
- reference to an accessor which can be passed on to the container (which will know what to do with it).
-
duplicateTypeOnSameNativeImg
public BitType duplicateTypeOnSameNativeImg()
Description copied from interface:NativeType
Creates a newNativeType
which stores in the same physical array. This is only used internally.- Specified by:
duplicateTypeOnSameNativeImg
in interfaceNativeType<BitType>
- Returns:
- a new
NativeType
instance working on the sameNativeImg
-
get
public boolean get()
- Specified by:
get
in interfaceBooleanType<BitType>
-
set
public void set(boolean value)
- Specified by:
set
in interfaceBooleanType<BitType>
-
getInteger
public int getInteger()
- Specified by:
getInteger
in interfaceIntegerType<BitType>
-
getIntegerLong
public long getIntegerLong()
- Specified by:
getIntegerLong
in interfaceIntegerType<BitType>
-
getBigInteger
public java.math.BigInteger getBigInteger()
- Specified by:
getBigInteger
in interfaceIntegerType<BitType>
-
setInteger
public void setInteger(int f)
- Specified by:
setInteger
in interfaceIntegerType<BitType>
-
setInteger
public void setInteger(long f)
- Specified by:
setInteger
in interfaceIntegerType<BitType>
-
setBigInteger
public void setBigInteger(java.math.BigInteger b)
- Specified by:
setBigInteger
in interfaceIntegerType<BitType>
-
getMaxValue
public double getMaxValue()
- Specified by:
getMaxValue
in interfaceRealType<BitType>
-
getMinValue
public double getMinValue()
- Specified by:
getMinValue
in interfaceRealType<BitType>
-
set
public void set(BitType c)
Description copied from interface:Type
Sets the value of anotherType
.
-
and
public void and(BitType c)
- Specified by:
and
in interfaceBooleanType<BitType>
-
or
public void or(BitType c)
- Specified by:
or
in interfaceBooleanType<BitType>
-
xor
public void xor(BitType c)
- Specified by:
xor
in interfaceBooleanType<BitType>
-
not
public void not()
- Specified by:
not
in interfaceBooleanType<BitType>
-
add
public void add(BitType c)
-
div
public void div(BitType c)
-
mul
public void mul(BitType c)
-
sub
public void sub(BitType c)
-
mul
public void mul(float c)
- Specified by:
mul
in interfaceMulFloatingPoint
- Overrides:
mul
in classAbstractRealType<BitType>
-
mul
public void mul(double c)
- Specified by:
mul
in interfaceMulFloatingPoint
- Overrides:
mul
in classAbstractRealType<BitType>
-
setOne
public void setOne()
- Specified by:
setOne
in interfaceSetOne
- Overrides:
setOne
in classAbstractIntegerType<BitType>
-
setZero
public void setZero()
- Specified by:
setZero
in interfaceSetZero
- Overrides:
setZero
in classAbstractIntegerType<BitType>
-
inc
public void inc()
-
dec
public void dec()
-
compareTo
public int compareTo(BitType c)
- Specified by:
compareTo
in interfacejava.lang.Comparable<BitType>
- Overrides:
compareTo
in classAbstractIntegerType<BitType>
-
createVariable
public BitType createVariable()
Description copied from interface:Type
Creates a newType
variable which can only store one value.- Specified by:
createVariable
in interfaceType<BitType>
- Returns:
- a new
Type
variable
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractIntegerType<BitType>
-
getEntitiesPerPixel
public Fraction getEntitiesPerPixel()
Description copied from interface:NativeType
Get the number of entities in the storage array required to store one pixel value. A pixel value may be spread over several or less than one entity. For example, a complex number may require 2 entries of a float[] array to store one pixel. Or a 12-bit type might need 12/64th entries of a long[] array.- Specified by:
getEntitiesPerPixel
in interfaceNativeType<BitType>
- Returns:
- the number of storage type entities required to store one pixel value.
-
updateIndex
public void updateIndex(int index)
Description copied from interface:NativeType
Set the index into the current data array.This is used by accessors (e.g., a
Cursor
) to position theNativeType
in the container.- Specified by:
updateIndex
in interfaceNativeType<BitType>
- Parameters:
index
- the new array index
-
getIndex
public int getIndex()
Description copied from interface:NativeType
Get the current index into the current data array.This is used by accessors (e.g., a
Cursor
) to position theNativeType
in the container.- Specified by:
getIndex
in interfaceNativeType<BitType>
- Returns:
- the current index into the underlying data array
-
incIndex
public void incIndex()
Description copied from interface:NativeType
Increment the index into the current data array.This is used by accessors (e.g., a
Cursor
) to position theNativeType
in the container.- Specified by:
incIndex
in interfaceNativeType<BitType>
-
incIndex
public void incIndex(int increment)
Description copied from interface:NativeType
Increases the index into the current data array byincrement
steps.This is used by accessors (e.g., a
Cursor
) to position theNativeType
in the container.- Specified by:
incIndex
in interfaceNativeType<BitType>
- Parameters:
increment
- how many steps
-
decIndex
public void decIndex()
Description copied from interface:NativeType
Decrement the index into the current data array.This is used by accessors (e.g., a
Cursor
) to position theNativeType
in the container.- Specified by:
decIndex
in interfaceNativeType<BitType>
-
decIndex
public void decIndex(int decrement)
Description copied from interface:NativeType
Decrease the index into the current data array bydecrement
steps.This is used by accessors (e.g., a
Cursor
) to position theNativeType
in the container.- Specified by:
decIndex
in interfaceNativeType<BitType>
- Parameters:
decrement
- how many steps
-
getBitsPerPixel
public int getBitsPerPixel()
- Specified by:
getBitsPerPixel
in interfaceRealType<BitType>
-
valueEquals
public boolean valueEquals(BitType t)
- Specified by:
valueEquals
in interfaceValueEquals<BitType>
-
-