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
The abstract base class for
ImageOp
s 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
-
Method Summary
Modifier and TypeMethodDescriptiongetFutureTile
(int tileX, int tileY, ImageOpObserver obs) Submits a request for tile(tileX,tileY)
, and returns a reference to that request.int
Returns the number of tiles along the x-axis.int
Returns 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
.int
Returns the standard height of theBufferedImage
tiles which are returned byImageOp.getTile(java.awt.Point, VASSAL.tools.imageop.ImageOpObserver)
.Point[]
getTileIndices
(Rectangle rect) Returns an array ofPoint
s representing the tiles intersecting the givenRectangle
.getTileOp
(int tileX, int tileY) Returns anImageOp
which can produce the requested tile.Returns the standard size of theBufferedImage
tiles which are returned byImageOp.getTile(java.awt.Point, VASSAL.tools.imageop.ImageOpObserver)
.int
Returns the standard width of theBufferedImage
tiles 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, getWidth
Methods inherited from class VASSAL.tools.opcache.AbstractOpImpl
get, get, getFuture, getSources, newKey, update
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface VASSAL.tools.opcache.Op
getSources, newKey, update
-
Constructor Details
-
AbstractTileOpImpl
public AbstractTileOpImpl()
-
-
Method Details
-
getTileSize
Returns the standard size of theBufferedImage
tiles 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 theBufferedImage
width is not an integral multiple of the tile width. Similarly, tiles in the bottom row will not have full height if theBufferedImage
height is not an integral multiple of the tile height. This implementation is equivalent toAbstractOpImpl.getSize()
.- Specified by:
getTileSize
in interfaceImageOp
- Specified by:
getTileSize
in classAbstractOpImpl
- Returns:
- the size of
BufferedImage
tiles in pixels - See Also:
-
getTileHeight
public int getTileHeight()Returns the standard height of theBufferedImage
tiles which are returned byImageOp.getTile(java.awt.Point, VASSAL.tools.imageop.ImageOpObserver)
. This implementation is equivalent toAbstractOpImpl.getHeight()
.- Specified by:
getTileHeight
in interfaceImageOp
- Specified by:
getTileHeight
in classAbstractOpImpl
- Returns:
- the height of
BufferedImage
tiles in pixels - See Also:
-
getTileWidth
public int getTileWidth()Returns the standard width of theBufferedImage
tiles which are returned byImageOp.getTile(java.awt.Point, VASSAL.tools.imageop.ImageOpObserver)
. This implementation is equivalent toAbstractOpImpl.getWidth()
.- Specified by:
getTileWidth
in interfaceImageOp
- Specified by:
getTileWidth
in classAbstractOpImpl
- 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 interfaceImageOp
- Specified by:
getNumXTiles
in 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:
getNumYTiles
in interfaceImageOp
- Specified by:
getNumYTiles
in classAbstractOpImpl
- 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 specifiedImageOpObserver
. If a non-null
observer 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 mainBufferedImage
is(0,0)
. Note thattileX
andtileY
are indices into the tile array, not pixel locations.Warning:
BufferedImage
s returned by this method must not be modified.- Specified by:
getTile
in interfaceImageOp
- Specified by:
getTile
in 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 != 0
ortileY != 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 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 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 mainBufferedImage
is(0,0)
. Note thattileX
andtileY
are indices into the tile array, not pixel locations.Warning:
BufferedImage
s obtained from theFuture
s returned by this method must not be modified.- Specified by:
getFutureTile
in interfaceImageOp
- Specified by:
getFutureTile
in 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 != 0
ortileY != 0
.ExecutionException
- if the operation failed
-
getTileOp
Description copied from class:AbstractOpImpl
Returns anImageOp
which can produce the requested tile.- Specified by:
getTileOp
in interfaceImageOp
- Specified by:
getTileOp
in classAbstractOpImpl
- Parameters:
tileX
- the x position of the requested tiletileY
- the y position of the requested tile- Returns:
- the
ImageOp
which produces the requested tile
-
getTileIndices
Returns an array ofPoint
s representing the tiles intersecting the givenRectangle
.- Specified by:
getTileIndices
in interfaceImageOp
- Specified by:
getTileIndices
in classAbstractOpImpl
- Parameters:
rect
- the rectangle- Returns:
- the positions of the tiles hit by the rectangle
- Throws:
IllegalArgumentException
- ifrect == null
.
-