eu.agrosense.client.io.geotiff.GeoTiffCoverageElement Maven / Gradle / Ivy
/**
* Copyright (C) 2008-2013 LimeTri. All rights reserved.
*
* AgroSense is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* There are special exceptions to the terms and conditions of the GPLv3 as it is applied to
* this software, see the FLOSS License Exception
* .
*
* AgroSense is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AgroSense. If not, see .
*/
package eu.agrosense.client.io.geotiff;
import java.awt.BorderLayout;
import java.util.logging.Logger;
import eu.limetri.api.geo.Geographical;
import eu.limetri.client.mapviewer.api.Palette;
import eu.limetri.client.mapviewer.swing.render.GridCoverage2DPreviewPanel;
import nl.cloudfarming.client.util.swing.MessagePanel;
import org.geotools.coverage.grid.GridCoverage2D;
import org.netbeans.core.spi.multiview.MultiViewElement;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
/**
*
* @author johan
*/
@MultiViewElement.Registration(
displayName = "#LBL_Geotiff_COVERAGE",
iconBase = GeoTiffDataObject.ICON_BASE,
mimeType = GeoTiffDataObject.MIME_TYPE,
persistenceType = TopComponent.PERSISTENCE_NEVER,
preferredID = "GeotiffVisual",
position = 2000)
@NbBundle.Messages({
"LBL_Geotiff_COVERAGE=Coverage",
"GeoTiffCoverageElement multiband not supported=Rasters using multiple bands are currently not supported"
})
public class GeoTiffCoverageElement extends AbstractGeoTiffElement {
private static final Logger LOGGER = Logger.getLogger(GeoTiffCoverageElement.class.getName());
private final MessagePanel messagePanel = new MessagePanel(MessagePanel.LARGE_ICON);
public GeoTiffCoverageElement(Lookup lkp) {
super(lkp);
init(lkp);
}
private void init(Lookup lkp) {
setLayout(new BorderLayout());
add(messagePanel, BorderLayout.NORTH);
// Geographical geographical = (Geographical) lkp.lookup(Geographical.class);
// Palette palette = lkp.lookup(Palette.class);
Geographical geographical = new AbstractGeoTiffGeographical.CroppedGridImpl(obj.getCoverage());
Palette palette = GeoTiffDataObject.getGridPalette(obj);
GridCoverage2D coverage = geographical.getRenderObject(null);
int numBands = coverage.getNumSampleDimensions();
if (numBands > 1) {
// can't apply a ColorMap to a multiband coverage (org.geotools.renderer.lite.gridcoverage2d.ColorMapNode:150)
// TODO: find alternative rendering.
messagePanel.setWarning(Bundle.GeoTiffCoverageElement_multiband_not_supported());
} else {
GridCoverage2DPreviewPanel previewPanel = new GridCoverage2DPreviewPanel(geographical, palette);
add(previewPanel, BorderLayout.CENTER);
}
}
@Override
public String getName() {
return "GeoTiffCoverageElement";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy