# Class CoverageCanvas

Object
Observable
Canvas
PlanarCanvas
MapCanvas
MapCanvasAWT
CoverageCanvas

All Implemented Interfaces:
  `Localized`

@DefaultProperty("coverage") public class CoverageCanvas extends MapCanvasAWT
A canvas for `RenderedImage` provided by a `GridCoverage` or a `GridCoverageResource`. In the latter case where the source of data is specified by `resourceProperty`, the grid coverage instance (given by `coverageProperty`) will change automatically according the zoom level.

Since:
  1.1
See Also:
  - `CoverageExplorer`

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from class MapCanvasAWT

  `MapCanvasAWT​.Renderer`

- ## Property Summary

  ### Properties inherited from class MapCanvas

  `error, rendering`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `final ObjectProperty<GridCoverage>`
  `coverageProperty`
  The data shown in this canvas.
  `final ObjectProperty<Interpolation>`
  `interpolationProperty`
  The interpolation method to use for resampling the image.
  `final ObjectProperty<GridCoverageResource>`
  `resourceProperty`
  The source of coverage data shown in this canvas.
  `final ObjectProperty<GridExtent>`
  `sliceExtentProperty`
  A subspace of the grid coverage extent where all dimensions except two have a size of 1 cell.

  ### Fields inherited from class MapCanvasAWT

  `image, imageMargin`

  ### Fields inherited from class MapCanvas

  `fixedPane, floatingPane`

  ### Fields inherited from class PlanarCanvas

  `BIDIMENSIONAL, objectiveToDisplay`

  ### Fields inherited from class Canvas

  `DISPLAY_BOUNDS_PROPERTY, OBJECTIVE_CRS_PROPERTY, OBJECTIVE_TO_DISPLAY_PROPERTY, POINT_OF_INTEREST_PROPERTY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CoverageCanvas()`
  Creates a new two-dimensional canvas for `RenderedImage`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `clear()`
  Removes the image shown and releases memory.
  `protected MapCanvasAWT​.Renderer`
  `createRenderer()`
  Invoked in JavaFX thread for creating a renderer to be executed in a background thread.
  `final GridCoverage`
  `getCoverage()`
  Returns the source of image for this viewer.
  `final Interpolation`
  `getInterpolation()`
  Gets the interpolation method used during resample operations.
  `final GridCoverageResource`
  `getResource()`
  Returns the source of coverages for this viewer.
  `final GridExtent`
  `getSliceExtent()`
  Returns a subspace of the grid coverage extent where all dimensions except two have a size of 1 cell.
  `final void`
  `setCoverage(GridCoverage coverage)`
  Sets the coverage to show in this viewer.
  `final void`
  `setInterpolation(Interpolation interpolation)`
  Sets the interpolation method to use during resample operations.
  `final void`
  `setResource(GridCoverageResource resource)`
  Sets the source of coverages shown in this viewer.
  `final void`
  `setSliceExtent(GridExtent sliceExtent)`
  Sets a subspace of the grid coverage extent where all dimensions except two have a size of 1 cell.
  `String`
  `toString()`
  Returns a string representation for debugging purposes.

  ### Methods inherited from class MapCanvas

  `clearError, errorOccurred, errorProperty, getObjectiveBounds, initialize, renderingProperty, requestRepaint, reset, runAfterRendering, setObjectiveBounds, setObjectiveToDisplay, transformDisplayCoordinates, transformObjectiveCoordinates`

  ### Methods inherited from class PlanarCanvas

  `getDisplayBounds`

  ### Methods inherited from class Canvas

  `getDisplayCRS, getGeographicArea, getGridGeometry, getLocale, getObjectiveCRS, getObjectiveToDisplay, getPointOfInterest, getSpatialResolution, setDisplayBounds, setPointOfInterest`

  ### Methods inherited from class Observable

  `addPropertyChangeListener, firePropertyChange, firePropertyChange, hasPropertyChangeListener, removePropertyChangeListener`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### resourceProperty

    public final ObjectProperty<GridCoverageResource> resourceProperty
    The source of coverage data shown in this canvas. If this property value is non-null, then `coverageProperty` value will change at any time (potentially many times) depending on the zoom level or other user interaction. Conversely if a value is set explicitly on `coverageProperty`, then this `resourceProperty` is cleared.
    Since:
      1.2
    See Also:
      - `getResource()`
      - `setResource(GridCoverageResource)`
      - `CoverageExplorer​.resourceProperty`

  - ### coverageProperty

    public final ObjectProperty<GridCoverage> coverageProperty
    The data shown in this canvas. This property value may be set implicitly or explicitly:
    - If the `resourceProperty` value is non-null, then the value will change automatically at any time (potentially many times) depending on user interaction.
    - Conversely if an explicit value is set on this property, then the `resourceProperty` is cleared.
    Note that a change in this property value may not modify the canvas content immediately. Instead, a background process will request the tiles and update the canvas content later, when data are ready.

    Current implementation is restricted to `GridCoverage` instances, but a future implementation may generalize to `org​.opengis​.coverage​.Coverage` instances.

    See Also:
      - `getCoverage()`
      - `setCoverage(GridCoverage)`
      - `CoverageExplorer​.coverageProperty`

  - ### sliceExtentProperty

    public final ObjectProperty<GridExtent> sliceExtentProperty
    A subspace of the grid coverage extent where all dimensions except two have a size of 1 cell. May be `null` if the grid coverage has only two dimensions with a size greater than 1 cell.
    See Also:
      - `getSliceExtent()`
      - `setSliceExtent(GridExtent)`
      - `GridCoverage​.render(GridExtent)`

  - ### interpolationProperty

    public final ObjectProperty<Interpolation> interpolationProperty
    The interpolation method to use for resampling the image.
    See Also:
      - `getInterpolation()`
      - `setInterpolation(Interpolation)`

- ## Constructor Details

  - ### CoverageCanvas

    public CoverageCanvas()
    Creates a new two-dimensional canvas for `RenderedImage`.

- ## Method Details

  - ### getResource

    public final GridCoverageResource getResource()
    Returns the source of coverages for this viewer. This method, like all other methods in this class, shall be invoked from the JavaFX thread.
    Returns:
      the source of coverages shown in this viewer, or `null` if none.
    Since:
      1.2
    See Also:
      - `resourceProperty`

  - ### setResource

    public final void setResource(GridCoverageResource resource)
    Sets the source of coverages shown in this viewer. This method shall be invoked from JavaFX thread and returns immediately. The new data are loaded in a background thread and the `coverageProperty` value will be updated after an undetermined amount of time.
    Parameters:
      `resource` - the source of data to show in this viewer, or `null` if none.
    Since:
      1.2
    See Also:
      - `resourceProperty`

  - ### getCoverage

    public final GridCoverage getCoverage()
    Returns the source of image for this viewer. This method, like all other methods in this class, shall be invoked from the JavaFX thread. Note that this value may change at any time (depending on user interaction) if the `resourceProperty` has a non-null value.
    Returns:
      the coverage shown in this explorer, or `null` if none.
    See Also:
      - `coverageProperty`

  - ### setCoverage

    public final void setCoverage(GridCoverage coverage)
    Sets the coverage to show in this viewer. This method shall be invoked from JavaFX thread and returns immediately. The new data are loaded in a background thread and will appear after an undetermined amount of time.

    Invoking this method sets the `resourceProperty` value to `null`.

    Parameters:
      `coverage` - the data to show in this viewer, or `null` if none.
    See Also:
      - `coverageProperty`

  - ### getSliceExtent

    public final GridExtent getSliceExtent()
    Returns a subspace of the grid coverage extent where all dimensions except two have a size of 1 cell.
    Returns:
      subspace of the grid coverage extent where all dimensions except two have a size of 1 cell.
    See Also:
      - `sliceExtentProperty`
      - `GridCoverage​.render(GridExtent)`

  - ### setSliceExtent

    public final void setSliceExtent(GridExtent sliceExtent)
    Sets a subspace of the grid coverage extent where all dimensions except two have a size of 1 cell. Note that values set on this property may be overwritten at any time by user interactions if this `CoverageCanvas` is associated with a `GridSliceSelector`.
    Parameters:
      `sliceExtent` - subspace of the grid coverage extent where all dimensions except two have a size of 1 cell.
    See Also:
      - `sliceExtentProperty`
      - `GridCoverage​.render(GridExtent)`

  - ### getInterpolation

    public final Interpolation getInterpolation()
    Gets the interpolation method used during resample operations.
    Returns:
      the current interpolation method.
    See Also:
      - `interpolationProperty`

  - ### setInterpolation

    public final void setInterpolation(Interpolation interpolation)
    Sets the interpolation method to use during resample operations.
    Parameters:
      `interpolation` - the new interpolation method.
    See Also:
      - `interpolationProperty`

  - ### createRenderer

    protected MapCanvasAWT.Renderer createRenderer()
    Invoked in JavaFX thread for creating a renderer to be executed in a background thread. This method prepares the information needed but does not start the rendering itself. The rendering will be done later by a call to `MapCanvasAWT​.Renderer​.paint(Graphics2D)`.
    Specified by:
      `createRenderer` in class `MapCanvasAWT`
    Returns:
      rendering process to be executed in background thread, or `null` if there is nothing to paint.

  - ### clear

    protected void clear()
    Removes the image shown and releases memory.

    #### Usage

    Overriding methods in subclasses should invoke `super​.clear()`. Other methods should generally not invoke this method directly, and use the following code instead:

        runAfterRendering(this::clear);

    Overrides:
      `clear` in class `MapCanvasAWT`
    See Also:
      - `MapCanvas​.runAfterRendering(Runnable)`

  - ### toString

    public String toString()
    Returns a string representation for debugging purposes. The string content may change in any future version.
    Overrides:
      `toString` in class `MapCanvas`
    Returns:
      debug string (may change in any future version).