WriteableRenderedImage is a common interface for objects which contain or can produce image data in the form of Rasters and which can be modified and/or written over. The image data may be stored/produced as a single tile or a regular array of tiles.

WritableRenderedImage provides notification to other interested objects when a tile is checked out for writing (via the getWritableTile method) and when the last writer of a particular tile relinquishes its access (via a call to releaseWritableTile). Additionally, it allows any caller to determine whether any tiles are currently checked out (via hasTileWriters), and to obtain a list of such tiles (via getWritableTileIndices, in the form of a Vector of Point objects).

Objects wishing to be notified of changes in tile writability must implement the TileObserver interface, and are added by a call to addTileObserver. Multiple calls to addTileObserver for the same object will result in multiple notifications. An existing observer may reduce its notifications by calling removeTileObserver; if the observer had no notifications the operation is a no-op.

It is necessary for a WritableRenderedImage to ensure that notifications occur only when the first writer acquires a tile and the last writer releases it.

Adds an observer. If the observer is already present, it will receive multiple notifications.
Parameters
tothe specified TileObserver
Computes an arbitrary rectangular region of the RenderedImage and copies it into a caller-supplied WritableRaster. The region to be computed is determined from the bounds of the supplied WritableRaster. The supplied WritableRaster must have a SampleModel that is compatible with this image. If raster is null, an appropriate WritableRaster is created.
Parameters
rastera WritableRaster to hold the returned portion of the image, or null.
Return
a reference to the supplied or created WritableRaster.
Returns the ColorModel associated with this image. All Rasters returned from this image will have this as their ColorModel. This can return null.
Return
the ColorModel of this image.
Returns the image as one large tile (for tile based images this will require fetching the whole image and copying the image data over). The Raster returned is a copy of the image data and will not be updated if the image is changed.
Return
the image as one large tile.
Computes and returns an arbitrary region of the RenderedImage. The Raster returned is a copy of the image data and will not be updated if the image is changed.
Parameters
rectthe region of the RenderedImage to be returned.
Return
the region of the RenderedImage indicated by the specified Rectangle.
Returns the height of the RenderedImage.
Return
the height of this RenderedImage.
Returns the minimum tile index in the X direction.
Return
the minimum tile index in the X direction.
Returns the minimum tile index in the Y direction.
Return
the minimum tile index in the X direction.
Returns the minimum X coordinate (inclusive) of the RenderedImage.
Return
the X coordinate of this RenderedImage.
Returns the minimum Y coordinate (inclusive) of the RenderedImage.
Return
the Y coordinate of this RenderedImage.
Returns the number of tiles in the X direction.
Return
the number of tiles in the X direction.
Returns the number of tiles in the Y direction.
Return
the number of tiles in the Y direction.
Gets a property from the property set of this image. The set of properties and whether it is immutable is determined by the implementing class. This method returns java.awt.Image.UndefinedProperty if the specified property is not defined for this RenderedImage.
Parameters
namethe name of the property
Return
the property indicated by the specified name.
Returns an array of names recognized by getProperty(String) or null, if no property names are recognized.
Return
a String array containing all of the property names that getProperty(String) recognizes; or null if no property names are recognized.
Returns the SampleModel associated with this image. All Rasters returned from this image will have this as their SampleModel.
Return
the SampleModel of this image.
Returns a vector of RenderedImages that are the immediate sources of image data for this RenderedImage. This method returns null if the RenderedImage object has no information about its immediate sources. It returns an empty Vector if the RenderedImage object has no immediate sources.
Return
a Vector of RenderedImage objects.
Returns tile (tileX, tileY). Note that tileX and tileY are indices into the tile array, not pixel locations. The Raster that is returned is live and will be updated if the image is changed.
Parameters
tileXthe X index of the requested tile in the tile array
tileYthe Y index of the requested tile in the tile array
Return
the tile given the specified indices.
Returns the X offset of the tile grid relative to the origin, i.e., the X coordinate of the upper-left pixel of tile (0, 0). (Note that tile (0, 0) may not actually exist.)
Return
the X offset of the tile grid relative to the origin.
Returns the Y offset of the tile grid relative to the origin, i.e., the Y coordinate of the upper-left pixel of tile (0, 0). (Note that tile (0, 0) may not actually exist.)
Return
the Y offset of the tile grid relative to the origin.
Returns the tile height in pixels. All tiles must have the same height.
Return
the tile height in pixels.
Returns the tile width in pixels. All tiles must have the same width.
Return
the tile width in pixels.
Returns the width of the RenderedImage.
Return
the width of this RenderedImage.
Checks out a tile for writing. The WritableRenderedImage is responsible for notifying all of its TileObservers when a tile goes from having no writers to having one writer.
Parameters
tileXthe X index of the tile.
tileYthe Y index of the tile.
Return
a writable tile.
Returns an array of Point objects indicating which tiles are checked out for writing. Returns null if none are checked out.
Return
an array containing the locations of tiles that are checked out for writing.
Returns whether any tile is checked out for writing. Semantically equivalent to (getWritableTileIndices() != null).
Return
true if any tiles are checked out for writing; false otherwise.
Returns whether a tile is currently checked out for writing.
Parameters
tileXthe X index of the tile.
tileYthe Y index of the tile.
Return
true if specified tile is checked out for writing; false otherwise.
Relinquishes the right to write to a tile. If the caller continues to write to the tile, the results are undefined. Calls to this method should only appear in matching pairs with calls to getWritableTile; any other use will lead to undefined results. The WritableRenderedImage is responsible for notifying all of its TileObservers when a tile goes from having one writer to having no writers.
Parameters
tileXthe X index of the tile.
tileYthe Y index of the tile.
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.
Parameters
tothe specified TileObserver
Sets a rect of the image to the contents of the Raster r, which is assumed to be in the same coordinate space as the WritableRenderedImage. The operation is clipped to the bounds of the WritableRenderedImage.
Parameters
rthe specified Raster