|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.media.jai.PlanarImage
org.geotools.image.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.
Simple 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); } }
Field Summary |
---|
Fields inherited from class javax.media.jai.PlanarImage |
---|
colorModel, eventManager, height, minX, minY, properties, sampleModel, tileFactory, tileGridXOffset, tileGridYOffset, tileHeight, tileWidth, width |
Constructor Summary | |
---|---|
DeferredPlanarImage(java.awt.image.RenderedImage source)
Constructs a new instance of DeferredPlanarImage . |
Method Summary | |
---|---|
void |
addTileObserver(java.awt.image.TileObserver observer)
Adds an observer. |
void |
dispose()
Provides a hint that this image will no longer be accessed from a reference in user space. |
java.awt.image.Raster |
getTile(int tileX,
int tileY)
Returns the specified tile, or a default one if the requested tile is not yet available. |
java.awt.image.WritableRaster |
getWritableTile(int tileX,
int tileY)
Checks out a tile for writing. |
java.awt.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(java.awt.image.TileObserver observer)
Removes an observer. |
void |
setData(java.awt.image.Raster r)
Sets a rectangle of the image to the contents of the raster. |
void |
tileCancelled(java.lang.Object eventSource,
javax.media.jai.TileRequest[] requests,
javax.media.jai.PlanarImage image,
int tileX,
int tileY)
Invoked when a tile computation has been cancelled. |
void |
tileComputationFailure(java.lang.Object eventSource,
javax.media.jai.TileRequest[] requests,
javax.media.jai.PlanarImage image,
int tileX,
int tileY,
java.lang.Throwable cause)
Invoked when a tile computation failed. |
void |
tileComputed(java.lang.Object eventSource,
javax.media.jai.TileRequest[] requests,
javax.media.jai.PlanarImage image,
int tileX,
int tileY,
java.awt.image.Raster tile)
Invoked when a tile has been computed. |
void |
tileUpdate(java.awt.image.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 javax.media.jai.PlanarImage |
---|
addPropertyChangeListener, addPropertyChangeListener, addSink, addSink, addSource, addTileComputationListener, cancelTiles, copyData, copyData, copyExtendedData, createColorModel, createSnapshot, createWritableRaster, finalize, getAsBufferedImage, getAsBufferedImage, getBounds, getColorModel, getData, getData, getDefaultColorModel, getExtendedData, getGraphics, getHeight, getImageID, getMaxTileX, getMaxTileY, getMaxX, getMaxY, getMinTileX, getMinTileY, getMinX, getMinY, getNumBands, getNumSources, getNumXTiles, getNumYTiles, getProperties, getProperty, getPropertyClass, getPropertyNames, getPropertyNames, getSampleModel, getSinks, getSource, getSourceImage, getSourceObject, getSources, getSplits, getTileComputationListeners, getTileFactory, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileIndices, getTileRect, getTiles, getTiles, getTileWidth, getWidth, overlapsMultipleTiles, prefetchTiles, queueTiles, removeProperty, removePropertyChangeListener, removePropertyChangeListener, removeSink, removeSink, removeSinks, removeSource, removeSources, removeTileComputationListener, setImageLayout, setProperties, setProperty, setSource, setSources, tileXToX, tileXToX, tileYToY, tileYToY, toString, wrapRenderedImage, XToTileX, XToTileX, YToTileY, YToTileY |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.image.RenderedImage |
---|
copyData, getColorModel, getData, getData, getHeight, getMinTileX, getMinTileY, getMinX, getMinY, getNumXTiles, getNumYTiles, getProperty, getPropertyNames, getSampleModel, getSources, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getWidth |
Constructor Detail |
---|
public DeferredPlanarImage(java.awt.image.RenderedImage source)
DeferredPlanarImage
.
source
- The source image.Method Detail |
---|
public java.awt.image.Raster getTile(int tileX, int tileY)
TileObserver
when the real tile will
be available.
getTile
in interface java.awt.image.RenderedImage
getTile
in class javax.media.jai.PlanarImage
tileX
- Tile X index.tileY
- Tile Y index.
public void tileComputed(java.lang.Object eventSource, javax.media.jai.TileRequest[] requests, javax.media.jai.PlanarImage image, int tileX, int tileY, java.awt.image.Raster tile)
tileComputed
in interface javax.media.jai.TileComputationListener
eventSource
- 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(java.lang.Object eventSource, javax.media.jai.TileRequest[] requests, javax.media.jai.PlanarImage image, int tileX, int tileY)
tileCancelled
in interface javax.media.jai.TileComputationListener
public void tileComputationFailure(java.lang.Object eventSource, javax.media.jai.TileRequest[] requests, javax.media.jai.PlanarImage image, int tileX, int tileY, java.lang.Throwable cause)
tileComputationFailure
in interface javax.media.jai.TileComputationListener
public void tileUpdate(java.awt.image.WritableRenderedImage source, int tileX, int tileY, boolean willBeWritable)
tileUpdate
in interface java.awt.image.TileObserver
public void addTileObserver(java.awt.image.TileObserver observer)
addTileObserver
in interface java.awt.image.WritableRenderedImage
public void removeTileObserver(java.awt.image.TileObserver observer)
removeTileObserver
in interface java.awt.image.WritableRenderedImage
public java.awt.image.WritableRaster getWritableTile(int tileX, int tileY)
DeferredPlanarImage
are not really
writable, this method throws an UnsupportedOperationException
.
getWritableTile
in interface java.awt.image.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 java.awt.image.WritableRenderedImage
public boolean hasTileWriters()
hasTileWriters
in interface java.awt.image.WritableRenderedImage
public boolean isTileWritable(int tileX, int tileY)
isTileWritable
in interface java.awt.image.WritableRenderedImage
public java.awt.Point[] getWritableTileIndices()
Point
objects indicating which tiles are
checked out for writing. Returns null if none are checked out.
getWritableTileIndices
in interface java.awt.image.WritableRenderedImage
public void setData(java.awt.image.Raster r)
DeferredPlanarImage
are not really writable, this method
throws an UnsupportedOperationException
.
setData
in interface java.awt.image.WritableRenderedImage
public 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 class javax.media.jai.PlanarImage
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |