Revision 43864

View differences:

branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/operations/linearstretchenhancement/LinearStretchEnhancementOperation.java
60 60
     *
61 61
     */
62 62
    public LinearStretchEnhancementOperation(OperationFactory factory) {
63
        this.factory = factory;
63
        super(factory);
64 64
    }
65 65

  
66 66
    @Override
......
68 68
        super.preProcess();
69 69
        BufferManager manager = BufferLocator.getBufferManager();
70 70

  
71
        if(this.parameters.getDynClass().getDynField(STATISTICS_PARAM)!=null) {
72
            statistics = (Statistics) this.parameters.getDynValue(STATISTICS_PARAM);
73
        }
71
        statistics = (Statistics) this.getParameter(STATISTICS_PARAM, null);
74 72
        if (statistics == null) {
75
            statistics = this.buffer.getStatistics(null);
76
        };
77
        if(this.parameters.getDynClass().getDynField(REMOVE_ENDS_PARAM)!=null) {
78
            removeEnds = (Boolean)this.parameters.getDynValue(REMOVE_ENDS_PARAM);
79
        } else {
80
            removeEnds = false;
81
        };
82
        if(this.parameters.getDynClass().getDynField(TAIL_TRIM_PARAM)!=null) {
83
            tailTrim = (Boolean)this.parameters.getDynValue(TAIL_TRIM_PARAM);
84
        } else {
85
            tailTrim = false;
86
        };
87
        if(this.parameters.getDynClass().getDynField(TAIL_TRIM_PERCENT_PARAM)!=null) {
88
            tailTrimPercent = (Double)this.parameters.getDynValue(TAIL_TRIM_PERCENT_PARAM);
89
            tailTrimPercent = (tailTrimPercent>100)?100:tailTrimPercent;
90
            tailTrimPercent = (tailTrimPercent<0)?0:tailTrimPercent;
91
        } else {
92
            tailTrimPercent = 0; // FIXME: ?0 o 100?
93
        };
73
            statistics = this.getInputBuffer().getStatistics(null);
74
        }
75
        removeEnds = (boolean) this.getParameter(REMOVE_ENDS_PARAM, false);
76
        tailTrim = (boolean) this.getParameter(TAIL_TRIM_PARAM, false);
77
        tailTrimPercent = (double) this.getParameter(TAIL_TRIM_PERCENT_PARAM, 0);
78
        tailTrimPercent = (tailTrimPercent>100)?100:tailTrimPercent;
79
        tailTrimPercent = (tailTrimPercent<0)?0:tailTrimPercent;
94 80

  
95
        int bands = this.buffer.getBandCount();
81
        int bands = this.getInputBuffer().getBandCount();
96 82
        rowProcessors = new RowProcessor[bands];
97 83
        int [] bandTypes = new int[bands];
98 84
        //FIXME: Falta la gesti?n del par?metro copyUnprocessedBands, de momento se copian sin tenerlo en cuenta
99 85
        for (int i = 0; i < bandTypes.length; i++) {
100
            if(bandsToProcess.contains(i)){
86
            if(this.getBandsToProcess().contains(i)){
101 87
                bandTypes[i] = BufferManager.TYPE_BYTE;
102 88
            } else {
103
                bandTypes[i] = this.buffer.getBandTypes()[i];
89
                bandTypes[i] = this.getInputBuffer().getBandTypes()[i];
104 90
            }
105 91
        }
106
        NoData[] noData = this.buffer.getBandNoData();
92
        NoData[] noData = this.getInputBuffer().getBandNoData();
107 93
        NoData[] resultNoData = new NoData[noData.length];
108 94
        for (int band = 0; band < noData.length; band++) {
109
            int bandType = this.buffer.getBand(band).getDataType();
95
            int bandType = this.getInputBuffer().getBand(band).getDataType();
110 96
            switch (bandType) {
111 97
            case BufferManager.TYPE_BYTE:
112 98
                rowProcessors[band] = new ByteRowProcessor(band);
......
139 125
        }
140 126

  
141 127
        try {
142
            this.outputBuffer = manager.createBuffer(
143
                this.buffer.getRows(),
144
                this.buffer.getColumns(),
128
            this.setOutputBuffer( manager.createBuffer(
129
                this.getInputBuffer().getRows(),
130
                this.getInputBuffer().getColumns(),
145 131
                bandTypes,
146 132
                resultNoData,
147
                this.buffer.getProjection(),
148
                this.buffer.getEnvelope());
133
                this.getInputBuffer().getProjection(),
134
                this.getInputBuffer().getEnvelope()));
149 135
        } catch (LocatorException | BufferException | CreateEnvelopeException e) {
150 136
            throw new ProcessingOperationException(e);
151 137
        }
......
154 140
    @Override
155 141
    public void process() throws ProcessingOperationException {
156 142
        super.process();
157
        for (int band=0; band<this.buffer.getBandCount(); band++){
158
            if (bandsToProcess.contains(band)) {
159
                Band bufferBand = this.buffer.getBand(band);
160
                Band outputBufferBand = this.outputBuffer.getBand(band);
143
        for (int band=0; band<this.getInputBuffer().getBandCount(); band++){
144
            if (this.getBandsToProcess().contains(band)) {
145
                Band bufferBand = this.getInputBuffer().getBand(band);
146
                Band outputBufferBand = this.getOutputBuffer().getBand(band);
161 147

  
162
                for (int row = 0; row < this.buffer.getRows(); row++) {
148
                for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
163 149
                    Object rowBuffer = bufferBand.createRowBuffer();
164 150
                    bufferBand.fetchRow(row, rowBuffer);
165 151

  
......
172 158
                }
173 159
            } else {
174 160
                try {
175
                    this.outputBuffer.getBand(band).copyFrom(this.buffer.getBand(band));
161
                    this.getOutputBuffer().getBand(band).copyFrom(this.getInputBuffer().getBand(band));
176 162
                } catch (BandException e) {
177 163
                    throw new ProcessingOperationException(e);
178 164
                }
......
185 171
        super.postProcess();
186 172
    }
187 173

  
188

  
189 174
    interface RowProcessor {
190 175
        void processRow(Object inputRow, Object outputRow);
191 176
        byte processValue(Object value);
......
201 186

  
202 187
        public AbstractRowProcessor(int band) {
203 188
            this.band = band;
204
            noData = buffer.getBand(band).getNoData();
189
            noData = getInputBuffer().getBand(band).getNoData();
205 190
            if(noData.isDefined()) {
206 191
                minResult = (byte)1;
207 192
            }
......
244 229
                return (byte)0;
245 230
            }
246 231

  
247
            int iValue = 0xFF & ((Byte) value).byteValue();
232
            int iValue = 0xFF & ((Byte) value);
248 233
            Double dValue = new Double(iValue);
249 234

  
250 235
            double result;
......
284 269
                return (byte)0;
285 270
            }
286 271

  
287
            int iValue = ((Short) value).shortValue();
272
            int iValue = ((Short) value);
288 273
            Double dValue = ((Number) iValue).doubleValue();
289 274

  
290 275
            double result;
......
324 309
            }
325 310

  
326 311
            //FIXME ???:
327
            int iValue = 0xFFFF & ((Short) value).shortValue();
312
            int iValue = 0xFFFF & ((Short) value);
328 313
            Double dValue = ((Number) iValue).doubleValue();
329 314

  
330 315
            double result;
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/operations/median/MedianOperation.java
61 61
     *
62 62
     */
63 63
    public MedianOperation(OperationFactory factory) {
64
        this.factory = factory;
64
        super(factory);
65 65
    }
66 66

  
67 67
    @SuppressWarnings("unchecked")
......
70 70
        super.preProcess();
71 71
        BufferManager manager = BufferLocator.getBufferManager();
72 72

  
73
        if(this.parameters.getDynClass().getDynField(SIDE_WINDOW_PARAM)!=null) {
74
            sideWindow = (Integer)this.parameters.getDynValue(SIDE_WINDOW_PARAM);
75
        } else {
76
            sideWindow = 3;
77
        };
73
        sideWindow = (int) this.getParameter(SIDE_WINDOW_PARAM, 3);
78 74
        halfSideWindow = (int)(sideWindow/2);
79 75

  
80
        int bands = this.buffer.getBandCount();
81
        NoData[] noData = this.buffer.getBandNoData();
82
        if (copyUnprocessedBands) {
76
        int bands = this.getInputBuffer().getBandCount();
77
        NoData[] noData = this.getInputBuffer().getBandNoData();
78
        if (mustCopyUnprocessedBands()) {
83 79
            try {
84
                this.outputBuffer =
85
                    manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), this.buffer.getBandTypes(),
86
                        this.buffer.getBandNoData(), this.buffer.getProjection(), this.buffer.getEnvelope());
80
                this.setOutputBuffer(
81
                    manager.createBuffer(
82
                            this.getInputBuffer().getRows(), 
83
                            this.getInputBuffer().getColumns(), 
84
                            this.getInputBuffer().getBandTypes(),
85
                            this.getInputBuffer().getBandNoData(), 
86
                            this.getInputBuffer().getProjection(), 
87
                            this.getInputBuffer().getEnvelope()));
87 88
            } catch (LocatorException | BufferException | CreateEnvelopeException e) {
88 89
                throw new ProcessingOperationException(e);
89 90
            }
90 91
        } else {
91
            List<NoData> noDatas = new ArrayList<NoData>();
92
            List<Integer> types = new ArrayList<Integer>();
93
            for (int band = 0; band < bands; band++) {
94
                if (isProcessableBand(band)) {
95
                    noDatas.add(this.buffer.getBandNoData()[band]);
96
                    types.add(this.buffer.getBandTypes()[band]);
97
                }
98
            }
99
            int[] typesInt = new int[types.size()];
100
            for (Iterator<Integer> iterator = types.iterator(); iterator.hasNext();) {
101
                int i = 0;
102
                Integer type = (Integer) iterator.next();
103
                typesInt[i] = type.intValue();
104
            }
105 92
            try {
106
                this.outputBuffer =
107
                    manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), typesInt,
108
                        noDatas.toArray(new NoData[0]), this.buffer.getProjection(), this.buffer.getEnvelope());
93
                this.setOutputBuffer(
94
                    manager.createBuffer(
95
                            this.getInputBuffer().getRows(), 
96
                            this.getInputBuffer().getColumns(), 
97
                            this.getProcessableBandTypesAsArray(),
98
                            this.getProcessableBandNoDatasAsArray(), 
99
                            this.getInputBuffer().getProjection(), 
100
                            this.getInputBuffer().getEnvelope()));
109 101
            } catch (LocatorException | BufferException | CreateEnvelopeException e) {
110 102
                throw new ProcessingOperationException(e);
111 103
            }
......
114 106
        rowProcessors = new RowProcessor[bands];
115 107
        for (int band = 0; band < noData.length; band++) {
116 108
            if (isProcessableBand(band)) {
117
                int bandType = this.buffer.getBand(band).getDataType();
109
                int bandType = this.getInputBuffer().getBand(band).getDataType();
118 110
                switch (bandType) {
119 111
                case BufferManager.TYPE_BYTE:
120 112
                    rowProcessors[band] = new ByteRowProcessor(band);
......
144 136
    @Override
145 137
    public void process() throws ProcessingOperationException {
146 138
        super.process();
147
        for (int band=0; band<this.buffer.getBandCount(); band++){
148
            if (bandsToProcess.contains(band)) {
149
                Band bufferBand = this.buffer.getBand(band);
150
                Band outputBufferBand = this.outputBuffer.getBand(band);
139
        for (int band=0; band<this.getInputBuffer().getBandCount(); band++){
140
            if (getBandsToProcess().contains(band)) {
141
                Band bufferBand = this.getInputBuffer().getBand(band);
142
                Band outputBufferBand = this.getOutputBuffer().getBand(band);
151 143

  
152 144

  
153
                for (int row = 0; row < this.buffer.getRows(); row++) {
145
                for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
154 146
                    Object rowBuffer = bufferBand.createRowBuffer();
155 147
                    bufferBand.fetchRow(row, rowBuffer);
156
                    List<Object> bundle = new ArrayList<Object>();
157
                    for(int r=Math.max(row-halfSideWindow,0); r<=Math.min(row+halfSideWindow,this.buffer.getRows()-1);r++){
148
                    List<Object> bundle = new ArrayList<>();
149
                    for(int r=Math.max(row-halfSideWindow,0); r<=Math.min(row+halfSideWindow,this.getInputBuffer().getRows()-1);r++){
158 150
                        Object bundleRow = bufferBand.createRowBuffer();
159 151
                        bufferBand.fetchRow(row, bundleRow);
160 152
                        bundle.add(bundleRow);
......
168 160
                    outputBufferBand.putRow(row, outputRowBuffer);
169 161
                }
170 162
            } else {
171
                if(copyUnprocessedBands){
163
                if(mustCopyUnprocessedBands()){
172 164
                    try {
173
                        this.outputBuffer.getBand(band).copyFrom(this.buffer.getBand(band));
165
                        this.getOutputBuffer().getBand(band).copyFrom(this.getInputBuffer().getBand(band));
174 166
                    } catch (BandException e) {
175 167
                        throw new ProcessingOperationException(e);
176 168
                    }
......
195 187

  
196 188
        public AbstractRowProcessor(int band) {
197 189
            this.band = band;
198
            noData = buffer.getBand(band).getNoData();
190
            noData = getInputBuffer().getBand(band).getNoData();
199 191
        }
200 192
    }
201 193

  
......
211 203
            byte[] inputByteRow = (byte[])inputRow;
212 204
            byte[] outputByteRow = (byte[])outputRow;
213 205
            for (int i = 0; i < inputByteRow.length; i++) {
214
                List<Number> kernel = new ArrayList<Number>();
206
                List<Number> kernel = new ArrayList<>();
215 207
                for (Iterator<Object> iterator = bundleRow.iterator(); iterator.hasNext();) {
216 208
                    byte[] row = (byte[]) iterator.next();
217 209
                    for(int c=Math.max(i-halfSideWindow,0); c<=Math.min(i+halfSideWindow,inputByteRow.length-1);c++){
218
                        Integer value = 0xFF & ((Byte) row[c]).byteValue();
210
                        Integer value = 0xFF & ((Byte) row[c]);
219 211
                        if(noData.isDefined() && noData.getValue().equals(value)){
220 212
                            continue;
221 213
                        } else {
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/operations/convolution/ConvolutionOperation.java
83 83
     *
84 84
     */
85 85
    public ConvolutionOperation(OperationFactory factory) {
86
        this.factory = factory;
86
        super(factory);
87 87
    }
88 88

  
89 89
    @Override
......
91 91
        super.preProcess();
92 92
        BufferManager manager = BufferLocator.getBufferManager();
93 93

  
94
        if(this.parameters.getDynClass().getDynField(SIDE_WINDOW_PARAM)!=null) {
95
            sideWindow = (Integer)this.parameters.getDynValue(SIDE_WINDOW_PARAM);
96
        } else {
97
            sideWindow = 3;
98
        };
94
        sideWindow = (int) this.getParameter(SIDE_WINDOW_PARAM, 3);
99 95
        halfSideWindow = (int)(sideWindow/2);
96
        sharpness = (double) this.getParameter(SHARPNESS_PARAM, 0);
97
        operator = (String) this.getParameter(OPERATOR_PARAM, AVERAGE_OPERATOR_STRING);
100 98

  
101

  
102
        if(this.parameters.getDynClass().getDynField(SHARPNESS_PARAM)!=null) {
103
            sharpness = (Double)this.parameters.getDynValue(SHARPNESS_PARAM);
104
        } else {
105
            sharpness = 0;
106
        };
107

  
108
        if(this.parameters.getDynClass().getDynField(OPERATOR_PARAM)!=null) {
109
            operator = (String)this.parameters.getDynValue(OPERATOR_PARAM);
110
        } else {
111
            operator = AVERAGE_OPERATOR_STRING;
112
        };
113

  
114 99
        switch (operator) {
115 100
        case AVERAGE_OPERATOR_STRING:
116 101
            switch (sideWindow) {
......
172 157
            }
173 158
            break;
174 159
        case CUSTOM_OPERATOR_STRING:
175
            if(this.parameters.getDynClass().getDynField(CUSTOM_KERNEL_PARAM)!=null) {
176
                kernelOperator = (Kernel)this.parameters.getDynValue(CUSTOM_KERNEL_PARAM);
177
            } else {
160
            kernelOperator = (Kernel) this.getParameter(CUSTOM_KERNEL_PARAM, null);
161
            if(kernelOperator==null) {
178 162
                throw new IllegalArgumentException("A Kernel is needed for the selected operator.");
179 163
            };
180
            if(kernelOperator==null || kernelOperator.getSide()!=sideWindow){
164
            if( kernelOperator.getSide()!=sideWindow){
181 165
                throw new IllegalArgumentException("Kernel side incorrect.");
182 166
            };
183 167
            break;
184 168
        }
185 169

  
186
        int bands = this.buffer.getBandCount();
187
        NoData[] noData = this.buffer.getBandNoData();
188
        if (copyUnprocessedBands) {
170
        int bands = this.getInputBuffer().getBandCount();
171
        NoData[] noData = this.getInputBuffer().getBandNoData();
172
        if (mustCopyUnprocessedBands()) {
189 173
            try {
190
                this.outputBuffer =
191
                    manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), this.buffer.getBandTypes(),
192
                        this.buffer.getBandNoData(), this.buffer.getProjection(), this.buffer.getEnvelope());
174
                this.setOutputBuffer(
175
                    manager.createBuffer(
176
                            this.getInputBuffer().getRows(), 
177
                            this.getInputBuffer().getColumns(), 
178
                            this.getInputBuffer().getBandTypes(),
179
                            this.getInputBuffer().getBandNoData(), 
180
                            this.getInputBuffer().getProjection(), 
181
                            this.getInputBuffer().getEnvelope()));
193 182
            } catch (LocatorException | BufferException | CreateEnvelopeException e) {
194 183
                throw new ProcessingOperationException(e);
195 184
            }
196 185
        } else {
197
            List<NoData> noDatas = new ArrayList<NoData>();
198
            List<Integer> types = new ArrayList<Integer>();
199
            for (int band = 0; band < bands; band++) {
200
                if (isProcessableBand(band)) {
201
                    if(this.buffer.getBandNoData()[band].isDefined()){
202
                        noDatas.add(manager.createNoData(0, 0));
203
                    } else {
204
                        noDatas.add(null);
205
                    }
206
                    types.add(BufferManager.TYPE_BYTE);
207
                }
208
            }
209
            int[] typesInt = new int[types.size()];
210
            for (Iterator<Integer> iterator = types.iterator(); iterator.hasNext();) {
211
                int i = 0;
212
                Integer type = (Integer) iterator.next();
213
                typesInt[i] = type.intValue();
214
            }
215 186
            try {
216
                this.outputBuffer =
217
                    manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), typesInt,
218
                        noDatas.toArray(new NoData[0]), this.buffer.getProjection(), this.buffer.getEnvelope());
187
                this.setOutputBuffer(
188
                    manager.createBuffer(
189
                            this.getInputBuffer().getRows(), 
190
                            this.getInputBuffer().getColumns(), 
191
                            this.getProcessableBandTypesAsArray(),
192
                            this.getProcessableBandNoDatasAsArray(), 
193
                            this.getInputBuffer().getProjection(), 
194
                            this.getInputBuffer().getEnvelope()));
219 195
            } catch (LocatorException | BufferException | CreateEnvelopeException e) {
220 196
                throw new ProcessingOperationException(e);
221 197
            }
......
224 200
        rowProcessors = new RowProcessor[bands];
225 201
        for (int band = 0; band < noData.length; band++) {
226 202
            if (isProcessableBand(band)) {
227
                int bandType = this.buffer.getBand(band).getDataType();
203
                int bandType = this.getInputBuffer().getBand(band).getDataType();
228 204
                switch (bandType) {
229 205
                case BufferManager.TYPE_BYTE:
230 206
                    rowProcessors[band] = new ByteRowProcessor(band);
......
254 230
    @Override
255 231
    public void process() throws ProcessingOperationException {
256 232
        super.process();
257
        for (int band=0; band<this.buffer.getBandCount(); band++){
258
            if (bandsToProcess.contains(band)) {
259
                Band bufferBand = this.buffer.getBand(band);
260
                Band outputBufferBand = this.outputBuffer.getBand(band);
233
        for (int band=0; band<this.getInputBuffer().getBandCount(); band++){
234
            if (getBandsToProcess().contains(band)) {
235
                Band bufferBand = this.getInputBuffer().getBand(band);
236
                Band outputBufferBand = this.getOutputBuffer().getBand(band);
261 237

  
262
                for (int row = 0; row < this.buffer.getRows(); row++) {
238
                for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
263 239
                    Object rowBuffer = bufferBand.createRowBuffer();
264 240
                    bufferBand.fetchRow(row, rowBuffer);
265
                    List<Object> bundle = new ArrayList<Object>();
241
                    List<Object> bundle = new ArrayList<>();
266 242
                    //FIXME: Solo se procesan aquellas filas en las que se pueden crear kernels, el resto ?qu? hacer? (ver abajo)
267
                    if ((row - halfSideWindow >= 0) && (row + halfSideWindow < this.buffer.getRows())) {
243
                    if ((row - halfSideWindow >= 0) && (row + halfSideWindow < this.getInputBuffer().getRows())) {
268 244
                        for (int r = Math.max(row - halfSideWindow, 0); r <= Math.min(row + halfSideWindow,
269
                            this.buffer.getRows()-1); r++) {
245
                            this.getInputBuffer().getRows()-1); r++) {
270 246
                            Object bundleRow = bufferBand.createRowBuffer();
271 247
                            bufferBand.fetchRow(r, bundleRow);
272 248
                            bundle.add(bundleRow);
......
280 256
                        outputBufferBand.putRow(row, outputRowBuffer);
281 257
                    } else {
282 258
                        // FIXME: Si son de tipo BYTE, las copio, si no, no hacemos nada
283
                        if(this.buffer.getBandTypes()[band]==BufferManager.TYPE_BYTE){
259
                        if(this.getInputBuffer().getBandTypes()[band]==BufferManager.TYPE_BYTE){
284 260
                            outputBufferBand.putRow(row, rowBuffer);
285 261
                        }
286 262
                    }
287 263
                }
288 264
            } else {
289
                if(copyUnprocessedBands){
265
                if(mustCopyUnprocessedBands()){
290 266
                    try {
291
                        this.outputBuffer.getBand(band).copyFrom(this.buffer.getBand(band));
267
                        this.getOutputBuffer().getBand(band).copyFrom(this.getInputBuffer().getBand(band));
292 268
                    } catch (BandException e) {
293 269
                        throw new ProcessingOperationException(e);
294 270
                    }
......
313 289

  
314 290
        public AbstractRowProcessor(int band) {
315 291
            this.band = band;
316
            noData = buffer.getBand(band).getNoData();
292
            noData = getInputBuffer().getBand(band).getNoData();
317 293
        }
318 294

  
319 295
        @Override
......
350 326
                        byte[] row = (byte[]) iterator.next();
351 327
                        for (int column = Math.max(i - halfSideWindow, 0); column <= Math.min(i + halfSideWindow,
352 328
                            inputByteRow.length-1); column++) {
353
                            byte value = ((Byte) row[column]).byteValue();
329
                            byte value = ((Byte) row[column]);
354 330
                            if (noData.isDefined() && noData.getValue().equals(value)) {
355 331
                                //FIXME: Si es noData, deber?a no influir en el resultado
356 332
                                // ?Que valor poner en el kernel?
......
395 371
                        short[] row = (short[]) iterator.next();
396 372
                        for (int column = Math.max(i - halfSideWindow, 0); column <= Math.min(i + halfSideWindow,
397 373
                            inputShortRow.length-1); column++) {
398
                            double value = ((Short) row[c]).shortValue();
374
                            double value = ((Short) row[c]);
399 375
                            if (noData.isDefined() && noData.getValue().equals(value)) {
400 376
                                //FIXME: Si es noData, deber?a no influir en el resultado
401 377
                                // ?Que valor poner en el kernel?
......
437 413
                        short[] row = (short[]) iterator.next();
438 414
                        for (int column = Math.max(i - halfSideWindow, 0); column <= Math.min(i + halfSideWindow,
439 415
                            inputShortRow.length-1); column++) {
440
                            double value = 0xFFFF & ((Short) row[c]).shortValue();
416
                            double value = 0xFFFF & ((Short) row[c]);
441 417
                            if (noData.isDefined() && noData.getValue().equals(value)) {
442 418
                                // FIXME: Si es noData, deber?a no influir en el
443 419
                                // resultado
......
479 455
                        int[] row = (int[]) iterator.next();
480 456
                        for (int column = Math.max(i - halfSideWindow, 0); column <= Math.min(i + halfSideWindow,
481 457
                            inputIntRow.length-1); column++) {
482
                            double value = ((Integer) row[c]).intValue();
458
                            double value = ((Integer) row[c]);
483 459
                            if (noData.isDefined() && noData.getValue().equals(value)) {
484 460
                                // FIXME: Si es noData, deber?a no influir en el
485 461
                                // resultado
......
520 496
                        float[] row = (float[]) iterator.next();
521 497
                        for (int column = Math.max(i - halfSideWindow, 0); column <= Math.min(i + halfSideWindow,
522 498
                            inputFloatRow.length-1); column++) {
523
                            Float value = ((Float) row[c]).floatValue();
499
                            Float value = ((Float) row[c]);
524 500
                            if (noData.isDefined() && noData.getValue().equals(value)) {
525 501
                                // FIXME: Si es noData, deber?a no influir en el
526 502
                                // resultado
......
561 537
                        double[] row = (double[]) iterator.next();
562 538
                        for (int column = Math.max(i - halfSideWindow, 0); column <= Math.min(i + halfSideWindow,
563 539
                            inputDoubleRow.length-1); column++) {
564
                            Double value = ((Double) row[c]).doubleValue();
540
                            Double value = ((Double) row[c]);
565 541
                            if (noData.isDefined() && noData.getValue().equals(value)) {
566 542
                                // FIXME: Si es noData, deber?a no influir en el resultado
567 543
                                // ?Que valor poner en el kernel?
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/operations/DefaultOperationList.java
57 57
import org.gvsig.tools.persistence.PersistenceManager;
58 58
import org.gvsig.tools.persistence.PersistentState;
59 59
import org.gvsig.tools.persistence.exception.PersistenceException;
60
import org.gvsig.tools.task.TaskStatus;
60 61

  
61 62

  
62 63
/**
......
87 88
     *
88 89
     */
89 90
    public DefaultOperationList() {
90
        this.operations = new ArrayList<OperationListEntry>();
91
        this.operations = new ArrayList<>();
91 92
    }
92 93

  
93 94
    @Override
......
248 249
    }
249 250

  
250 251
    @Override
251
    public Buffer execute(Buffer buffer) throws BufferOperationException {
252
    public Buffer execute(TaskStatus status, Buffer buffer) throws BufferOperationException {
252 253
        Buffer tmpBuffer1 = buffer;
253 254
        DisposeUtils.bind(tmpBuffer1);
254
        Buffer tmpBuffer2 = null;
255
        Buffer tmpBuffer2;
255 256
        int i=0;
256
        for (Iterator<OperationListEntry> iterator = operations.iterator(); iterator.hasNext();) {
257
            OperationListEntry operationListEntry = (OperationListEntry) iterator.next();
257
        for (OperationListEntry operationListEntry : operations) {
258 258
            Operation operation = operationListEntry.getOperation();
259 259
            DynObject parameters = operationListEntry.getParameters();
260 260
            OperationFactory factory = operation.getFactory();
......
264 264
                }
265 265
                DynClass paramsDefinition = parameters.getDynClass();
266 266
                DynField[] fields = paramsDefinition.getDynFields();
267
                for (int j = 0; j < fields.length; j++) {
268
                    DynField_v2 field = (DynField_v2) fields[j];
267
                for (DynField field1 : fields) {
268
                    DynField_v2 field = (DynField_v2) field1;
269 269
                    String name = operationListEntry.getLookpupParameterName(field.getName());
270 270
                    if (StringUtils.isEmpty(name)) {
271 271
                        name = (String) field.getTags().get("lookupParameter");
......
274 274
                        parameters.setDynValue(field.getName(), getParameterValue(name, i));
275 275
                    }
276 276
                }
277
                tmpBuffer2 = operation.execute(tmpBuffer1, parameters);
277
                tmpBuffer2 = operation.execute(status, tmpBuffer1, parameters);
278 278
                DisposeUtils.dispose(tmpBuffer1);
279 279
                tmpBuffer1 = tmpBuffer2;
280 280
            }
......
362 362

  
363 363
    @Override
364 364
    public void loadFromState(PersistentState state) throws PersistenceException {
365
        this.operations = new ArrayList<OperationListEntry>();
365
        this.operations = new ArrayList<>();
366 366

  
367 367
        Iterator it = state.getIterator(OPERATIONS_PERSISTENCE_FIELD);
368 368
        while(it.hasNext()) {
......
383 383
    }
384 384

  
385 385
    public List<String> getAvailableParameterNames() {
386
        Set<String> result = new HashSet<String>();
387
        for (Iterator<OperationListEntry> iterator = operations.iterator(); iterator.hasNext();) {
388
            OperationListEntry operationListEntry = (OperationListEntry) iterator.next();
386
        Set<String> result = new HashSet<>();
387
        for (OperationListEntry operationListEntry : operations) {
389 388
            DynObject parameters = operationListEntry.getParameters();
390 389
            DynField[] dynFields = parameters.getDynClass().getDynFields();
391 390
            for (int i = 0; i < dynFields.length; i++) {
......
394 393
        }
395 394
        if (this.defaultParameters != null) {
396 395
            DynField[] dynFields = this.defaultParameters.getDynClass().getDynFields();
397
            for (int i = 0; i < dynFields.length; i++) {
398
                result.add(dynFields[i].getName());
396
            for (DynField dynField : dynFields) {
397
                result.add(dynField.getName());
399 398
            }
400 399
        }
401
        return new ArrayList<String>(result);
400
        return new ArrayList<>(result);
402 401
    }
403 402

  
404 403
    @Override
......
409 408
    @Override
410 409
    public void validateLookupParameters() throws InvalidLookupParametersException {
411 410
        List<Problem> problems = new ArrayList<>();
412
        InvalidLookupParametersException exception = new InvalidLookupParametersException(problems);
411
//        InvalidLookupParametersException exception = new InvalidLookupParametersException(problems);
413 412

  
414 413
        ListIterator<OperationListEntry> iterator = operations.listIterator();
415 414

  
......
422 421
            if (operationListEntry.isActive()) {
423 422
                DynClass paramsDefinition = parameters.getDynClass();
424 423
                DynField[] fields = paramsDefinition.getDynFields();
425
                for (int j = 0; j < fields.length; j++) {
426
                    DynField_v2 field = (DynField_v2) fields[j];
424
                for (DynField field1 : fields) {
425
                    DynField_v2 field = (DynField_v2) field1;
427 426
                    String name = operationListEntry.getLookpupParameterName(field.getName());
428 427
                    if( !StringUtils.isEmpty(name) ) {
429 428
                        name = (String) field.getTags().get("lookupParameter");
430 429
                    }
431 430
                    if( !StringUtils.isEmpty(name) ) {
432 431
                        if( getParameterValue(name, i) == null){
433
                            Problem problem = exception.new Problem(factory.getName(), field.getName(), name);
432
                            Problem problem = new Problem(factory.getName(), field.getName(), name);
434 433
                            problems.add(problem);
435 434
                        }
436 435
                    }
......
441 440
        if(!problems.isEmpty()){
442 441
            throw new InvalidLookupParametersException(problems);
443 442
        }
444
        return;
445 443
    }
446 444

  
447 445
    private ArrayList<OperationListEntry> cloneOperations() {
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/operations/edgedetection/firstderivative/FirstDerivativeOperation.java
89 89
     *
90 90
     */
91 91
    public FirstDerivativeOperation(OperationFactory factory) {
92
        this.factory = factory;
92
        super(factory);
93 93
    }
94 94

  
95 95
    @Override
......
97 97
        super.preProcess();
98 98
        BufferManager manager = BufferLocator.getBufferManager();
99 99

  
100
        if(this.parameters.getDynClass().getDynField(OPERATOR_PARAM)!=null) {
101
            operator = (String)this.parameters.getDynValue(OPERATOR_PARAM);
102
        } else {
103
            operator = SOBEL_OPERATOR_STRING;
104
        };
105

  
100
        operator = (String) this.getParameter(OPERATOR_PARAM, SOBEL_OPERATOR_STRING);
101
        
106 102
        switch (operator) {
107 103
        case SOBEL_OPERATOR_STRING:
108 104
            operatorH = manager.createKernel(sobelH);
......
122 118
            break;
123 119
        }
124 120

  
125
        if(this.parameters.getDynClass().getDynField(COMPARE_PARAM)!=null) {
126
            compare = (Boolean)this.parameters.getDynValue(COMPARE_PARAM);
127
        } else {
128
            compare = false;
129
        };
130
        if(this.parameters.getDynClass().getDynField(UMBRAL_PARAM)!=null) {
131
            umbral = (Integer)this.parameters.getDynValue(UMBRAL_PARAM);
132
        } else {
133
            umbral = 0;
134
        };
121
        compare = (boolean) this.getParameter(COMPARE_PARAM, false);
122
        umbral = (int) this.getParameter(UMBRAL_PARAM, 0);
135 123

  
136
        int bands = this.buffer.getBandCount();
137
        NoData[] noData = this.buffer.getBandNoData();
138
        if (copyUnprocessedBands) {
124
        int bands = this.getInputBuffer().getBandCount();
125
        NoData[] noData = this.getInputBuffer().getBandNoData();
126
        if (mustCopyUnprocessedBands()) {
139 127
            try {
140
                this.outputBuffer =
141
                    manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), this.buffer.getBandTypes(),
142
                        this.buffer.getBandNoData(), this.buffer.getProjection(), this.buffer.getEnvelope());
128
                this.setOutputBuffer(
129
                    manager.createBuffer(
130
                            this.getInputBuffer().getRows(), 
131
                            this.getInputBuffer().getColumns(), 
132
                            this.getInputBuffer().getBandTypes(),
133
                            this.getInputBuffer().getBandNoData(), 
134
                            this.getInputBuffer().getProjection(), 
135
                            this.getInputBuffer().getEnvelope()));
143 136
            } catch (LocatorException | BufferException | CreateEnvelopeException e) {
144 137
                throw new ProcessingOperationException(e);
145 138
            }
146 139
        } else {
147
            List<NoData> noDatas = new ArrayList<NoData>();
148
            List<Integer> types = new ArrayList<Integer>();
149
            for (int band = 0; band < bands; band++) {
150
                if (isProcessableBand(band)) {
151
                    if(this.buffer.getBandNoData()[band].isDefined()){
152
                        noDatas.add(manager.createNoData(0, 0));
153
                    } else {
154
                        noDatas.add(null);
155
                    }
156
                    types.add(BufferManager.TYPE_BYTE);
157
                }
158
            }
159
            int[] typesInt = new int[types.size()];
160
            for (Iterator<Integer> iterator = types.iterator(); iterator.hasNext();) {
161
                int i = 0;
162
                Integer type = (Integer) iterator.next();
163
                typesInt[i] = type.intValue();
164
            }
165 140
            try {
166
                this.outputBuffer =
167
                    manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), typesInt,
168
                        noDatas.toArray(new NoData[0]), this.buffer.getProjection(), this.buffer.getEnvelope());
141
                this.setOutputBuffer(
142
                    manager.createBuffer(
143
                            this.getInputBuffer().getRows(), 
144
                            this.getInputBuffer().getColumns(), 
145
                            this.getProcessableBandTypesAsArray(),
146
                            this.getProcessableBandNoDatasAsArray(), 
147
                            this.getInputBuffer().getProjection(), 
148
                            this.getInputBuffer().getEnvelope()));
169 149
            } catch (LocatorException | BufferException | CreateEnvelopeException e) {
170 150
                throw new ProcessingOperationException(e);
171 151
            }
......
174 154
        rowProcessors = new RowProcessor[bands];
175 155
        for (int band = 0; band < noData.length; band++) {
176 156
            if (isProcessableBand(band)) {
177
                int bandType = this.buffer.getBand(band).getDataType();
157
                int bandType = this.getInputBuffer().getBand(band).getDataType();
178 158
                switch (bandType) {
179 159
                case BufferManager.TYPE_BYTE:
180 160
                    rowProcessors[band] = new ByteRowProcessor(band);
......
204 184
    @Override
205 185
    public void process() throws ProcessingOperationException {
206 186
        super.process();
207
        for (int band=0; band<this.buffer.getBandCount(); band++){
208
            if (bandsToProcess.contains(band)) {
209
                Band bufferBand = this.buffer.getBand(band);
210
                Band outputBufferBand = this.outputBuffer.getBand(band);
187
        for (int band=0; band<this.getInputBuffer().getBandCount(); band++){
188
            if (getBandsToProcess().contains(band)) {
189
                Band bufferBand = this.getInputBuffer().getBand(band);
190
                Band outputBufferBand = this.getOutputBuffer().getBand(band);
211 191

  
212
                for (int row = 0; row < this.buffer.getRows(); row++) {
192
                for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
213 193
                    Object rowBuffer = bufferBand.createRowBuffer();
214 194
                    bufferBand.fetchRow(row, rowBuffer);
215
                    List<Object> bundle = new ArrayList<Object>();
195
                    List<Object> bundle = new ArrayList<>();
216 196
                    //FIXME: Solo se procesan aquellas filas en las que se pueden crear kernels, el resto ?qu? hacer? (ver abajo)
217
                    if ((row - HALF_SIDE_WINDOW >= 0) && (row + HALF_SIDE_WINDOW < this.buffer.getRows())) {
197
                    if ((row - HALF_SIDE_WINDOW >= 0) && (row + HALF_SIDE_WINDOW < this.getInputBuffer().getRows())) {
218 198
                        for (int r = Math.max(row - HALF_SIDE_WINDOW, 0); r <= Math.min(row + HALF_SIDE_WINDOW,
219
                            this.buffer.getRows()-1); r++) {
199
                            this.getInputBuffer().getRows()-1); r++) {
220 200
                            Object bundleRow = bufferBand.createRowBuffer();
221 201
                            bufferBand.fetchRow(r, bundleRow);
222 202
                            bundle.add(bundleRow);
......
230 210
                        outputBufferBand.putRow(row, outputRowBuffer);
231 211
                    } else {
232 212
                        // FIXME: Si son de tipo BYTE, las copio, si no, no hacemos nada
233
                        if(this.buffer.getBandTypes()[band]==BufferManager.TYPE_BYTE){
213
                        if(this.getInputBuffer().getBandTypes()[band]==BufferManager.TYPE_BYTE){
234 214
                            outputBufferBand.putRow(row, rowBuffer);
235 215
                        }
236 216
                    }
237 217
                }
238 218
            } else {
239
                if(copyUnprocessedBands){
219
                if(mustCopyUnprocessedBands()){
240 220
                    try {
241
                        this.outputBuffer.getBand(band).copyFrom(this.buffer.getBand(band));
221
                        this.getOutputBuffer().getBand(band).copyFrom(this.getInputBuffer().getBand(band));
242 222
                    } catch (BandException e) {
243 223
                        throw new ProcessingOperationException(e);
244 224
                    }
......
263 243

  
264 244
        public AbstractRowProcessor(int band) {
265 245
            this.band = band;
266
            noData = buffer.getBand(band).getNoData();
246
            noData = getInputBuffer().getBand(band).getNoData();
267 247
        }
268 248

  
269 249
        @Override
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/operations/mode/ModeOperation.java
26 26
import java.util.Iterator;
27 27
import java.util.List;
28 28

  
29
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
30 29
import org.gvsig.raster.lib.buffer.api.Band;
31 30
import org.gvsig.raster.lib.buffer.api.BufferLocator;
32 31
import org.gvsig.raster.lib.buffer.api.BufferManager;
33 32
import org.gvsig.raster.lib.buffer.api.NoData;
34 33
import org.gvsig.raster.lib.buffer.api.exceptions.BandException;
35
import org.gvsig.raster.lib.buffer.api.exceptions.BufferException;
36 34
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException;
37 35
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory;
38 36
import org.gvsig.raster.lib.buffer.api.statistics.Statistics;
39 37
import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException;
40 38
import org.gvsig.raster.lib.buffer.spi.operations.AbstractSpecifiedBandsOperation;
41
import org.gvsig.tools.locator.LocatorException;
42 39

  
43 40

  
44 41
/**
......
60 57
     *
61 58
     */
62 59
    public ModeOperation(OperationFactory factory) {
63
        this.factory = factory;
60
        super(factory);
64 61
    }
65

  
62
    
66 63
    @Override
67 64
    public void preProcess() throws BufferOperationException {
68 65
        super.preProcess();
69 66
        BufferManager manager = BufferLocator.getBufferManager();
70 67

  
71
        if(this.parameters.getDynClass().getDynField(SIDE_WINDOW_PARAM)!=null) {
72
            sideWindow = (Integer)this.parameters.getDynValue(SIDE_WINDOW_PARAM);
73
        } else {
74
            sideWindow = 3;
75
        };
68
        sideWindow = (int) this.getParameter(SIDE_WINDOW_PARAM, 3);
76 69
        halfSideWindow = (int)(sideWindow/2);
77 70

  
78
        int bands = this.buffer.getBandCount();
79
        NoData[] noData = this.buffer.getBandNoData();
80
        if (copyUnprocessedBands) {
71
        if (mustCopyUnprocessedBands()) {
81 72
            try {
82
                this.outputBuffer =
83
                    manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), this.buffer.getBandTypes(),
84
                        this.buffer.getBandNoData(), this.buffer.getProjection(), this.buffer.getEnvelope());
85
            } catch (LocatorException | BufferException | CreateEnvelopeException e) {
73
                this.setOutputBuffer(
74
                    manager.createBuffer(
75
                            this.getInputBuffer().getRows(), 
76
                            this.getInputBuffer().getColumns(), 
77
                            this.getInputBuffer().getBandTypes(),
78
                            this.getInputBuffer().getBandNoData(), 
79
                            this.getInputBuffer().getProjection(), 
80
                            this.getInputBuffer().getEnvelope()));
81
            } catch (Exception e) {
86 82
                throw new ProcessingOperationException(e);
87 83
            }
88
            } else {
89
            List<NoData> noDatas = new ArrayList<NoData>();
90
            List<Integer> types = new ArrayList<Integer>();
91
            for (int band = 0; band < bands; band++) {
92
                if (isProcessableBand(band)) {
93
                    noDatas.add(this.buffer.getBandNoData()[band]);
94
                    types.add(this.buffer.getBandTypes()[band]);
95
            }
96
        }
97
            int[] typesInt = new int[types.size()];
98
            for (Iterator<Integer> iterator = types.iterator(); iterator.hasNext();) {
99
                int i = 0;
100
                Integer type = (Integer) iterator.next();
101
                typesInt[i] = type.intValue();
102
            }
84
        } else {
103 85
            try {
104
                this.outputBuffer =
105
                    manager.createBuffer(this.buffer.getRows(), this.buffer.getColumns(), typesInt,
106
                        noDatas.toArray(new NoData[0]), this.buffer.getProjection(), this.buffer.getEnvelope());
107
            } catch (LocatorException | BufferException | CreateEnvelopeException e) {
86
                this.setOutputBuffer(
87
                    manager.createBuffer(
88
                            this.getInputBuffer().getRows(), 
89
                            this.getInputBuffer().getColumns(), 
90
                            this.getProcessableBandTypesAsArray(),
91
                            this.getProcessableBandNoDatasAsArray(), 
92
                            this.getInputBuffer().getProjection(),
93
                            this.getInputBuffer().getEnvelope()));
94
            } catch (Exception e) {
108 95
                throw new ProcessingOperationException(e);
109 96
            }
110 97
        }
111 98

  
99
        int bands = this.getInputBuffer().getBandCount();
112 100
        rowProcessors = new RowProcessor[bands];
113
        for (int band = 0; band < noData.length; band++) {
101
        for (int band = 0; band < bands; band++) {
114 102
            if (isProcessableBand(band)) {
115
            int bandType = this.buffer.getBand(band).getDataType();
103
            int bandType = this.getInputBuffer().getBand(band).getDataType();
116 104
            switch (bandType) {
117 105
            case BufferManager.TYPE_BYTE:
118 106
                rowProcessors[band] = new ByteRowProcessor(band);
......
142 130
    @Override
143 131
    public void process() throws ProcessingOperationException {
144 132
        super.process();
145
        for (int band=0; band<this.buffer.getBandCount(); band++){
146
            if (bandsToProcess.contains(band)) {
147
                Band bufferBand = this.buffer.getBand(band);
148
                Band outputBufferBand = this.outputBuffer.getBand(band);
133
        for (int band=0; band<this.getInputBuffer().getBandCount(); band++){
134
            if (getBandsToProcess().contains(band)) {
135
                Band bufferBand = this.getInputBuffer().getBand(band);
136
                Band outputBufferBand = this.getOutputBuffer().getBand(band);
149 137

  
150
                for (int row = 0; row < this.buffer.getRows(); row++) {
138
                for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
151 139
                    Object rowBuffer = bufferBand.createRowBuffer();
152 140
                    bufferBand.fetchRow(row, rowBuffer);
153
                    List<Object> bundle = new ArrayList<Object>();
154
                    for(int r=Math.max(row-halfSideWindow,0); r<=Math.min(row+halfSideWindow,this.buffer.getRows()-1);r++){
141
                    List<Object> bundle = new ArrayList<>();
142
                    int maxr = Math.min(row+halfSideWindow,this.getInputBuffer().getRows()-1);
143
                    for(int r=Math.max(row-halfSideWindow,0); r<=maxr;r++){
155 144
                        Object bundleRow = bufferBand.createRowBuffer();
156 145
                        bufferBand.fetchRow(row, bundleRow);
157 146
                        bundle.add(bundleRow);
......
165 154
                    outputBufferBand.putRow(row, outputRowBuffer);
166 155
                }
167 156
            } else {
168
                if(copyUnprocessedBands){
157
                if(mustCopyUnprocessedBands()){
169 158
                try {
170
                    this.outputBuffer.getBand(band).copyFrom(this.buffer.getBand(band));
159
                    this.getOutputBuffer().getBand(band).copyFrom(this.getInputBuffer().getBand(band));
171 160
                } catch (BandException e) {
172 161
                    throw new ProcessingOperationException(e);
173 162
                }
......
192 181

  
193 182
        public AbstractRowProcessor(int band) {
194 183
            this.band = band;
195
            noData = buffer.getBand(band).getNoData();
184
            noData = getInputBuffer().getBand(band).getNoData();
196 185
            }
197 186
            }
198 187

  
......
208 197
            byte[] inputByteRow = (byte[])inputRow;
209 198
            byte[] outputByteRow = (byte[])outputRow;
210 199
            for (int i = 0; i < inputByteRow.length; i++) {
211
                List<Number> kernel = new ArrayList<Number>();
200
                List<Number> kernel = new ArrayList<>();
212 201
                for (Iterator<Object> iterator = bundleRow.iterator(); iterator.hasNext();) {
213 202
                    byte[] row = (byte[]) iterator.next();
214 203
                    for(int c=Math.max(i-halfSideWindow,0); c<=Math.min(i+halfSideWindow,inputByteRow.length-1);c++){
215
                        Integer value = 0xFF & ((Byte) row[c]).byteValue();
204
                        Integer value = 0xFF & ((Byte) row[c]);
216 205
                        if(noData.isDefined() && noData.getValue().equals(value)){
217 206
                            continue;
218 207
                        } else {
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/operations/tailtrim/TailTrimOperation.java
33 33
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory;
34 34
import org.gvsig.raster.lib.buffer.api.statistics.Statistics;
35 35
import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException;
36
import org.gvsig.raster.lib.buffer.spi.operations.AbstractOperation;
37 36
import org.gvsig.raster.lib.buffer.spi.operations.AbstractSpecifiedBandsOperation;
38 37
import org.gvsig.tools.locator.LocatorException;
39 38

  
......
56 55
     *
57 56
     */
58 57
    public TailTrimOperation(OperationFactory factory) {
59
        this.factory = factory;
58
        super(factory);
60 59
    }
61 60

  
62 61
    @SuppressWarnings("unchecked")
......
65 64
        super.preProcess();
66 65
        BufferManager manager = BufferLocator.getBufferManager();
67 66

  
68
        if(this.parameters.getDynClass().getDynField(STATISTICS_PARAM)!=null) {
69
            statistics = (Statistics) this.parameters.getDynValue(STATISTICS_PARAM);
70
        }
67
        statistics = (Statistics) this.getParameter(STATISTICS_PARAM, null);
71 68
        if (statistics == null) {
72
            statistics = this.buffer.getStatistics(null);
69
            statistics = this.getInputBuffer().getStatistics(null);
73 70
        };
74
        if(this.parameters.getDynClass().getDynField(TAIL_TRIM_PERCENT_PARAM)!=null) {
75
            tailTrimPercent = (Double)this.parameters.getDynValue(TAIL_TRIM_PERCENT_PARAM);
76
            tailTrimPercent = (tailTrimPercent>100)?100:tailTrimPercent;
77
            tailTrimPercent = (tailTrimPercent<0)?0:tailTrimPercent;
78
        } else {
79
            tailTrimPercent = 0; // FIXME: ?0 o 100?
80
        };
71
        tailTrimPercent = (double) this.getParameter(TAIL_TRIM_PERCENT_PARAM, 0);
72
        tailTrimPercent = (tailTrimPercent>100)?100:tailTrimPercent;
73
        tailTrimPercent = (tailTrimPercent<0)?0:tailTrimPercent;
81 74

  
82 75
        //FIXME: Falta la gesti?n del par?metro copyUnprocessedBands, de momento se copian sin tenerlo en cuenta
83 76

  
84
        int bands = this.buffer.getBandCount();
77
        int bands = this.getInputBuffer().getBandCount();
85 78
        rowProcessors = new RowProcessor[bands];
86 79
        int [] bandTypes = new int[bands];
87 80
        for (int i = 0; i < bandTypes.length; i++) {
88
            bandTypes[i] = this.buffer.getBandTypes()[i];
81
            bandTypes[i] = this.getInputBuffer().getBandTypes()[i];
89 82
        }
90
        NoData[] noData = this.buffer.getBandNoData();
83
        NoData[] noData = this.getInputBuffer().getBandNoData();
91 84
        NoData[] resultNoData = new NoData[noData.length];
92 85
        for (int band = 0; band < noData.length; band++) {
93
            int bandType = this.buffer.getBand(band).getDataType();
86
            int bandType = this.getInputBuffer().getBand(band).getDataType();
94 87
            switch (bandType) {
95 88
            case BufferManager.TYPE_BYTE:
96 89
                rowProcessors[band] = new ByteRowProcessor(band);
......
159 152
        }
160 153

  
161 154
        try {
162
            this.outputBuffer = manager.createBuffer(
163
                this.buffer.getRows(),
164
                this.buffer.getColumns(),
155
            this.setOutputBuffer(manager.createBuffer(
156
                this.getInputBuffer().getRows(),
157
                this.getInputBuffer().getColumns(),
165 158
                bandTypes,
166 159
                resultNoData,
167
                this.buffer.getProjection(),
168
                this.buffer.getEnvelope());
160
                this.getInputBuffer().getProjection(),
161
                this.getInputBuffer().getEnvelope()));
169 162
        } catch (LocatorException | BufferException | CreateEnvelopeException e) {
170 163
            throw new BufferOperationException(e);
171 164
        }
......
174 167
    @Override
175 168
    public void process() throws ProcessingOperationException {
176 169
        super.process();
177
        for (int band=0; band<this.buffer.getBandCount(); band++){
178
            if (bandsToProcess.contains(band)) {
179
                Band bufferBand = this.buffer.getBand(band);
180
                Band outputBufferBand = this.outputBuffer.getBand(band);
170
        for (int band=0; band<this.getInputBuffer().getBandCount(); band++){
171
            if (getBandsToProcess().contains(band)) {
172
                Band bufferBand = this.getInputBuffer().getBand(band);
173
                Band outputBufferBand = this.getOutputBuffer().getBand(band);
181 174

  
182
                for (int row = 0; row < this.buffer.getRows(); row++) {
175
                for (int row = 0; row < this.getInputBuffer().getRows(); row++) {
183 176
                    Object rowBuffer = bufferBand.createRowBuffer();
184 177
                    bufferBand.fetchRow(row, rowBuffer);
185 178

  
......
192 185
                }
193 186
            } else {
194 187
                try {
195
                    this.outputBuffer.getBand(band).copyFrom(this.buffer.getBand(band));
188
                    this.getOutputBuffer().getBand(band).copyFrom(this.getInputBuffer().getBand(band));
196 189
                } catch (BandException e) {
197 190
                    throw new ProcessingOperationException(e);
198 191
                }
......
219 212

  
220 213
        public AbstractRowProcessor(int band) {
221 214
            this.band = band;
222
            noData = buffer.getBand(band).getNoData();
215
            noData = getInputBuffer().getBand(band).getNoData();
223 216
//            outputNoData = outputBuffer.getBand(band).getNoData();
224 217

  
225 218
            double[][] tailTrim = statistics.getTailTrimValue(tailTrimPercent);
......
248 241
        @Override
249 242
        public Number processValue(Number value) {
250 243
            if(noData.isDefined() && noData.getValue().equals(value)){
251
                return outputBuffer.getBand(band).getNoData().getValue();
244
                return getOutputBuffer().getBand(band).getNoData().getValue();
252 245
            }
253 246

  
254 247
            int iValue = 0xFF & ((Byte) value).byteValue();
255 248

  
256 249
            if(iValue < minValue || iValue > maxValue){
257
                return outputBuffer.getBand(band).getNoData().getValue();
250
                return getOutputBuffer().getBand(band).getNoData().getValue();
258 251
            } else {
259 252
                return value;
260 253
            }
......
280 273
        @Override
281 274
        public Number processValue(Number value) {
282 275
            if(noData.isDefined() && noData.getValue().equals(value)){
283
                return outputBuffer.getBand(band).getNoData().getValue();
276
                return getOutputBuffer().getBand(band).getNoData().getValue();
284 277
            }
285 278

  
286 279
            int iValue = ((Short) value).shortValue();
287 280

  
288 281
            if(iValue < minValue || iValue > maxValue){
289
                return outputBuffer.getBand(band).getNoData().getValue();
282
                return getOutputBuffer().getBand(band).getNoData().getValue();
290 283
            } else {
291 284
                return value;
292 285
            }
......
312 305
        @Override
313 306
        public Number processValue(Number value) {
314 307
            if(noData.isDefined() && noData.getValue().equals(value)){
315
                return outputBuffer.getBand(band).getNoData().getValue();
308
                return getOutputBuffer().getBand(band).getNoData().getValue();
316 309
            }
317 310

  
318 311
            int iValue = 0xFFFF & ((Short) value).shortValue();
319 312

  
320 313
            if(iValue < minValue || iValue > maxValue){
321
                return outputBuffer.getBand(band).getNoData().getValue();
314
                return getOutputBuffer().getBand(band).getNoData().getValue();
322 315
            } else {
323 316
                return value;
324 317
            }
......
344 337
        @Override
345 338
        public Number processValue(Number value) {
346 339
            if(noData.isDefined() && noData.getValue().equals(value)){
347
                return outputBuffer.getBand(band).getNoData().getValue();
340
                return getOutputBuffer().getBand(band).getNoData().getValue();
348 341
            }
349 342
            int iValue = value.intValue();
350 343

  
351 344
            if(iValue < minValue || iValue > maxValue){
352
                return outputBuffer.getBand(band).getNoData().getValue();
345
                return getOutputBuffer().getBand(band).getNoData().getValue();
353 346
            } else {
354 347
                return value;
355 348
            }
......
374 367
        @Override
375 368
        public Number processValue(Number value) {
376 369
            if(noData.isDefined() && noData.getValue().equals(value)){
377
                return outputBuffer.getBand(band).getNoData().getValue();
370
                return getOutputBuffer().getBand(band).getNoData().getValue();
378 371
            }
379 372
            float fValue = value.floatValue();
380 373

  
381 374
            if(fValue < minValue || fValue > maxValue){
382
                return outputBuffer.getBand(band).getNoData().getValue();
375
                return getOutputBuffer().getBand(band).getNoData().getValue();
383 376
            } else {
384 377
                return value;
385 378
            }
......
405 398
        @Override
406 399
        public Number processValue(Number value) {
407 400
            if(noData.isDefined() && noData.getValue().equals(value)){
408
                return outputBuffer.getBand(band).getNoData().getValue();
401
                return getOutputBuffer().getBand(band).getNoData().getValue();
409 402
            }
410 403
            double fValue = value.doubleValue();
411 404

  
412 405
            if(fValue < minValue || fValue > maxValue){
413
                return outputBuffer.getBand(band).getNoData().getValue();
406
                return getOutputBuffer().getBand(band).getNoData().getValue();
414 407
            } else {
415 408
                return value;
416 409
            }

Also available in: Unified diff