Interface NativeType<T extends NativeType<T>>
-
- All Superinterfaces:
Type<T>
,ValueEquals<T>
- All Known Implementing Classes:
AbstractBit64Type
,AbstractBitType
,AbstractIntegerBitType
,AbstractNativeType
,ARGBType
,BasePairBitType
,BasePairCharType
,BitType
,ByteType
,ComplexDoubleType
,ComplexFloatType
,DoubleType
,FloatType
,GenericByteType
,GenericIntType
,GenericLongType
,GenericShortType
,IntType
,LongType
,NativeARGBDoubleType
,ShortType
,Unsigned128BitType
,Unsigned12BitType
,Unsigned2BitType
,Unsigned4BitType
,UnsignedByteType
,UnsignedIntType
,UnsignedLongType
,UnsignedShortType
,UnsignedVariableBitLengthType
public interface NativeType<T extends NativeType<T>> extends Type<T>
ANativeType
is aType
that that provides access to data stored in Java primitive arrays. To this end, implementations maintain a reference to the current storage array and the index of an element in that array. TheNativeType
is positioned on the correct storage array and index by accessors (Cursors
andRandomAccesses
).The
NativeType
is the only class that is aware of the actual data type, i.e., which Java primitive type is used to store the data. On the other hand it does not know the storage layout, i.e., how n-dimensional pixel coordinates map to indices in the current array. It also doesn't know whether and how the data is split into multiple chunks. This is determined by the container implementation (e.g.,ArrayImg
,CellImg
, ...). Separating the storage layout from access and operations on theType
avoids re-implementation for each container type.- Author:
- Stephan Preibisch, Stephan Saalfeld, Tobias Pietzsch
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description NativeImg<T,?>
createSuitableNativeImg(NativeImgFactory<T> storageFactory, long[] dim)
TheNativeType
creates theNativeImg
used for storing image data; based on the given storage strategy and its size.void
decIndex()
Decrement the index into the current data array.void
decIndex(int decrement)
Decrease the index into the current data array bydecrement
steps.T
duplicateTypeOnSameNativeImg()
Creates a newNativeType
which stores in the same physical array.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.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
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 i)
Set the index into the current data array.-
Methods inherited from interface net.imglib2.type.Type
copy, createVariable, set
-
Methods inherited from interface net.imglib2.type.operators.ValueEquals
valueEquals
-
-
-
-
Method Detail
-
getEntitiesPerPixel
Fraction getEntitiesPerPixel()
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.- Returns:
- the number of storage type entities required to store one pixel value.
-
createSuitableNativeImg
NativeImg<T,?> createSuitableNativeImg(NativeImgFactory<T> storageFactory, long[] dim)
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.
-
duplicateTypeOnSameNativeImg
T duplicateTypeOnSameNativeImg()
Creates a newNativeType
which stores in the same physical array. This is only used internally.- Returns:
- a new
NativeType
instance working on the sameNativeImg
-
updateContainer
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.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
.- Parameters:
c
- reference to an accessor which can be passed on to the container (which will know what to do with it).
-
updateIndex
void updateIndex(int i)
Set the index into the current data array.This is used by accessors (e.g., a
Cursor
) to position theNativeType
in the container.- Parameters:
i
- the new array index
-
getIndex
int getIndex()
Get the current index into the current data array.This is used by accessors (e.g., a
Cursor
) to position theNativeType
in the container.- Returns:
- the current index into the underlying data array
-
incIndex
void incIndex()
Increment the index into the current data array.This is used by accessors (e.g., a
Cursor
) to position theNativeType
in the container.
-
incIndex
void incIndex(int increment)
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.- Parameters:
increment
- how many steps
-
decIndex
void decIndex()
Decrement the index into the current data array.This is used by accessors (e.g., a
Cursor
) to position theNativeType
in the container.
-
decIndex
void decIndex(int decrement)
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.- Parameters:
decrement
- how many steps
-
-