Package VASSAL.tools.imageop
Class AbstractTileOpImpl
java.lang.Object
VASSAL.tools.opcache.AbstractOpImpl<BufferedImage>
VASSAL.tools.imageop.AbstractOpImpl
VASSAL.tools.imageop.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
-
Field Summary
Fields inherited from class VASSAL.tools.imageop.AbstractOpImpl
cache, size -
Constructor Summary
Constructors Constructor Description AbstractTileOpImpl() -
Method Summary
Modifier and Type Method Description Future<BufferedImage>getFutureTile(int tileX, int tileY, ImageOpObserver obs)Submits a request for tile(tileX,tileY), and returns a reference to that request.intgetNumXTiles()Returns the number of tiles along the x-axis.intgetNumYTiles()Returns the number of tiles along the y-axis.BufferedImagegetTile(int tileX, int tileY, ImageOpObserver obs)Calculates tile(tileX,tileY), and reports completion or failure to the specifiedImageOpObserver.intgetTileHeight()Returns the standard height of theBufferedImagetiles which are returned byImageOp.getTile(java.awt.Point, VASSAL.tools.imageop.ImageOpObserver).Point[]getTileIndices(Rectangle rect)Returns an array ofPoints representing the tiles intersecting the givenRectangle.ImageOpgetTileOp(int tileX, int tileY)Returns anImageOpwhich can produce the requested tile.DimensiongetTileSize()Returns the standard size of theBufferedImagetiles which are returned byImageOp.getTile(java.awt.Point, VASSAL.tools.imageop.ImageOpObserver).intgetTileWidth()Returns the standard width of theBufferedImagetiles which are returned byImageOp.getTile(java.awt.Point, VASSAL.tools.imageop.ImageOpObserver).Methods inherited from class VASSAL.tools.imageop.AbstractOpImpl
clearCache, eval, fixSize, getFutureImage, getFutureTile, getHeight, getImage, getImage, getSize, getSizeFromCache, getTile, getTileOp, getWidthMethods inherited from class VASSAL.tools.opcache.AbstractOpImpl
get, get, getFuture, getSources, newKey, updateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface VASSAL.tools.opcache.Op
getSources, newKey, update
-
Constructor Details
-
AbstractTileOpImpl
public AbstractTileOpImpl()
-
-
Method Details
-
getTileSize
Returns the standard size of theBufferedImagetiles which are returned byImageOp.getTile(java.awt.Point, VASSAL.tools.imageop.ImageOpObserver). Tiles which are in the extreme right column will not have full width if theBufferedImagewidth is not an integral multiple of the tile width. Similarly, tiles in the bottom row will not have full height if theBufferedImageheight is not an integral multiple of the tile height. This implementation is equivalent toAbstractOpImpl.getSize().- Specified by:
getTileSizein interfaceImageOp- Specified by:
getTileSizein classAbstractOpImpl- Returns:
- the size of
BufferedImagetiles in pixels - See Also:
ImageOp.getTileHeight(),ImageOp.getTileWidth()
-
getTileHeight
public int getTileHeight()Returns the standard height of theBufferedImagetiles which are returned byImageOp.getTile(java.awt.Point, VASSAL.tools.imageop.ImageOpObserver). This implementation is equivalent toAbstractOpImpl.getHeight().- Specified by:
getTileHeightin interfaceImageOp- Specified by:
getTileHeightin classAbstractOpImpl- Returns:
- the height of
BufferedImagetiles in pixels - See Also:
ImageOp.getTileSize(),ImageOp.getTileWidth()
-
getTileWidth
public int getTileWidth()Returns the standard width of theBufferedImagetiles which are returned byImageOp.getTile(java.awt.Point, VASSAL.tools.imageop.ImageOpObserver). This implementation is equivalent toAbstractOpImpl.getWidth().- Specified by:
getTileWidthin interfaceImageOp- Specified by:
getTileWidthin classAbstractOpImpl- Returns:
- the width of
BufferedImagetiles in pixels - See Also:
ImageOp.getTileSize(),ImageOp.getTileHeight()
-
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:
getNumXTilesin interfaceImageOp- Specified by:
getNumXTilesin classAbstractOpImpl- 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:
getNumYTilesin interfaceImageOp- Specified by:
getNumYTilesin classAbstractOpImpl- Returns:
1, always
-
getTile
public BufferedImage getTile(int tileX, int tileY, ImageOpObserver obs) throws CancellationException, InterruptedException, ExecutionExceptionCalculates tile(tileX,tileY), and reports completion or failure to the specifiedImageOpObserver. If a non-nullobserver is given, then the operation may be done asynchronously. If the observer isnull, 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 mainBufferedImageis(0,0). Note thattileXandtileYare indices into the tile array, not pixel locations.Warning:
BufferedImages returned by this method must not be modified.- Specified by:
getTilein interfaceImageOp- Specified by:
getTilein classAbstractOpImpl- Parameters:
tileX- the x position of the requested tiletileY- the y position of the requested tileobs- the observer to be notified on completion- Returns:
getImage(obs), because there is only one tile- Throws:
IndexOutOfBoundsException- IftileX != 0ortileY != 0.CancellationException- if the operation was cancelledInterruptedException- if the operation was interruptedExecutionException- if the operation failed
-
getFutureTile
public Future<BufferedImage> getFutureTile(int tileX, int tileY, ImageOpObserver obs) throws ExecutionExceptionSubmits a request for tile(tileX,tileY), and returns a reference to that request. If a non-nullobserver is given, then the operation may be done asynchronously. If the observer isnull, 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 mainBufferedImageis(0,0). Note thattileXandtileYare indices into the tile array, not pixel locations.Warning:
BufferedImages obtained from theFutures returned by this method must not be modified.- Specified by:
getFutureTilein interfaceImageOp- Specified by:
getFutureTilein classAbstractOpImpl- Parameters:
tileX- the x position of the requested tiletileY- the y position of the requested tileobs- the observer to be notified on completion- Returns:
getFutureImage(obs), because there is only one tile- Throws:
IndexOutOfBoundsException- IftileX != 0ortileY != 0.ExecutionException- if the operation failed
-
getTileOp
Description copied from class:AbstractOpImplReturns anImageOpwhich can produce the requested tile.- Specified by:
getTileOpin interfaceImageOp- Specified by:
getTileOpin classAbstractOpImpl- Parameters:
tileX- the x position of the requested tiletileY- the y position of the requested tile- Returns:
- the
ImageOpwhich produces the requested tile
-
getTileIndices
Returns an array ofPoints representing the tiles intersecting the givenRectangle.- Specified by:
getTileIndicesin interfaceImageOp- Specified by:
getTileIndicesin classAbstractOpImpl- Parameters:
rect- the rectangle- Returns:
- the positions of the tiles hit by the rectangle
- Throws:
IllegalArgumentException- ifrect == null.
-