Class AbstractTileOpImpl

All Implemented Interfaces:
ImageOp, Op<BufferedImage>
Direct Known Subclasses:
GamePieceOpImpl, ImageItem.BaseOp, Labeler.LabelOp, RotateScaleOpBitmapImpl, RotateScaleOpSVGImpl, SourceOpDiskCacheBitmapImpl, SourceTileOpBitmapImpl, SourceTileOpSVGImpl

public abstract class AbstractTileOpImpl extends AbstractOpImpl
The abstract base class for ImageOps which are a single tile. This class provides simpler implementations of the tile-related methods than does AbstractTiledOpImpl, as objects instantiating this class' subclasses are all single tiles.
Since:
3.1.0
Author:
Joel Uckelman
  • Constructor Details

    • AbstractTileOpImpl

      public AbstractTileOpImpl()
  • Method Details

    • getTileSize

      public Dimension getTileSize()
      Returns the standard size of the BufferedImage tiles which are returned by ImageOp.getTile(Point, ImageOpObserver). Tiles which are in the extreme right column will not have full width if the BufferedImage width is not an integral multiple of the tile width. Similarly, tiles in the bottom row will not have full height if the BufferedImage height is not an integral multiple of the tile height. This implementation is equivalent to AbstractOpImpl.getSize().
      Specified by:
      getTileSize in interface ImageOp
      Specified by:
      getTileSize in class AbstractOpImpl
      Returns:
      the size of BufferedImage tiles in pixels
      See Also:
    • getTileHeight

      public int getTileHeight()
      Returns the standard height of the BufferedImage tiles which are returned by ImageOp.getTile(Point, ImageOpObserver). This implementation is equivalent to AbstractOpImpl.getHeight().
      Specified by:
      getTileHeight in interface ImageOp
      Specified by:
      getTileHeight in class AbstractOpImpl
      Returns:
      the height of BufferedImage tiles in pixels
      See Also:
    • getTileWidth

      public int getTileWidth()
      Returns the standard width of the BufferedImage tiles which are returned by ImageOp.getTile(Point, ImageOpObserver). This implementation is equivalent to AbstractOpImpl.getWidth().
      Specified by:
      getTileWidth in interface ImageOp
      Specified by:
      getTileWidth in class AbstractOpImpl
      Returns:
      the width of BufferedImage tiles in pixels
      See Also:
    • getNumXTiles

      public int getNumXTiles()
      Returns the number of tiles along the x-axis. There will always be at least one column of tiles. The number of columns should equal (int) Math.ceil((double) getWidth() / getTileWidth()).
      Specified by:
      getNumXTiles in interface ImageOp
      Specified by:
      getNumXTiles in class AbstractOpImpl
      Returns:
      1, always
    • getNumYTiles

      public int getNumYTiles()
      Returns the number of tiles along the y-axis. There will always be at least one row of tiles. The number of rows should equal (int) Math.ceil((double) getHeight() / getTileHeight()).
      Specified by:
      getNumYTiles in interface ImageOp
      Specified by:
      getNumYTiles in class AbstractOpImpl
      Returns:
      1, always
    • getTile

      public BufferedImage getTile(int tileX, int tileY, ImageOpObserver obs) throws CancellationException, InterruptedException, ExecutionException
      Calculates tile (tileX,tileY), and reports completion or failure to the specified ImageOpObserver. If a non-null observer is given, then the operation may be done asynchronously. If the observer is null, then this method will block on completion of the operation. Tiles are numbered from zero, so the tile in the upper-left corner of the main BufferedImage is (0,0). Note that tileX and tileY are indices into the tile array, not pixel locations.

      Warning: BufferedImages returned by this method must not be modified.

      Specified by:
      getTile in interface ImageOp
      Specified by:
      getTile in class AbstractOpImpl
      Parameters:
      tileX - the x position of the requested tile
      tileY - the y position of the requested tile
      obs - the observer to be notified on completion
      Returns:
      getImage(obs), because there is only one tile
      Throws:
      IndexOutOfBoundsException - If tileX != 0 or tileY != 0.
      CancellationException - if the operation was cancelled
      InterruptedException - if the operation was interrupted
      ExecutionException - if the operation failed
    • getFutureTile

      public Future<BufferedImage> getFutureTile(int tileX, int tileY, ImageOpObserver obs) throws ExecutionException
      Submits a request for tile (tileX,tileY), and returns a reference to that request. If a non-null observer is given, then the operation may be done asynchronously. If the observer is null, then this method will block on completion of the operation. Tiles are numbered from zero, so the tile in the upper-left corner of the main BufferedImage is (0,0). Note that tileX and tileY are indices into the tile array, not pixel locations.

      Warning: BufferedImages obtained from the Futures returned by this method must not be modified.

      Specified by:
      getFutureTile in interface ImageOp
      Specified by:
      getFutureTile in class AbstractOpImpl
      Parameters:
      tileX - the x position of the requested tile
      tileY - the y position of the requested tile
      obs - the observer to be notified on completion
      Returns:
      getFutureImage(obs), because there is only one tile
      Throws:
      IndexOutOfBoundsException - If tileX != 0 or tileY != 0.
      ExecutionException - if the operation failed
    • getTileOp

      public ImageOp getTileOp(int tileX, int tileY)
      Description copied from class: AbstractOpImpl
      Returns an ImageOp which can produce the requested tile.
      Specified by:
      getTileOp in interface ImageOp
      Specified by:
      getTileOp in class AbstractOpImpl
      Parameters:
      tileX - the x position of the requested tile
      tileY - the y position of the requested tile
      Returns:
      the ImageOp which produces the requested tile
    • getTileIndices

      public Point[] getTileIndices(Rectangle rect)
      Returns an array of Points representing the tiles intersecting the given Rectangle.
      Specified by:
      getTileIndices in interface ImageOp
      Specified by:
      getTileIndices in class AbstractOpImpl
      Parameters:
      rect - the rectangle
      Returns:
      the positions of the tiles hit by the rectangle
      Throws:
      IllegalArgumentException - if rect == null.