Class BasePairCharType
- java.lang.Object
-
- net.imglib2.type.AbstractNativeType<BasePairCharType>
-
- net.imglib2.type.label.BasePairCharType
-
- All Implemented Interfaces:
java.lang.Comparable<BasePairCharType>
,BasePairType<BasePairCharType>
,NativeType<BasePairCharType>
,ValueEquals<BasePairCharType>
,Type<BasePairCharType>
public class BasePairCharType extends AbstractNativeType<BasePairCharType> implements BasePairType<BasePairCharType>
Representation of base pairs using one char per entry, supported characters: gap, N, A, T, G, C, U Bases are handled using theBasePairBitType.Base
enumeration.- Author:
- Stephan Preibisch, Stephan Saalfeld
-
-
Field Summary
Fields Modifier and Type Field Description protected CharAccess
dataAccess
protected NativeImg<?,? extends CharAccess>
img
-
Fields inherited from class net.imglib2.type.AbstractNativeType
i
-
-
Constructor Summary
Constructors Constructor Description BasePairCharType()
BasePairCharType(char value)
BasePairCharType(NativeImg<?,? extends CharAccess> charStorage)
BasePairCharType(BasePairBitType.Base value)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte
baseToValue()
int
compareTo(BasePairCharType c)
void
complement()
BasePairCharType
copy()
NativeImg<BasePairCharType,? extends CharAccess>
createSuitableNativeImg(NativeImgFactory<BasePairCharType> storageFactory, long[] dim)
TheNativeType
creates theNativeImg
used for storing image data; based on the given storage strategy and its size.BasePairCharType
createVariable()
Creates a newType
variable which can only store one value.BasePairCharType
duplicateTypeOnSameNativeImg()
Creates a newNativeType
which stores in the same physical array.BasePairBitType.Base
get()
char
getChar()
Fraction
getEntitiesPerPixel()
Get the number of entities in the storage array required to store one pixel value.void
set(BasePairBitType.Base base)
void
set(BasePairCharType c)
Sets the value of anotherType
.void
setChar(char f)
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.boolean
valueEquals(BasePairCharType t)
-
Methods inherited from class net.imglib2.type.AbstractNativeType
decIndex, decIndex, getIndex, incIndex, incIndex, updateIndex
-
-
-
-
Field Detail
-
img
protected final NativeImg<?,? extends CharAccess> img
-
dataAccess
protected CharAccess dataAccess
-
-
Constructor Detail
-
BasePairCharType
public BasePairCharType(NativeImg<?,? extends CharAccess> charStorage)
-
BasePairCharType
public BasePairCharType(BasePairBitType.Base value)
-
BasePairCharType
public BasePairCharType(char value)
-
BasePairCharType
public BasePairCharType()
-
-
Method Detail
-
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<BasePairCharType>
- Returns:
- the number of storage type entities required to store one pixel value.
-
createSuitableNativeImg
public NativeImg<BasePairCharType,? extends CharAccess> createSuitableNativeImg(NativeImgFactory<BasePairCharType> 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<BasePairCharType>
- 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<BasePairCharType>
- Parameters:
c
- reference to an accessor which can be passed on to the container (which will know what to do with it).
-
duplicateTypeOnSameNativeImg
public BasePairCharType 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<BasePairCharType>
- Returns:
- a new
NativeType
instance working on the sameNativeImg
-
getChar
public char getChar()
-
setChar
public void setChar(char f)
-
set
public void set(BasePairBitType.Base base)
- Specified by:
set
in interfaceBasePairType<BasePairCharType>
-
get
public BasePairBitType.Base get()
- Specified by:
get
in interfaceBasePairType<BasePairCharType>
-
set
public void set(BasePairCharType c)
Description copied from interface:Type
Sets the value of anotherType
.- Specified by:
set
in interfaceType<BasePairCharType>
- Parameters:
c
- the new value
-
compareTo
public int compareTo(BasePairCharType c)
- Specified by:
compareTo
in interfacejava.lang.Comparable<BasePairCharType>
-
complement
public void complement()
- Specified by:
complement
in interfaceBasePairType<BasePairCharType>
-
baseToValue
public byte baseToValue()
- Specified by:
baseToValue
in interfaceBasePairType<BasePairCharType>
-
createVariable
public BasePairCharType createVariable()
Description copied from interface:Type
Creates a newType
variable which can only store one value.- Specified by:
createVariable
in interfaceType<BasePairCharType>
- Returns:
- a new
Type
variable
-
copy
public BasePairCharType copy()
Description copied from interface:Type
- Specified by:
copy
in interfaceType<BasePairCharType>
- Returns:
- a new
Type
variable
-
toString
public java.lang.String toString()
- Specified by:
toString
in classAbstractNativeType<BasePairCharType>
-
valueEquals
public boolean valueEquals(BasePairCharType t)
- Specified by:
valueEquals
in interfaceValueEquals<BasePairCharType>
-
-