public interface WritableRenderedImage extends RenderedImage
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.
Modifier and Type | Method and Description |
---|---|
void |
addTileObserver(TileObserver to)
Adds an observer.
|
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 to)
Removes an observer.
|
void |
setData(Raster r)
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.
|
copyData, getColorModel, getData, getData, getHeight, getMinTileX, getMinTileY, getMinX, getMinY, getNumXTiles, getNumYTiles, getProperty, getPropertyNames, getSampleModel, getSources, getTile, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getWidth
void addTileObserver(TileObserver to)
to
- the specified TileObserver
void removeTileObserver(TileObserver to)
to
- the specified TileObserver
WritableRaster getWritableTile(int tileX, int tileY)
tileX
- the X index of the tile.tileY
- the Y index of the tile.void releaseWritableTile(int tileX, int tileY)
tileX
- the X index of the tile.tileY
- the Y index of the tile.boolean isTileWritable(int tileX, int tileY)
tileX
- the X index of the tile.tileY
- the Y index of the tile.true
if specified tile is checked out
for writing; false
otherwise.Point[] getWritableTileIndices()
boolean hasTileWriters()
true
if any tiles are checked out for
writing; false
otherwise.void setData(Raster r)
r
- the specified Raster
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2016, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.