Revision 6900 org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.fmap.mapcontext.raster.swing/org.gvsig.fmap.mapcontext.raster.swing.impl/src/main/java/org/gvsig/fmap/mapcontext/raster/swing/impl/bands/BandsPanelController.java

View differences:

BandsPanelController.java
62 62
import org.gvsig.raster.lib.buffer.api.BufferLocator;
63 63
import org.gvsig.raster.lib.buffer.api.BufferManager;
64 64
import org.gvsig.raster.lib.buffer.api.NoData;
65
import org.gvsig.raster.lib.legend.api.ColorInterpretation;
66 65
import org.gvsig.raster.lib.legend.api.RasterLegend;
67 66
import org.gvsig.raster.lib.legend.api.RasterLegendLocator;
68 67
import org.gvsig.raster.lib.legend.api.RasterLegendManager;
68
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation;
69 69
import org.gvsig.tools.ToolsLocator;
70 70
import org.gvsig.tools.dynobject.DynObject;
71 71
import org.gvsig.tools.i18n.I18nManager;
......
158 158
    @SuppressWarnings("unchecked")
159 159
    public void set(FLayer layer) {
160 160
        this.layer = (RasterLayer) layer;
161
        RasterLegend legend = null;
162
        try {
163
            legend = (RasterLegend) this.layer.getLegend();
164
        } catch (LegendLayerException e) {
165
            LOG.warn("Can't get legend from '" + layer + "' layer.", e);
166
        }
161
        RasterLegend legend = this.layer.getLegend();
167 162
        ColorInterpretation colorInterpretation = null;
168 163
        if (legend != null) {
169 164
            colorInterpretation = legend.getColorInterpretation();
......
242 237
                bandDescriptor.setNoData(noData);
243 238
            }
244 239
            rasterLayer.recalculateStatistics();
245
        }
246 240

  
247
        List<String> colorInterpretations = getColorInterpretations();
248
        ColorInterpretation colorInterpretation =
249
            rasterLegendManager.createColorInterpretation(colorInterpretations.toArray(new String[0]));
241
            List<String> colorInterpretations = getColorInterpretations();
242
            ColorInterpretation colorInterpretation =
243
                rasterLegendManager.createColorInterpretation(colorInterpretations.toArray(new String[0]));
250 244

  
251
        RasterLegend legend = rasterLegendManager.createLegend(colorInterpretation);
252
        rasterLayer.setLegend(legend);
253
        rasterLayer.getMapContext().invalidate();
245
            RasterLegend legend = rasterLegendManager.createLegend(colorInterpretation);
246
            rasterLayer.setLegend(legend);
247
            rasterLayer.getMapContext().invalidate();
248
        }
249

  
254 250
        return true;
255 251
    }
256 252

  
......
274 270
        if(store.getBands()!=model.getRowCount()){
275 271
            return true;
276 272
        }
273
        ColorInterpretation colorInterpretation = this.layer.getLegend().getColorInterpretation();
277 274
        for (int index = 0; index < model.getRowCount(); index++) {
278 275
            RasterStoreBand rasterStoreBand = model.getElementAt(index);
279 276
            RasterStore subStore = rasterStoreBand.getStore();
280 277
            int band = rasterStoreBand.getBand();
281 278
            BandDescriptor bandDescriptor = store.getBandDescriptor(index);
282 279
            if (bandDescriptor.getStore() != subStore || bandDescriptor.getBand() != band
283
                || isChangedNoData(bandDescriptor.getNoData(), rasterStoreBand.getNoDataNumber())){
280
                || isChangedNoData(bandDescriptor.getNoData(), rasterStoreBand.getNoDataNumber())
281
                || !(rasterStoreBand.getBandColorInterpretation().equals(colorInterpretation.get(index)))
282
               ){
284 283
                return true;
285 284
            }
286 285
        }

Also available in: Unified diff