org.geotools.resources.image
Class DeferredPlanarImage

java.lang.Object
  extended byjavax.media.jai.PlanarImage
      extended byorg.geotools.resources.image.DeferredPlanarImage
All Implemented Interfaces:
java.util.EventListener, javax.media.jai.ImageJAI, javax.media.jai.PropertyChangeEmitter, javax.media.jai.PropertySource, java.awt.image.RenderedImage, javax.media.jai.TileComputationListener, java.awt.image.TileObserver, javax.media.jai.WritablePropertySource, java.awt.image.WritableRenderedImage

public final class DeferredPlanarImage
extends javax.media.jai.PlanarImage
implements java.awt.image.WritableRenderedImage, java.awt.image.TileObserver, javax.media.jai.TileComputationListener

G?re l'affichage en diff?r? d'une image compos?e de tuiles. Lorsqu'une tuile solicit?e n'est pas disponible, une tuile comportant une valeur par d?faut est retourn?e. Lorsque la tuile est enfin disponible, un ?v?nement est d?clench? indiquant au composant qui d?sire afficher l'image que la tuile est maintenant disponible.

Le composant qui d?sire ?tre inform? des ?v?nements sur les tuiles doit au pr?alable s'enregistrer aupr?s de la classe DefferedPlanarImage au travers de la m?thode addTileObserver(java.awt.image.TileObserver). Lorsque le composant est inform? qu'une tuile est pr?te, il lui suffit d'appeler une m?thode repaint(...) pour mettre ? jour cette tuile.

Since:
2.0
Version:
$Id: DeferredPlanarImage.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Remi Eve, Martin Desruisseaux

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)
          Construct a new instance of .
 
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

DeferredPlanarImage

public DeferredPlanarImage(java.awt.image.RenderedImage source)
Construct a new instance of .

Parameters:
source - The source image.
Method Detail

getTile

public 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. If the requested tile is not immediately available, then an empty tile is returned and a notification will be sent later through TileObserver when the real tile will be available.

Specified by:
getTile in interface java.awt.image.RenderedImage
Parameters:
tileX - Tile X index.
tileY - Tile Y index.
Returns:
The requested tile.

tileComputed

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)
Invoked when a tile has been computed.

Specified by:
tileComputed in interface javax.media.jai.TileComputationListener
Parameters:
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.

tileCancelled

public 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. The default implementation do nothing.

Specified by:
tileCancelled in interface javax.media.jai.TileComputationListener

tileComputationFailure

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)
Invoked when a tile computation failed. Default implementation log a warning and lets the program continue as usual. We are not throwing an exception since this failure will alter the visual rendering, but will not otherwise destabilize the system.

Specified by:
tileComputationFailure in interface javax.media.jai.TileComputationListener

tileUpdate

public 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. This method forward the call to every registered listener.

Specified by:
tileUpdate in interface java.awt.image.TileObserver

addTileObserver

public void addTileObserver(java.awt.image.TileObserver observer)
Adds an observer. This observer will be notified everytime a tile initially empty become available. If the observer is already present, it will receive multiple notifications.

Specified by:
addTileObserver in interface java.awt.image.WritableRenderedImage

removeTileObserver

public void removeTileObserver(java.awt.image.TileObserver observer)
Removes an observer. If the observer was not registered, nothing happens. If the observer was registered for multiple notifications, it will now be registered for one fewer.

Specified by:
removeTileObserver in interface java.awt.image.WritableRenderedImage

getWritableTile

public java.awt.image.WritableRaster getWritableTile(int tileX,
                                                     int tileY)
Checks out a tile for writing. Since are not really writable, this method throws an UnsupportedOperationException.

Specified by:
getWritableTile in interface java.awt.image.WritableRenderedImage

releaseWritableTile

public void releaseWritableTile(int tileX,
                                int tileY)
Relinquishes the right to write to a tile. Since are not really writable, this method throws an IllegalStateException (the state is really illegal since getWritableTile(int, int) should never have succeeded).

Specified by:
releaseWritableTile in interface java.awt.image.WritableRenderedImage

hasTileWriters

public boolean hasTileWriters()
Returns whether any tile is checked out for writing.

Specified by:
hasTileWriters in interface java.awt.image.WritableRenderedImage

isTileWritable

public boolean isTileWritable(int tileX,
                              int tileY)
Returns whether a tile is currently checked out for writing.

Specified by:
isTileWritable in interface java.awt.image.WritableRenderedImage

getWritableTileIndices

public java.awt.Point[] getWritableTileIndices()
Returns an array of Point objects indicating which tiles are checked out for writing. Returns null if none are checked out.

Specified by:
getWritableTileIndices in interface java.awt.image.WritableRenderedImage

setData

public void setData(java.awt.image.Raster r)
Sets a rectangle of the image to the contents of the raster. Since are not really writable, this method throws an UnsupportedOperationException.

Specified by:
setData in interface java.awt.image.WritableRenderedImage

dispose

public void dispose()
Provides a hint that this image will no longer be accessed from a reference in user space. NOTE: this method dispose the image given to the constructor as well!. This is because is used as a "view" of an other image, and the user shouldn't know that he is not using directly the other image.



Copyright © GeoTools. All Rights Reserved.