Class AbstractTileOperation

java.lang.Object
nom.tam.image.tile.operation.AbstractTileOperation
All Implemented Interfaces:
Runnable, ITileOperation
Direct Known Subclasses:
TileCompressor, TileDecompressor

public abstract class AbstractTileOperation extends Object implements Runnable, ITileOperation
(for internal use) A base implementation of parallel processing of tiles. Each instance handles the processing of a single 2D image tile, which is submitted to a thread pool for parallel processing of multiple tiles simultaneously.
  • Constructor Details

    • AbstractTileOperation

      public AbstractTileOperation(ITiledImageOperation operation, int tileIndex, TileArea area)
      Creates a parallel tile processing operation for a specific 2D image tile.
      Parameters:
      operation - the operation that is to be performed on the tile
      tileIndex - the sequential tile index
      area - the location and size of tile in the full image.
  • Method Details

    • execute

      public void execute(ExecutorService threadPool)
      Performs the operation on the selected tile, by submitting it to a thread pool for parallel processing.
      Parameters:
      threadPool - The thread pool in which the operation is to be processed.
      See Also:
    • getArea

      public TileArea getArea()
      Returns the location and size of the 2D image tile inside the entire image
      Returns:
      the location and size of the tile in the full image.
    • getPixelSize

      public int getPixelSize()
      Returns the pixel count inside the tile that this operation is assigned to process.
      Returns:
      the number of pixels in this tile.
    • getTileIndex

      public int getTileIndex()
      Returns the sequential index of the tile that this operations is assigned to process.
      Returns:
      the sequential index of the tile
    • setWholeImageBuffer

      public void setWholeImageBuffer(Buffer buffer)
      Sets the buffer that describes the whole image and let the tile create a slice of it from the position where the tile starts in the whole image. Attention this method is not thread-safe because it changes the position of the buffer parameter.
      Parameters:
      buffer - the buffer that describes the whole image.
    • waitForResult

      public void waitForResult()
      Wait for the result of the tile processing.
      Specified by:
      waitForResult in interface ITileOperation
      See Also:
    • getBaseType

      protected ElementType<Buffer> getBaseType()
      Returns the FITS element type of the image to be processed.
      Returns:
      the FITS element type of the underlying image
    • getPreviousTileOperation

      protected ITileOperation getPreviousTileOperation()
      Returns the parallel tile operation whose tile index is one less than ours.
      Returns:
      the parallel tile operation for the tile prior to ours.
    • getTileBuffer

      protected TileBuffer getTileBuffer()
      Returns the buffer that is to be used for storing or retrieving the serialized tile image.
      Returns:
      the linear buffer for the tile image.
      See Also:
    • getTiledImageOperation

      protected ITiledImageOperation getTiledImageOperation()
      Returns the operation that is assigned to be performed on the image tile.
      Returns:
      the operation to be performed on the associated image tile
    • setDimensions

      public ITileOperation setDimensions(int dataOffset, int width, int height)
      Description copied from interface: ITileOperation
      Specifies the location of the tile in the serialized buffer.
      Specified by:
      setDimensions in interface ITileOperation
      Parameters:
      dataOffset - the byte offset at which the tile data begins.
      width - the width of the tile in pixels.
      height - the tile height in pixels.
      Returns:
      itself.
    • setTileBuffer

      protected void setTileBuffer(TileBuffer tileBuffer)
      Sets the buffer to be used for storing or retrieving the serialized tile image.
      Parameters:
      tileBuffer - the linear buffer for the tile image.
      See Also: