public interface NativeType<T extends NativeType<T>> extends Type<T>
NativeType
is a Type
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.
The NativeType
is positioned on the correct storage array and index
by accessors (Cursors
and RandomAccesses
).
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 the Type
avoids re-implementation for each container type.
Modifier and Type | Method and Description |
---|---|
NativeImg<T,?> |
createSuitableNativeImg(NativeImgFactory<T> storageFactory,
long[] dim)
The
NativeType creates the NativeImg 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 by
decrement
steps. |
T |
duplicateTypeOnSameNativeImg()
Creates a new
NativeType 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 by
increment
steps. |
void |
updateContainer(Object c)
This method is used by an accessor (e.g., a
Cursor ) to request an
update of the current data array. |
void |
updateIndex(int i)
Set the index into the current data array.
|
copy, createVariable, set
valueEquals
Fraction getEntitiesPerPixel()
NativeImg<T,?> createSuitableNativeImg(NativeImgFactory<T> storageFactory, long[] dim)
NativeType
creates the NativeImg
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.T duplicateTypeOnSameNativeImg()
NativeType
which stores in the same physical array.
This is only used internally.NativeType
instance working on the same
NativeImg
void updateContainer(Object c)
Cursor
) to request an
update of the current data array.
As an example consider a CellCursor
moving on a CellImg
.
The cursor maintains a NativeType
which provides access to the
image data. When the cursor moves from one cell to the next, the
underlying data array of the NativeType
must be switched to the
data array of the new cell.
To achieve this, the CellCursor
calls updateContainer()
with itself as the argument. updateContainer()
in turn will call
NativeImg.update(Object)
on it's container, passing along the
reference to the cursor. In this example, the container would be a
CellImg
. While the NativeType
does not know about the
type of the cursor, the container does. CellImg
knows that it is
passed a CellCursor
instance, which can be used to figure out the
current cell and the underlying data array, which is then returned to the
NativeType
.
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 of NativeType
.
c
- reference to an accessor which can be passed on to the
container (which will know what to do with it).void updateIndex(int i)
This is used by accessors (e.g., a Cursor
) to position the
NativeType
in the container.
i
- the new array indexint getIndex()
This is used by accessors (e.g., a Cursor
) to position the
NativeType
in the container.
void incIndex()
This is used by accessors (e.g., a Cursor
) to position the
NativeType
in the container.
void incIndex(int increment)
increment
steps.
This is used by accessors (e.g., a Cursor
) to position the
NativeType
in the container.
increment
- how many stepsvoid decIndex()
This is used by accessors (e.g., a Cursor
) to position the
NativeType
in the container.
void decIndex(int decrement)
decrement
steps.
This is used by accessors (e.g., a Cursor
) to position the
NativeType
in the container.
decrement
- how many stepsCopyright © 2009–2018 ImgLib2. All rights reserved.