Revision 8682 org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.legend/org.gvsig.raster.lib.legend.impl/src/main/java/org/gvsig/raster/lib/legend/impl/operations/equalization/EqualizationOperation.java

View differences:

EqualizationOperation.java
37 37
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory;
38 38
import org.gvsig.raster.lib.buffer.api.statistics.HistogramBand;
39 39
import org.gvsig.raster.lib.buffer.api.statistics.Statistics;
40
import org.gvsig.raster.lib.buffer.impl.exceptions.ProcessingOperationException;
40
import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException;
41 41
import org.gvsig.raster.lib.buffer.spi.operations.AbstractOperation;
42 42
import org.gvsig.raster.lib.legend.api.RasterLegendLocator;
43 43
import org.gvsig.raster.lib.legend.api.RasterLegendManager;
44 44
import org.gvsig.raster.lib.legend.api.colorinterpretation.ColorInterpretation;
45
import org.gvsig.raster.lib.legend.spi.AbstractColoredOperation;
45 46
import org.gvsig.tools.locator.LocatorException;
46 47

  
47 48

  
......
49 50
 * @author fdiaz
50 51
 *
51 52
 */
52
public class EqualizationOperation extends AbstractOperation{
53
public class EqualizationOperation extends AbstractColoredOperation{
53 54

  
54
    static public String COLOR_INTERPRETATION_PARAM = "color_interpretation";
55 55
    static public String STATISTICS_PARAM = "statistics";
56
    static public String COPY_UNPROCESSED_BANDS_PARAM = "copy_unprocessed_bands";
57
    static public String OUTPUT_COLOR_INTERPRETATION_PARAM = "output_color_interpretation";
58 56

  
59 57

  
60
    private ColorInterpretation colorInterpretation;
61 58
    private Statistics statistics;
62 59
    private List<Integer> bandsToProcess;
63
    private boolean copyUnprocessedBands;
64 60
    private RowProcessor[] rowProcessors;
65 61
    private HistogramBand[] histogramBands;
66
    private ColorInterpretation outputColorInterpretation;
67 62
    private Integer dataType;
68 63
    private long[][] lahe;
69 64
    private long[][] laheNegative;
......
81 76

  
82 77
    @Override
83 78
    public void preProcess() throws BufferOperationException {
79
        super.preProcess();
84 80
        BufferManager manager = BufferLocator.getBufferManager();
85 81
        RasterLegendManager legendManager = RasterLegendLocator.getRasterLegendManager();
86 82

  
87
        colorInterpretation = (ColorInterpretation) this.parameters.getDynValue(COLOR_INTERPRETATION_PARAM);
88

  
89
        if(this.parameters.hasDynValue(STATISTICS_PARAM)) {
83
        if(this.parameters.getDynClass().getDynField(STATISTICS_PARAM)!=null) {
90 84
            statistics = (Statistics) this.parameters.getDynValue(STATISTICS_PARAM);
91
        } else {
85
        }
86
        if (statistics==null) {
92 87
            statistics = this.buffer.getStatistics(null);
93 88
        };
94 89
        histogramBands = statistics.getHistogram();
95 90

  
96
        if (this.parameters.hasDynValue(COPY_UNPROCESSED_BANDS_PARAM)) {
97
            copyUnprocessedBands = (Boolean) this.parameters.getDynValue(COPY_UNPROCESSED_BANDS_PARAM);
98
        } else {
99
            copyUnprocessedBands = true;
100
        }
101

  
102 91
        int bands = this.buffer.getBandCount();
103 92
        NoData[] noData = this.buffer.getBandNoData();
104 93

  
......
146 135

  
147 136
        rowProcessors = new RowProcessor[bands];
148 137
        dataType = null;
138
        if(getBandsToProcess().isEmpty()){
139
            throw new ProcessingOperationException("There is no RGB band.", null);
140
        }
149 141
        for (Iterator<Integer> iterator = getBandsToProcess().iterator(); iterator.hasNext();) {
150 142
            Integer band = (Integer) iterator.next();
151 143
            int bandType = this.buffer.getBand(band).getDataType();
......
309 301

  
310 302
    @Override
311 303
    public void process() throws ProcessingOperationException {
304
        super.process();
312 305
        for (int band=0; band<this.buffer.getBandCount(); band++){
313 306
            if (getBandsToProcess().contains(band)) {
314 307
                Band bufferBand = this.buffer.getBand(band);
......
337 330

  
338 331
    @Override
339 332
    public void postProcess() throws BufferOperationException {
340
        // TODO Auto-generated method stub
341

  
333
        super.postProcess();
342 334
    }
343 335

  
344 336
    /**

Also available in: Unified diff