Class AbstractBitType<T extends AbstractBitType<T>>

  • All Implemented Interfaces:
    NativeType<T>, ValueEquals<T>, Type<T>
    Direct Known Subclasses:
    AbstractBit64Type, AbstractIntegerBitType

    public abstract class AbstractBitType<T extends AbstractBitType<T>>
    extends java.lang.Object
    implements NativeType<T>
    Provides basic infrastructure to implement Types based on single bits stored in a LongAccess
    Author:
    Albert Cardona, Stephan Preibisch
    • Field Detail

      • i

        protected long i
      • nBits

        protected final int nBits
    • Constructor Detail

      • AbstractBitType

        public AbstractBitType​(NativeImg<?,​? extends LongAccess> bitStorage,
                               int nBits)
    • Method Detail

      • updateContainer

        public void updateContainer​(java.lang.Object c)
        Description copied from interface: NativeType
        This method is used by an accessor (e.g., a 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 .

        Specified by:
        updateContainer in interface NativeType<T extends AbstractBitType<T>>
        Parameters:
        c - reference to an accessor which can be passed on to the container (which will know what to do with it).
      • getIndex

        public int getIndex()
        Description copied from interface: NativeType
        Get the current index into the current data array.

        This is used by accessors (e.g., a Cursor) to position the NativeType in the container.

        Specified by:
        getIndex in interface NativeType<T extends AbstractBitType<T>>
        Returns:
        the current index into the underlying data array
      • updateIndex

        public void updateIndex​(int index)
        Description copied from interface: NativeType
        Set the index into the current data array.

        This is used by accessors (e.g., a Cursor) to position the NativeType in the container.

        Specified by:
        updateIndex in interface NativeType<T extends AbstractBitType<T>>
        Parameters:
        index - the new array index
      • incIndex

        public void incIndex​(int increment)
        Description copied from interface: NativeType
        Increases the index into the current data array by increment steps.

        This is used by accessors (e.g., a Cursor) to position the NativeType in the container.

        Specified by:
        incIndex in interface NativeType<T extends AbstractBitType<T>>
        Parameters:
        increment - how many steps
      • decIndex

        public void decIndex​(int decrement)
        Description copied from interface: NativeType
        Decrease the index into the current data array by decrement steps.

        This is used by accessors (e.g., a Cursor) to position the NativeType in the container.

        Specified by:
        decIndex in interface NativeType<T extends AbstractBitType<T>>
        Parameters:
        decrement - how many steps
      • getEntitiesPerPixel

        public Fraction getEntitiesPerPixel()
        Description copied from interface: NativeType
        Get the number of entities in the storage array required to store one pixel value. A pixel value may be spread over several or less than one entity. For example, a complex number may require 2 entries of a float[] array to store one pixel. Or a 12-bit type might need 12/64th entries of a long[] array.
        Specified by:
        getEntitiesPerPixel in interface NativeType<T extends AbstractBitType<T>>
        Returns:
        the number of storage type entities required to store one pixel value.