Package VASSAL.tools.imageop
Class AbstractTiledOpImpl
java.lang.Object
VASSAL.tools.opcache.AbstractOpImpl<BufferedImage>
VASSAL.tools.imageop.AbstractOpImpl
VASSAL.tools.imageop.AbstractTiledOpImpl
- All Implemented Interfaces:
ImageOp,Op<BufferedImage>
- Direct Known Subclasses:
CropOpBitmapImpl,GridOp,ImageSourceOpBitmapImpl,OrthoRotateOpBitmapImpl,ScaleOpBitmapImpl,SolidColorOp,SourceOpBitmapImpl,SourceOpSVGImpl
The abstract base class for
ImageOps which support multiple tiles.- Since:
- 3.1.0
- Author:
- Joel Uckelman
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe number of tiles along the x-axis.protected intThe number of tiles along the y-axis.protected ImageOp[]The tiles already created, stored asy*numXTiles + x.protected DimensionThe standard size of thisImageOps tiles.Fields inherited from class VASSAL.tools.imageop.AbstractOpImpl
cache, size -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ImageOpcreateTileOp(int tileX, int tileY)protected voidSets thetileSizewhich is used bygetTileSize(),getTileHeight(),getTileWidth(),getNumXTiles(),getNumYTiles(), and all other tile methods.getFutureTile(int tileX, int tileY, ImageOpObserver obs)Submits a request for tile(tileX,tileY), and returns a reference to that request.intReturns the number of tiles along the x-axis.intReturns the number of tiles along the y-axis.getTile(int tileX, int tileY, ImageOpObserver obs)Calculates tile(tileX,tileY), and reports completion or failure to the specifiedImageOpObserver.intReturns 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.getTileOp(int tileX, int tileY)Returns theImageOpwhich produces tile(tileX,tileY), creating it if necessary.Returns the standard size of theBufferedImagetiles which are returned byImageOp.getTile(java.awt.Point, VASSAL.tools.imageop.ImageOpObserver).intReturns 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
-
Field Details
-
tileSize
The standard size of thisImageOps tiles. -
numXTiles
protected int numXTilesThe number of tiles along the x-axis. -
numYTiles
protected int numYTilesThe number of tiles along the y-axis. -
tiles
The tiles already created, stored asy*numXTiles + x.
-
-
Constructor Details
-
AbstractTiledOpImpl
public AbstractTiledOpImpl()
-
-
Method Details
-
fixTileSize
protected void fixTileSize()Sets thetileSizewhich is used bygetTileSize(),getTileHeight(),getTileWidth(),getNumXTiles(),getNumYTiles(), and all other tile methods. -
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.- 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).- 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).- 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:
- the number of tiles along the x-axis
-
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:
- the number of tiles along the y-axis
-
getTileOp
Returns theImageOpwhich produces tile(tileX,tileY), creating it if necessary.- 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
ImageOpfor tile(tileX,tileY)
-
createTileOp
-
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:
- the resulting
BufferedImage - Throws:
IndexOutOfBoundsException- unless0 <= tileX < numXTilesand0 <= tileY < numYTiles.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:
- a
Futurefor the resultingBufferedImage - Throws:
IndexOutOfBoundsException- unless0 <= tileX < numXTilesand0 <= tileY < numYTiles.ExecutionException- if the operation failed
-
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.
-