Search in sources :

Example 1 with CoverageCanvas

use of org.apache.sis.gui.coverage.CoverageCanvas in project sis by apache.

the class ValuesUnderCursor method create.

/**
 * Creates a new instance for the given canvas and registers as a listener by weak reference.
 * Caller must retain the returned reference somewhere, e.g. in {@link StatusBar#sampleValuesProvider}.
 *
 * @param  canvas  the canvas for which to create a {@link ValuesUnderCursor}, or {@code null}.
 * @return the sample values provider, or {@code null} if none.
 */
static ValuesUnderCursor create(final MapCanvas canvas) {
    if (canvas instanceof CoverageCanvas) {
        final FromCoverage listener = new FromCoverage();
        final ObjectProperty<GridCoverage> coverageProperty = ((CoverageCanvas) canvas).coverageProperty;
        coverageProperty.addListener(new WeakChangeListener<>(listener));
        final GridCoverage coverage = coverageProperty.get();
        if (coverage != null) {
            listener.changed(null, null, coverage);
        }
        return listener;
    } else {
    // More cases may be added in the future.
    }
    return null;
}
Also used : GridCoverage(org.apache.sis.coverage.grid.GridCoverage) CoverageCanvas(org.apache.sis.gui.coverage.CoverageCanvas)

Aggregations

GridCoverage (org.apache.sis.coverage.grid.GridCoverage)1 CoverageCanvas (org.apache.sis.gui.coverage.CoverageCanvas)1