Class WritableTiledImage
java.lang.Object
org.apache.sis.image.PlanarImage
org.apache.sis.internal.coverage.j2d.TiledImage
org.apache.sis.internal.coverage.j2d.WritableTiledImage
- All Implemented Interfaces:
RenderedImage,WritableRenderedImage
A writable version of
TiledImage.- Since:
- 1.1
- Version:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate TileObserver[]The observers, ornullif none.Indices of tiles taken for a write operation.Fields inherited from class org.apache.sis.image.PlanarImage
GRID_GEOMETRY_KEY, MASK_KEY, POSITIONAL_ACCURACY_KEY, SAMPLE_RESOLUTIONS_KEY, STATISTICS_KEY -
Constructor Summary
ConstructorsConstructorDescriptionWritableTiledImage(Map<String, Object> properties, ColorModel colorModel, int width, int height, int minTileX, int minTileY, WritableRaster... tiles) Creates a new tiled image. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTileObserver(TileObserver observer) Adds an observer to be notified when a tile is checked out for writing.getWritableTile(int tileX, int tileY) Checks out a tile for writing.Point[]Returns the indices of all tiles checked out for writing.booleanReturns whether any tile is checked out for writing.booleanisTileWritable(int tileX, int tileY) Returns whether a tile is currently checked out for writing.voidreleaseWritableTile(int tileX, int tileY) Relinquishes the right to write to a tile.voidremoveTileObserver(TileObserver observer) Removes an observer from the list of observers notified when a tile is checked out for writing.voidSets a region of the image to the contents of the given raster.Methods inherited from class org.apache.sis.internal.coverage.j2d.TiledImage
getColorModel, getHeight, getMinTileX, getMinTileY, getMinX, getMinY, getProperty, getPropertyNames, getSampleModel, getTile, getTileHeight, getTileWidth, getWidth, verifyMethods inherited from class org.apache.sis.image.PlanarImage
copyData, getBounds, getData, getData, getNumXTiles, getNumYTiles, getSources, getTileGridXOffset, getTileGridYOffset, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.awt.image.RenderedImage
copyData, getColorModel, getData, getData, getHeight, getMinTileX, getMinTileY, getMinX, getMinY, getNumXTiles, getNumYTiles, getProperty, getPropertyNames, getSampleModel, getSources, getTile, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getWidth
-
Field Details
-
observers
The observers, ornullif none. This is a copy-on-write array: values are never modified after construction (new arrays are created). This field is declared volatile because it is read without synchronization bygetWritableTile(int, int)andreleaseWritableTile(int, int). Since this is a copy-on-write array, it is okay to omit synchronization for those methods but we still need the memory effect. -
writables
Indices of tiles taken for a write operation. Values are counter of calls togetWritableTile(int, int). All accesses to this map shall be synchronized on the map instance.
-
-
Constructor Details
-
WritableTiledImage
public WritableTiledImage(Map<String, Object> properties, ColorModel colorModel, int width, int height, int minTileX, int minTileY, WritableRaster... tiles) Creates a new tiled image. The first tile in the given array must be the one located at the minimal tile indices. All tiles must have the same size and the same sample model and must be sorted in row-major fashion.- Parameters:
properties- image properties, ornullif none.colorModel- the color model, ornullif none.width- number of pixels along X axis in the whole rendered image.height- number of pixels along Y axis in the whole rendered image.minTileX- minimum tile index in the X direction.minTileY- minimum tile index in the Y direction.tiles- the tiles. Must contains at least one element. This array is not cloned.
-
-
Method Details
-
addTileObserver
Adds an observer to be notified when a tile is checked out for writing. If the observer is already present, it will receive multiple notifications.- Specified by:
addTileObserverin interfaceWritableRenderedImage- Parameters:
observer- the observer to notify.
-
removeTileObserver
Removes an observer from the list of observers notified when a tile is checked out for writing. 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:
removeTileObserverin interfaceWritableRenderedImage- Parameters:
observer- the observer to stop notifying.
-
getWritableTile
Checks out a tile for writing. If the same tile is checked out many times before to be released, only the first checkout is notified to listeners.- Specified by:
getWritableTilein interfaceWritableRenderedImage- Parameters:
tileX- the x index of the tile.tileY- the y index of the tile.- Returns:
- the specified tile as a writable tile.
-
releaseWritableTile
public void releaseWritableTile(int tileX, int tileY) Relinquishes the right to write to a tile. If the tile goes from having one writer to having no writers, the values are inverse converted and written in the original image. If the caller continues to write to the tile, the results are undefined.- Specified by:
releaseWritableTilein interfaceWritableRenderedImage- Parameters:
tileX- the x index of the tile.tileY- the y index of the tile.
-
isTileWritable
public boolean isTileWritable(int tileX, int tileY) Returns whether a tile is currently checked out for writing.- Specified by:
isTileWritablein interfaceWritableRenderedImage- Parameters:
tileX- the x index of the tile.tileY- the y index of the tile.- Returns:
trueif specified tile is checked out for writing,falseotherwise.
-
getWritableTileIndices
Returns the indices of all tiles checked out for writing. Returns null if none are checked out.- Specified by:
getWritableTileIndicesin interfaceWritableRenderedImage- Returns:
- indices of tiles that are checked out for writing, or
nullif none.
-
hasTileWriters
public boolean hasTileWriters()Returns whether any tile is checked out for writing.- Specified by:
hasTileWritersin interfaceWritableRenderedImage- Returns:
trueif any tiles are checked out for writing, orfalseotherwise.
-
setData
Sets a region of the image to the contents of the given raster. The raster is assumed to be in the same coordinate space as this image. The operation is clipped to the bounds of this image.- Specified by:
setDatain interfaceWritableRenderedImage- Parameters:
data- the values to write in this image.
-