Class 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 Details

    • inverses

      private final org.opengis.referencing.operation.MathTransform1D[] inverses
      The converters for computing the source values from a converted value.
    • observers

      private volatile TileObserver[] observers
      The observers, or null 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 by markTileWritable(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

      public void addTileObserver(TileObserver observer)
      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 interface WritableRenderedImage
      Parameters:
      observer - the observer to notify.
    • removeTileObserver

      public void removeTileObserver(TileObserver observer)
      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 interface WritableRenderedImage
      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 class ComputedImage
      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, or false for releasing it.
      Returns:
      true if the tile goes from having no writers to having one writer (may happen if writing is true), or goes from having one writer to no writers (may happen if writing is false).
      See Also:
    • getWritableTile

      public WritableRaster getWritableTile(int tileX, int tileY)
      Checks out a tile for writing.
      Specified by:
      getWritableTile in interface WritableRenderedImage
      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 interface WritableRenderedImage
      Parameters:
      tileX - the x index of the tile.
      tileY - the y index of the tile.
    • setData

      public void setData(Raster data)
      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 interface WritableRenderedImage
      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 class BandedSampleConverter
    • equals

      public boolean equals(Object object)
      Restores the identity behavior for writable image, because it may have listeners attached to this specific instance.
      Overrides:
      equals in class BandedSampleConverter