public abstract class AbstractBitType<T extends AbstractBitType<T>> extends Object implements NativeType<T>
Modifier and Type | Field and Description |
---|---|
protected LongAccess |
dataAccess |
protected long |
i |
protected NativeImg<?,? extends LongAccess> |
img |
protected int |
nBits |
Constructor and Description |
---|
AbstractBitType(NativeImg<?,? extends LongAccess> bitStorage,
int nBits) |
Modifier and Type | Method and Description |
---|---|
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. |
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 index)
Set the index into the current data array.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createSuitableNativeImg, duplicateTypeOnSameNativeImg
copy, createVariable, set
valueEquals
protected long i
protected final int nBits
protected final NativeImg<?,? extends LongAccess> img
protected LongAccess dataAccess
public AbstractBitType(NativeImg<?,? extends LongAccess> bitStorage, int nBits)
public void updateContainer(Object c)
NativeType
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
.
updateContainer
in interface NativeType<T extends AbstractBitType<T>>
c
- reference to an accessor which can be passed on to the
container (which will know what to do with it).public int getIndex()
NativeType
This is used by accessors (e.g., a Cursor
) to position the
NativeType
in the container.
getIndex
in interface NativeType<T extends AbstractBitType<T>>
public void updateIndex(int index)
NativeType
This is used by accessors (e.g., a Cursor
) to position the
NativeType
in the container.
updateIndex
in interface NativeType<T extends AbstractBitType<T>>
index
- the new array indexpublic void incIndex()
NativeType
This is used by accessors (e.g., a Cursor
) to position the
NativeType
in the container.
incIndex
in interface NativeType<T extends AbstractBitType<T>>
public void incIndex(int increment)
NativeType
increment
steps.
This is used by accessors (e.g., a Cursor
) to position the
NativeType
in the container.
incIndex
in interface NativeType<T extends AbstractBitType<T>>
increment
- how many stepspublic void decIndex()
NativeType
This is used by accessors (e.g., a Cursor
) to position the
NativeType
in the container.
decIndex
in interface NativeType<T extends AbstractBitType<T>>
public void decIndex(int decrement)
NativeType
decrement
steps.
This is used by accessors (e.g., a Cursor
) to position the
NativeType
in the container.
decIndex
in interface NativeType<T extends AbstractBitType<T>>
decrement
- how many stepspublic Fraction getEntitiesPerPixel()
NativeType
getEntitiesPerPixel
in interface NativeType<T extends AbstractBitType<T>>
Copyright © 2009–2017 ImgLib2. All rights reserved.