public interface NativeType<T extends NativeType<T>> extends Type<T>
Typethat 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
NativeTypeis positioned on the correct storage array and index by accessors (
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.,
Separating the storage layout from access and operations on the
avoids re-implementation for each container type.
|Modifier and Type||Method and Description|
Decrement the index into the current data array.
Decrease the index into the current data array by
Creates a new
Get the number of entities in the storage array required to store one pixel value.
Get the current index into the current data array.
Increment the index into the current data array.
Increases the index into the current data array by
This method is used by an accessor (e.g., a
Set the index into the current data array.
NativeTypewhich stores in the same physical array. This is only used internally.
void updateContainer(Object c)
Cursor) to request an update of the current data array.
As an example consider a
CellCursor moving on a
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
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
CellCursor instance, which can be used to figure out the
current cell and the underlying data array, which is then returned to the
The idea behind this concept is maybe not obvious. The
knows which basic type is used (float, int, byte, ...). However, it does
not know how the data is stored (
This prevents the need for multiple implementations of
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)
i- the new array index
void incIndex(int increment)
increment- how many steps
Copyright © 2015–2019 ImgLib2. All rights reserved.