T
- - the specialized versionpublic interface Type<T extends Type<T>>
Type
class is responsible for computing. It can be instaniated as a variable holding one single value only or with
a DirectAccessContainer. There is no differentiation between the two cases except for the constructor to avoid double implementations.
The Type
is the only class that is aware of the actual data type, i.e. which basic type (DataAccess
) is used to
store the data. On the other hand it does not know the storage type (Array
, Cursor
, ...). This is not necessary for
computation and avoid complicated re-implementations. The method public void updateDataArray( Cursor> c ); links the DirectAccessContainer and
the cursor which define the current position as well as the current storage array.Modifier and Type | Method and Description |
---|---|
T |
copy()
|
T[] |
createArray1D(int size1)
Creates a 1d array of the generic
Type |
T[][] |
createArray2D(int size1,
int size2)
Creates a 2d array of the generic
Type |
T[][][] |
createArray3D(int size1,
int size2,
int size3)
Creates a 3d array of the generic
Type |
DirectAccessContainer<T,?> |
createSuitableDirectAccessContainer(DirectAccessContainerFactory storageFactory,
int[] dim)
The
Type creates the DirectAccessContainer used for storing image data; based on the given storage strategy and its size. |
T |
createVariable()
Creates a new
Type which can only store one value. |
void |
decIndex()
Decreases the array index,
this is called by the
Cursor s which iterate over the image. |
void |
decIndex(int decrement)
Decreases the index by increment steps,
this is called by the
Cursor s which iterate over the image. |
T |
duplicateTypeOnSameDirectAccessContainer()
Creates a new
Type which stores in the same physical array. |
Display<T> |
getDefaultDisplay(Image<T> image)
|
int |
getEntitiesPerPixel() |
int |
getIndex()
Returns the current index in the storage array,
this is called by the
Cursor s which iterate over the image. |
void |
incIndex()
Increases the array index,
this is called by the
Cursor s which iterate over the image. |
void |
incIndex(int increment)
Increases the index by increment steps,
this is called by the
Cursor s which iterate over the image. |
void |
set(T c)
Sets the value of another
Type . |
void |
updateContainer(Cursor<?> c)
|
void |
updateIndex(int i)
Set the array position of the
Type . |
int getEntitiesPerPixel()
DirectAccessContainer<T,?> createSuitableDirectAccessContainer(DirectAccessContainerFactory storageFactory, int[] dim)
Type
creates the DirectAccessContainer 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 Image
and the basic types.storageFactory
- - Which storage strategy is useddim
- - the dimensionsType
knowns the BasicType it contains.void updateContainer(Cursor<?> c)
Cursor
s to update the data current data array
of the Type
, for example when moving from one Cell
to the next.
If it is only an Array
the Cursor
s never have to call that function.
The idea behind this concept is maybe not obvious. The Type
knows which basic type
is used (float, int, byte, ...) but does not know how it is stored (Array
, CellDirectAccessContainer
, ...) to
prevent multiple implementations of Type
.
That's why Type
asks the DataAccess
to give the actual basic array by passing the Cursor
that calls the method. The DataAccess
is also an Array
, CellDirectAccessContainer
, ... which
can then communicate with the ArrayCursor
, CellCursor
, ... and return the current basic type array.
A typical implementation of this method looks like that (this is the FloatType
implementation):
float[] v = floatStorage.getCurrentStorageArray( c );c
- - the Cursor
gives a link to itself so that the Type
tell its DataAccess
to get the new basic type array.void updateIndex(int i)
Type
.i
- - index valueint getIndex()
Cursor
s which iterate over the image.void incIndex()
Cursor
s which iterate over the image.void incIndex(int increment)
Cursor
s which iterate over the image.increment
- - how many stepsvoid decIndex()
Cursor
s which iterate over the image.void decIndex(int decrement)
Cursor
s which iterate over the image.increment
- - how many stepsT createVariable()
Type
which can only store one value.Type
instanceT duplicateTypeOnSameDirectAccessContainer()
Type
which stores in the same physical array. This is only used internally.Type
instance working on the same DirectAccessContainer
T[] createArray1D(int size1)
Type
size1
- - the size of the arrayT[][] createArray2D(int size1, int size2)
Type
size1
- - the size of the arraysize2
- - the size of the arrayCopyright © 2015–2021 Fiji. All rights reserved.