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/tailtrim/TailTrimOperation.java
TailTrimOperation.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.raster.lib.buffer.impl.operations.tailtrim; |
24 | 24 |
|
25 |
import java.util.ArrayList; |
|
26 |
import java.util.List; |
|
27 |
|
|
28 | 25 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
29 | 26 |
import org.gvsig.raster.lib.buffer.api.Band; |
30 | 27 |
import org.gvsig.raster.lib.buffer.api.BufferLocator; |
... | ... | |
35 | 32 |
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException; |
36 | 33 |
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory; |
37 | 34 |
import org.gvsig.raster.lib.buffer.api.statistics.Statistics; |
38 |
import org.gvsig.raster.lib.buffer.impl.exceptions.ProcessingOperationException;
|
|
35 |
import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException;
|
|
39 | 36 |
import org.gvsig.raster.lib.buffer.spi.operations.AbstractOperation; |
37 |
import org.gvsig.raster.lib.buffer.spi.operations.AbstractSpecifiedBandsOperation; |
|
40 | 38 |
import org.gvsig.tools.locator.LocatorException; |
41 | 39 |
|
42 | 40 |
|
... | ... | |
44 | 42 |
* @author fdiaz |
45 | 43 |
* |
46 | 44 |
*/ |
47 |
public class TailTrimOperation extends AbstractOperation{ |
|
45 |
public class TailTrimOperation extends AbstractSpecifiedBandsOperation{
|
|
48 | 46 |
|
49 | 47 |
static public String STATISTICS_PARAM = "statistics"; |
50 | 48 |
static public String TAIL_TRIM_PERCENT_PARAM = "tail_trim_percent"; |
51 |
static public String BANDS_TO_PROCESS_PARAM = "bands_to_process"; |
|
52 | 49 |
|
53 | 50 |
private Statistics statistics; |
54 | 51 |
private double tailTrimPercent; |
55 |
private List<Integer> bandsToProcess; |
|
56 | 52 |
private RowProcessor[] rowProcessors; |
57 | 53 |
|
58 | 54 |
/** |
... | ... | |
66 | 62 |
@SuppressWarnings("unchecked") |
67 | 63 |
@Override |
68 | 64 |
public void preProcess() throws BufferOperationException { |
65 |
super.preProcess(); |
|
69 | 66 |
BufferManager manager = BufferLocator.getBufferManager(); |
70 | 67 |
|
71 |
if(this.parameters.hasDynValue(STATISTICS_PARAM)) {
|
|
68 |
if(this.parameters.getDynClass().getDynField(STATISTICS_PARAM)!=null) {
|
|
72 | 69 |
statistics = (Statistics) this.parameters.getDynValue(STATISTICS_PARAM); |
73 |
} else { |
|
70 |
} |
|
71 |
if (statistics == null) { |
|
74 | 72 |
statistics = this.buffer.getStatistics(null); |
75 | 73 |
}; |
76 |
if(this.parameters.hasDynValue(TAIL_TRIM_PERCENT_PARAM)) {
|
|
74 |
if(this.parameters.getDynClass().getDynField(TAIL_TRIM_PERCENT_PARAM)!=null) {
|
|
77 | 75 |
tailTrimPercent = (Double)this.parameters.getDynValue(TAIL_TRIM_PERCENT_PARAM); |
78 | 76 |
tailTrimPercent = (tailTrimPercent>100)?100:tailTrimPercent; |
79 | 77 |
tailTrimPercent = (tailTrimPercent<0)?0:tailTrimPercent; |
80 | 78 |
} else { |
81 | 79 |
tailTrimPercent = 0; // FIXME: ?0 o 100? |
82 | 80 |
}; |
83 |
if(this.parameters.hasDynValue(BANDS_TO_PROCESS_PARAM)) { |
|
84 |
bandsToProcess = (List<Integer>)this.parameters.getDynValue(BANDS_TO_PROCESS_PARAM); |
|
85 |
} else { |
|
86 |
bandsToProcess = new ArrayList<Integer>(buffer.getBandCount()); |
|
87 |
for (int i=0; i<buffer.getBandCount(); i++){ |
|
88 |
bandsToProcess.add(i); |
|
89 |
} |
|
90 |
}; |
|
91 | 81 |
|
82 |
//FIXME: Falta la gesti?n del par?metro copyUnprocessedBands, de momento se copian sin tenerlo en cuenta |
|
83 |
|
|
92 | 84 |
int bands = this.buffer.getBandCount(); |
93 | 85 |
rowProcessors = new RowProcessor[bands]; |
94 | 86 |
int [] bandTypes = new int[bands]; |
... | ... | |
181 | 173 |
|
182 | 174 |
@Override |
183 | 175 |
public void process() throws ProcessingOperationException { |
176 |
super.process(); |
|
184 | 177 |
for (int band=0; band<this.buffer.getBandCount(); band++){ |
185 | 178 |
if (bandsToProcess.contains(band)) { |
186 | 179 |
Band bufferBand = this.buffer.getBand(band); |
... | ... | |
209 | 202 |
|
210 | 203 |
@Override |
211 | 204 |
public void postProcess() throws BufferOperationException { |
212 |
// TODO Auto-generated method stub |
|
213 |
|
|
205 |
super.postProcess(); |
|
214 | 206 |
} |
215 | 207 |
|
216 | 208 |
/** |
Also available in: Unified diff