All Packages Class Hierarchy This Package Previous Next Index
Interface java.awt.image.WritableRenderedImage
- public interface WritableRenderedImage
- extends RenderedImage
WriteableRenderedImage is a common interface for objects which
contain or can produce image data which can be modified and/or
written over.
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 (from getWritableTiles, in the form of a Vector
of Point objects).
Object wishing to be notified of changes in tile writability must
implement the TileChangeListener interface, and are added by a
call to addTileChangeListener. Multiple calls to
addTileChangeListener for the same object will result in multiple
notifications. An existing listener may reduce its notifications
by calling removeTileChangeListener; if the listener had no
notifications the operation is a no-op. A Vector of the current
TileChangeListeners is obtained by calling getTileChangeListeners.
It is necessary for a WritableRenderedImage to ensure that
notifications occur only when the first writer acquires a tile and
the last writer deacquires it. To simplify the necessary
bookkeeping, the TileChangeMulticaster class is available. Calls to
getWritableTile are forwarded to calls to addTileWriter and calls
to releaseWritableTile are forwared to calls to removeTileWriter;
other listener-related calls are trivially forwarded (see
BufferedImage for an example of this style of implementation).
A TileChangeMulticaster may be used to inform a number of objects
of a tile change event from a single notification.
addTileChangeListener(TileChangeListener)
- Add a listener.
getTileChangeListeners()
- Return a Vector of TileChangeListener objects.
getWritableTile(int, int)
- Check out a tile for writing.
getWritableTiles()
- Return a array of Point objects indicating which tiles
are checked out for writing.
hasTileWriters()
- Return whether any tile is checked out for writing.
isTileWritable(int, int)
- Return whether a tile is currently checked out for writing.
releaseWritableTile(int, int)
- Relinquish the right to write to a tile.
removeTileChangeListener(TileChangeListener)
- Remove a listener.
setRect(Raster)
- Set a rect of the image to the contents of rb.
addTileChangeListener
public abstract void addTileChangeListener(TileChangeListener tcl)
- Add a listener. If the listener is already present,
it will receive multiple notifications.
removeTileChangeListener
public abstract void removeTileChangeListener(TileChangeListener tcl)
- Remove a listener. If the listener was not registered,
nothing happens. If the listener was registered for multiple
notifications, it will now be registered for one fewer.
getTileChangeListeners
public abstract TileChangeListener[] getTileChangeListeners()
- Return a Vector of TileChangeListener objects.
Listeners registered multiple times will appear
a corresponding number of times in the list.
getWritableTile
public abstract WritableRaster getWritableTile(int tileX,
int tileY)
- Check out a tile for writing. This method is already part of
the WritableRenderedImage interface.
The WritableRenderedImage is responsible for notifying all
of its TileChangeListeners when a tile goes from having
no writers to having one writer. A simple way to fulfill this
contract is to instantiate a TileChangeFilter and to call
its addTileWriter method every time this method is called.
- Parameters:
- tileX - the X index of the tile.
- tileY - the Y index of the tile.
releaseWritableTile
public abstract void releaseWritableTile(int tileX,
int tileY)
- Relinquish the right to write to a tile. If the caller
continues to write to the tile, the results are undefined.
Calls to his 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 TileChangeListeners when a tile goes from having one writer
to having no writers. A simple way to fulfill this contract is
to instantiate a TileChangeFilter and to call its removeTileWriter
method every time this method is called.
- Parameters:
- tileX - the X index of the tile.
- tileY - the Y index of the tile.
isTileWritable
public abstract boolean isTileWritable(int tileX,
int tileY)
- Return whether a tile is currently checked out for writing.
This may be implemented by delegation to a TileChangeFilter.
- Parameters:
- tileX - the X index of the tile.
- tileY - the Y index of the tile.
getWritableTiles
public abstract Point[] getWritableTiles()
- Return a array of Point objects indicating which tiles
are checked out for writing.
hasTileWriters
public abstract boolean hasTileWriters()
- Return whether any tile is checked out for writing.
Equivalent to (getWritableTiles().size() != 0).
setRect
public abstract void setRect(Raster rb)
- Set a rect of the image to the contents of rb.
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature