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 |
---|---|
default void |
decIndex()
Deprecated.
Use
index().dec() instead. If possible, request the
index() object only once and re-use it. |
default void |
decIndex(int decrement)
Deprecated.
Use
index().dec(int) instead. If possible, request the
index() object only once and re-use it. |
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.
|
default int |
getIndex()
Deprecated.
Use
index().get() instead. If possible, request the
index() object only once and re-use it. |
NativeTypeFactory<T,?> |
getNativeTypeFactory() |
default void |
incIndex()
Deprecated.
Use
index().inc() instead. If possible, request the
index() object only once and re-use it. |
default void |
incIndex(int increment)
Deprecated.
Use
index().inc(int) instead. If possible, request the
index() object only once and re-use it. |
Index |
index()
Get the (modifiable) index into the current data array.
|
void |
updateContainer(Object c)
This method is used by an accessor (e.g., a
Cursor ) to request an
update of the current data array. |
default void |
updateIndex(int i)
Deprecated.
Use
index().set(int) instead. If possible, request the
index() object only once and re-use it. |
copy, createVariable, set
valueEquals
Fraction getEntitiesPerPixel()
T duplicateTypeOnSameNativeImg()
NativeType
which stores in the same physical array.
This is only used internally.NativeType
instance working on the same
NativeImg
NativeTypeFactory<T,?> getNativeTypeFactory()
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).Index index()
@Deprecated default void updateIndex(int i)
index().set(int)
instead. If possible, request the
index()
object only once and re-use it.@Deprecated default int getIndex()
index().get()
instead. If possible, request the
index()
object only once and re-use it.@Deprecated default void incIndex()
index().inc()
instead. If possible, request the
index()
object only once and re-use it.@Deprecated default void incIndex(int increment)
index().inc(int)
instead. If possible, request the
index()
object only once and re-use it.increment
steps.@Deprecated default void decIndex()
index().dec()
instead. If possible, request the
index()
object only once and re-use it.@Deprecated default void decIndex(int decrement)
index().dec(int)
instead. If possible, request the
index()
object only once and re-use it.decrement
steps.Copyright © 2015–2022 ImgLib2. All rights reserved.