Package org.apache.sis.image
Class BandedSampleConverter.Writable
java.lang.Object
org.apache.sis.image.PlanarImage
org.apache.sis.image.ComputedImage
org.apache.sis.image.BandedSampleConverter
org.apache.sis.image.BandedSampleConverter.Writable
- All Implemented Interfaces:
RenderedImage
,WritableRenderedImage
,Disposable
- Enclosing class:
- BandedSampleConverter
private static final class BandedSampleConverter.Writable
extends BandedSampleConverter
implements WritableRenderedImage
A
BandedSampleConverter
capable to retro-propagate the changes to the source coverage.
This class contains the inverse of all MathTransform1D
given to the parent class.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.opengis.referencing.operation.MathTransform1D[]
The converters for computing the source values from a converted value.private TileObserver[]
The observers, ornull
if none.Fields inherited from class org.apache.sis.image.ComputedImage
sampleModel, SOURCE_PADDING_KEY
Fields inherited from class org.apache.sis.image.PlanarImage
GRID_GEOMETRY_KEY, MASK_KEY, POSITIONAL_ACCURACY_KEY, SAMPLE_RESOLUTIONS_KEY, STATISTICS_KEY
-
Constructor Summary
ConstructorsConstructorDescriptionWritable
(WritableRenderedImage source, BandedSampleModel sampleModel, ColorModel colorModel, NumberRange<?>[] ranges, org.opengis.referencing.operation.MathTransform1D[] converters, org.opengis.referencing.operation.MathTransform1D[] inverses) Creates a new writable image which will compute values using the given converters. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTileObserver
(TileObserver observer) Adds an observer to be notified when a tile is checked out for writing.boolean
Restores the identity behavior for writable image, because it may have listeners attached to this specific instance.getWritableTile
(int tileX, int tileY) Checks out a tile for writing.int
hashCode()
Restores the identity behavior for writable image, because it may have listeners attached to this specific instance.protected boolean
markTileWritable
(int tileX, int tileY, boolean writing) Sets or clears whether a tile is checked out for writing and notifies the listener if needed.void
releaseWritableTile
(int tileX, int tileY) Relinquishes the right to write to a tile.void
removeTileObserver
(TileObserver observer) Removes an observer from the list of observers notified when a tile is checked out for writing.void
Sets a region of the image to the contents of the given raster.Methods inherited from class org.apache.sis.image.BandedSampleConverter
computeTile, create, getColorModel, getHeight, getMinTileX, getMinTileY, getMinX, getMinY, getProperty, getPropertyNames, getWidth, prefetch
Methods inherited from class org.apache.sis.image.ComputedImage
clearErrorFlags, createTile, dispose, equalsBase, getDestination, getSampleModel, getSource, getSource, getSources, getTile, getTileHeight, getTileWidth, getWritableTileIndices, hashCodeBase, hasTileWriters, isTileWritable, markDirtyTiles, reference, setDestination, sourceTileChanged
Methods inherited from class org.apache.sis.image.PlanarImage
copyData, getBounds, getData, getData, getNumXTiles, getNumYTiles, getTileGridXOffset, getTileGridYOffset, toString, verify
Methods inherited from class java.lang.Object
clone, finalize, getClass, 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, getTile, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getWidth
Methods inherited from interface java.awt.image.WritableRenderedImage
getWritableTileIndices, hasTileWriters, isTileWritable
-
Field Details
-
inverses
private final org.opengis.referencing.operation.MathTransform1D[] inversesThe converters for computing the source values from a converted value. -
observers
The observers, ornull
if 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 bymarkTileWritable(int, int, boolean)
. Since this is a copy-on-write array, it is okay to omit synchronization for that method but we still need the memory effect.
-
-
Constructor Details
-
Writable
Writable(WritableRenderedImage source, BandedSampleModel sampleModel, ColorModel colorModel, NumberRange<?>[] ranges, org.opengis.referencing.operation.MathTransform1D[] converters, org.opengis.referencing.operation.MathTransform1D[] inverses) Creates a new writable image which will compute values using the given converters.
-
-
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:
addTileObserver
in 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:
removeTileObserver
in interfaceWritableRenderedImage
- Parameters:
observer
- the observer to stop notifying.
-
markTileWritable
protected boolean markTileWritable(int tileX, int tileY, boolean writing) Sets or clears whether a tile is checked out for writing and notifies the listener if needed.- Overrides:
markTileWritable
in classComputedImage
- Parameters:
tileX
- the x index of the tile to acquire or release.tileY
- the y index of the tile to acquire or release.writing
-true
for acquiring the tile, orfalse
for releasing it.- Returns:
true
if the tile goes from having no writers to having one writer (may happen ifwriting
istrue
), or goes from having one writer to no writers (may happen ifwriting
isfalse
).- See Also:
-
getWritableTile
Checks out a tile for writing.- Specified by:
getWritableTile
in 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:
releaseWritableTile
in interfaceWritableRenderedImage
- Parameters:
tileX
- the x index of the tile.tileY
- the y index of the tile.
-
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:
setData
in interfaceWritableRenderedImage
- Parameters:
data
- the values to write in this image.
-
hashCode
public int hashCode()Restores the identity behavior for writable image, because it may have listeners attached to this specific instance.- Overrides:
hashCode
in classBandedSampleConverter
-
equals
Restores the identity behavior for writable image, because it may have listeners attached to this specific instance.- Overrides:
equals
in classBandedSampleConverter
-