|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectPlanarImage
DeferredPlanarImage
public final class DeferredPlanarImage
A tiled image to be used by renderer when the actual image may take a while to compute. This
image wraps an arbitrary rendered image, which may (or may not) be
some image expensive to compute. When a tile is requested (through a call to getTile(int, int)
but the tile is not available in the wrapped image, then this class returns some default
(usually black) tile and start the real tile computation in a background thread. When the
actual tile is available, this class fire a tileUpdate event,
thus given a chance to a renderer to repaint again this image with the new tiles.
Example of use:
public class Renderer extends JPanel implements TileObserver {
private DeferredPlanarImage image;
public Renderer(RenderedImage toPaint) {
image = new DeferredPlanarImage(toPaint);
image.addTileObserver(this);
}
public void tileUpdate(WritableRenderedImage source,
int tileX, int tileY, boolean willBeWritable)
{
repaint();
}
public void paint(Graphics gr) {
((Graphics2D) gr).drawRenderedImage(image);
}
}
| coverage/geotk-coverage (download) | View source code for this class |
| Field Summary |
|---|
| Fields inherited from class PlanarImage |
|---|
colorModel, eventManager, height, minX, minY, properties, sampleModel, tileFactory, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, width |
| Constructor Summary | |
|---|---|
DeferredPlanarImage(RenderedImage source)
Constructs a new instance of DeferredPlanarImage. |
|
| Method Summary | |
|---|---|
void |
addTileObserver(TileObserver observer)
Adds an observer. |
void |
dispose()
Provides a hint that this image will no longer be accessed from a reference in user space. |
Vector<RenderedImage> |
getSources()
Returns the source images. |
Raster |
getTile(int tileX,
int tileY)
Returns the specified tile, or a default one if the requested tile is not yet available. |
WritableRaster |
getWritableTile(int tileX,
int tileY)
Checks out a tile for writing. |
Point[] |
getWritableTileIndices()
Returns an array of Point objects indicating which tiles are
checked out for writing. |
boolean |
hasTileWriters()
Returns whether any tile is checked out for writing. |
boolean |
isTileWritable(int tileX,
int tileY)
Returns whether a tile is currently checked out for writing. |
void |
releaseWritableTile(int tileX,
int tileY)
Relinquishes the right to write to a tile. |
void |
removeTileObserver(TileObserver observer)
Removes an observer. |
void |
setData(Raster r)
Sets a rectangle of the image to the contents of the raster. |
void |
tileCancelled(Object eventSource,
TileRequest[] requests,
PlanarImage image,
int tileX,
int tileY)
Invoked when a tile computation has been canceled. |
void |
tileComputationFailure(Object eventSource,
TileRequest[] requests,
PlanarImage image,
int tileX,
int tileY,
Throwable cause)
Invoked when a tile computation failed. |
void |
tileComputed(Object eventSource,
TileRequest[] requests,
PlanarImage image,
int tileX,
int tileY,
Raster tile)
Invoked when a tile has been computed. |
void |
tileUpdate(WritableRenderedImage source,
int tileX,
int tileY,
boolean willBeWritable)
Invoked if the underlying image is writable and one of its tile changed. |
| Methods inherited from class Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface RenderedImage |
|---|
copyData, getColorModel, getData, getData, getHeight, getMinTileX, getMinTileY, getMinX, getMinY, getNumXTiles, getNumYTiles, getProperty, getPropertyNames, getSampleModel, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getWidth |
| Constructor Detail |
|---|
public DeferredPlanarImage(RenderedImage source)
DeferredPlanarImage.
source - The source image.| Method Detail |
|---|
public Vector<RenderedImage> getSources()
getSources in interface RenderedImagegetSources in class PlanarImage
public Raster getTile(int tileX,
int tileY)
TileObserver when the real tile will
be available.
getTile in interface RenderedImagegetTile in class PlanarImagetileX - Tile X index.tileY - Tile Y index.
public void tileComputed(Object eventSource,
TileRequest[] requests,
PlanarImage image,
int tileX,
int tileY,
Raster tile)
tileComputed in interface TileComputationListenereventSource - The caller of this method.requests - The relevant tile computation requests as returned by the method used to queue the tile.image - The image for which tiles are being computed as specified to the TileScheduler.tileX - The X index of the tile in the tile array.tileY - The Y index of the tile in the tile array.tile - The computed tile.
public void tileCancelled(Object eventSource,
TileRequest[] requests,
PlanarImage image,
int tileX,
int tileY)
tileCancelled in interface TileComputationListenereventSource - The caller of this method.requests - The relevant tile computation requests as returned by the method used to queue the tile.image - The image for which tiles are being computed as specified to the TileScheduler.tileX - The X index of the tile in the tile array.tileY - The Y index of the tile in the tile array.
public void tileComputationFailure(Object eventSource,
TileRequest[] requests,
PlanarImage image,
int tileX,
int tileY,
Throwable cause)
tileComputationFailure in interface TileComputationListenereventSource - The caller of this method.requests - The relevant tile computation requests as returned by the method used to queue the tile.image - The image for which tiles are being computed as specified to the TileScheduler.tileX - The X index of the tile in the tile array.tileY - The Y index of the tile in the tile array.cause - The cause of the failure.
public void tileUpdate(WritableRenderedImage source,
int tileX,
int tileY,
boolean willBeWritable)
tileUpdate in interface TileObserverpublic void addTileObserver(TileObserver observer)
addTileObserver in interface WritableRenderedImageobserver - The observer to add.public void removeTileObserver(TileObserver observer)
removeTileObserver in interface WritableRenderedImageobserver - The observer to remove.
public WritableRaster getWritableTile(int tileX,
int tileY)
DeferredPlanarImage are not really
writable, this method throws an UnsupportedOperationException.
getWritableTile in interface WritableRenderedImage
public void releaseWritableTile(int tileX,
int tileY)
DeferredPlanarImage are
not really writable, this method throws an IllegalStateException (the state is
really illegal since getWritableTile(int, int) should never have succeeded).
releaseWritableTile in interface WritableRenderedImagepublic boolean hasTileWriters()
hasTileWriters in interface WritableRenderedImage
public boolean isTileWritable(int tileX,
int tileY)
isTileWritable in interface WritableRenderedImagepublic Point[] getWritableTileIndices()
Point objects indicating which tiles are
checked out for writing. Returns null if none are checked out.
getWritableTileIndices in interface WritableRenderedImagepublic void setData(Raster r)
DeferredPlanarImage are not really writable, this method
throws an UnsupportedOperationException.
setData in interface WritableRenderedImagepublic void dispose()
DeferredPlanarImage is used as a "view" of an other
image, and the user shouldn't know that he is not using directly the other image.
dispose in interface Disposabledispose in class PlanarImage
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||