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
,FixedScaleOpBitmapImpl
,GridOp
,ImageSourceOpBitmapImpl
,OrthoRotateOpBitmapImpl
,ScaleOpBitmapImpl
,SolidColorOp
,SourceOpBitmapImpl
,SourceOpSVGImpl
The abstract base class for
ImageOp
s which support multiple tiles.- Since:
- 3.1.0
- Author:
- Joel Uckelman
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
The number of tiles along the x-axis.protected int
The number of tiles along the y-axis.protected ImageOp[]
The tiles already created, stored asy*numXTiles + x
.protected Dimension
The standard size of thisImageOp
s tiles.Fields inherited from class VASSAL.tools.imageop.AbstractOpImpl
cache, size
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ImageOp
createTileOp
(int tileX, int tileY) protected void
Sets thetileSize
which 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.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 theImageOp
which produces tile(tileX,tileY)
, creating it if necessary.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
-
Field Details
-
tileSize
The standard size of thisImageOp
s 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 thetileSize
which is used bygetTileSize()
,getTileHeight()
,getTileWidth()
,getNumXTiles()
,getNumYTiles()
, and all other tile methods. -
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.- 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)
.- 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)
.- 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:
- 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:
getNumYTiles
in interfaceImageOp
- Specified by:
getNumYTiles
in classAbstractOpImpl
- Returns:
- the number of tiles along the y-axis
-
getTileOp
Returns theImageOp
which produces tile(tileX,tileY)
, creating it if necessary.- 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
for tile(tileX,tileY)
-
createTileOp
-
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:
- the resulting
BufferedImage
- Throws:
IndexOutOfBoundsException
- unless0 <= tileX < numXTiles
and0 <= 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 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:
- a
Future
for the resultingBufferedImage
- Throws:
IndexOutOfBoundsException
- unless0 <= tileX < numXTiles
and0 <= tileY < numYTiles
.ExecutionException
- if the operation failed
-
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
.
-