Revision 8682 org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/operations/mode/ModeOperation.java
ModeOperation.java | ||
---|---|---|
23 | 23 |
package org.gvsig.raster.lib.buffer.impl.operations.mode; |
24 | 24 |
|
25 | 25 |
import java.util.ArrayList; |
26 |
import java.util.Collections; |
|
27 |
import java.util.Comparator; |
|
28 | 26 |
import java.util.Iterator; |
29 | 27 |
import java.util.List; |
30 | 28 |
|
... | ... | |
38 | 36 |
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException; |
39 | 37 |
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory; |
40 | 38 |
import org.gvsig.raster.lib.buffer.api.statistics.Statistics; |
41 |
import org.gvsig.raster.lib.buffer.impl.exceptions.ProcessingOperationException;
|
|
42 |
import org.gvsig.raster.lib.buffer.spi.operations.AbstractOperation; |
|
39 |
import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException;
|
|
40 |
import org.gvsig.raster.lib.buffer.spi.operations.AbstractSpecifiedBandsOperation;
|
|
43 | 41 |
import org.gvsig.tools.locator.LocatorException; |
44 |
import org.gvsig.tools.operations.OperationException; |
|
45 | 42 |
|
46 | 43 |
|
47 | 44 |
/** |
48 | 45 |
* @author fdiaz |
49 | 46 |
* |
50 | 47 |
*/ |
51 |
public class ModeOperation extends AbstractOperation{ |
|
48 |
public class ModeOperation extends AbstractSpecifiedBandsOperation{
|
|
52 | 49 |
|
53 | 50 |
// static public String STATISTICS_PARAM = "statistics"; |
54 | 51 |
static public String SIDE_WINDOW_PARAM = "side_window"; |
55 |
static public String BANDS_TO_PROCESS_PARAM = "bands_to_process"; |
|
56 |
static public String COPY_UNPROCESSED_BANDS_PARAM = "copy_unprocessed_bands"; |
|
57 | 52 |
|
58 | 53 |
private Statistics statistics; |
59 | 54 |
private int sideWindow; |
60 |
private List<Integer> bandsToProcess; |
|
61 |
private boolean copyUnprocessedBands; |
|
62 | 55 |
private RowProcessor[] rowProcessors; |
63 | 56 |
private int halfSideWindow; |
64 | 57 |
|
... | ... | |
72 | 65 |
|
73 | 66 |
@Override |
74 | 67 |
public void preProcess() throws BufferOperationException { |
68 |
super.preProcess(); |
|
75 | 69 |
BufferManager manager = BufferLocator.getBufferManager(); |
76 | 70 |
|
77 |
if(this.parameters.hasDynValue(SIDE_WINDOW_PARAM)) {
|
|
71 |
if(this.parameters.getDynClass().getDynField(SIDE_WINDOW_PARAM)!=null) {
|
|
78 | 72 |
sideWindow = (Integer)this.parameters.getDynValue(SIDE_WINDOW_PARAM); |
79 | 73 |
} else { |
80 | 74 |
sideWindow = 3; |
81 | 75 |
}; |
82 | 76 |
halfSideWindow = (int)(sideWindow/2); |
83 | 77 |
|
84 |
if(this.parameters.hasDynValue(BANDS_TO_PROCESS_PARAM)) { |
|
85 |
bandsToProcess = (List<Integer>)this.parameters.getDynValue(BANDS_TO_PROCESS_PARAM); |
|
86 |
} else { |
|
87 |
bandsToProcess = new ArrayList<Integer>(buffer.getBandCount()); |
|
88 |
for (int i=0; i<buffer.getBandCount(); i++){ |
|
89 |
bandsToProcess.add(i); |
|
90 |
} |
|
91 |
}; |
|
92 |
if (this.parameters.hasDynValue(COPY_UNPROCESSED_BANDS_PARAM)) { |
|
93 |
copyUnprocessedBands = (Boolean) this.parameters.getDynValue(COPY_UNPROCESSED_BANDS_PARAM); |
|
94 |
} else { |
|
95 |
copyUnprocessedBands = true; |
|
96 |
} |
|
97 |
|
|
98 | 78 |
int bands = this.buffer.getBandCount(); |
99 | 79 |
NoData[] noData = this.buffer.getBandNoData(); |
100 | 80 |
if (copyUnprocessedBands) { |
... | ... | |
161 | 141 |
|
162 | 142 |
@Override |
163 | 143 |
public void process() throws ProcessingOperationException { |
144 |
super.process(); |
|
164 | 145 |
for (int band=0; band<this.buffer.getBandCount(); band++){ |
165 | 146 |
if (bandsToProcess.contains(band)) { |
166 | 147 |
Band bufferBand = this.buffer.getBand(band); |
... | ... | |
197 | 178 |
|
198 | 179 |
@Override |
199 | 180 |
public void postProcess() throws BufferOperationException { |
200 |
// TODO Auto-generated method stub |
|
201 |
|
|
181 |
super.postProcess(); |
|
202 | 182 |
} |
203 | 183 |
|
204 | 184 |
/** |
Also available in: Unified diff