Revision 43865
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.spi/src/main/java/org/gvsig/raster/lib/buffer/spi/operations/AbstractSpecifiedBandsOperation.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import java.util.ArrayList; |
26 | 26 |
import java.util.List; |
27 |
import org.gvsig.raster.lib.buffer.api.Buffer; |
|
28 |
import org.gvsig.raster.lib.buffer.api.NoData; |
|
27 | 29 |
|
28 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
|
29 | 30 |
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException; |
31 |
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory; |
|
30 | 32 |
import org.gvsig.raster.lib.buffer.api.operations.SpecifiedBandsOperation; |
31 | 33 |
import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException; |
32 | 34 |
|
... | ... | |
36 | 38 |
*/ |
37 | 39 |
public abstract class AbstractSpecifiedBandsOperation extends AbstractOperation implements SpecifiedBandsOperation { |
38 | 40 |
|
39 |
protected List<Integer> bandsToProcess;
|
|
41 |
private List<Integer> bandsToProcess;
|
|
40 | 42 |
|
41 | 43 |
/** |
42 | 44 |
* |
45 |
* @param factory |
|
43 | 46 |
*/ |
44 |
public AbstractSpecifiedBandsOperation() { |
|
45 |
// TODO Auto-generated constructor stub
|
|
47 |
public AbstractSpecifiedBandsOperation(OperationFactory factory) {
|
|
48 |
super(factory);
|
|
46 | 49 |
} |
47 |
|
|
50 |
|
|
51 |
public List<Integer> getBandsToProcess() { |
|
52 |
return this.bandsToProcess; |
|
53 |
} |
|
54 |
|
|
48 | 55 |
@SuppressWarnings("unchecked") |
49 | 56 |
@Override |
50 | 57 |
public void preProcess() throws BufferOperationException { |
51 | 58 |
super.preProcess(); |
52 |
if(this.parameters.getDynClass().getDynField(BANDS_TO_PROCESS_PARAM)!=null) {
|
|
53 |
bandsToProcess = (List<Integer>)this.parameters.getDynValue(BANDS_TO_PROCESS_PARAM);
|
|
59 |
if(this.getParameters().getDynClass().getDynField(BANDS_TO_PROCESS_PARAM)!=null) {
|
|
60 |
bandsToProcess = (List<Integer>)this.getParameters().getDynValue(BANDS_TO_PROCESS_PARAM);
|
|
54 | 61 |
} |
55 | 62 |
|
56 | 63 |
if(this.bandsToProcess==null) { |
57 |
bandsToProcess = new ArrayList<Integer>(buffer.getBandCount());
|
|
58 |
};
|
|
59 |
if(this.bandsToProcess.size()==0){
|
|
60 |
for (int i=0; i<buffer.getBandCount(); i++){
|
|
64 |
bandsToProcess = new ArrayList<>(this.getInputBuffer().getBandCount());
|
|
65 |
} |
|
66 |
if(this.bandsToProcess.isEmpty()){
|
|
67 |
for (int i=0; i<this.getInputBuffer().getBandCount(); i++){
|
|
61 | 68 |
bandsToProcess.add(i); |
62 | 69 |
} |
63 | 70 |
} |
... | ... | |
82 | 89 |
public void postProcess() throws BufferOperationException { |
83 | 90 |
super.postProcess(); |
84 | 91 |
} |
92 |
|
|
93 |
|
|
94 |
/** |
|
95 |
* This is a utility method that return a copy of the NoData of |
|
96 |
* the processable band of the input buffer. |
|
97 |
* |
|
98 |
* @return List of NoDatas |
|
99 |
*/ |
|
100 |
protected List<NoData> getProcessableBandNoDatas() { |
|
101 |
int bands = this.getInputBuffer().getBandCount(); |
|
102 |
List<NoData> noDatas = new ArrayList<>(); |
|
103 |
for (int band = 0; band < bands; band++) { |
|
104 |
if (this.isProcessableBand(band)) { |
|
105 |
noDatas.add(this.getInputBuffer().getBandNoData()[band]); |
|
106 |
} |
|
107 |
} |
|
108 |
return noDatas; |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* This is a utility method that return a copy of the NoData of |
|
113 |
* the processable band of the input buffer. |
|
114 |
* |
|
115 |
* @return array of NoDatas |
|
116 |
*/ |
|
117 |
protected NoData[] getProcessableBandNoDatasAsArray() { |
|
118 |
List<NoData> l = this.getProcessableBandNoDatas(); |
|
119 |
NoData[] noDatas = l.toArray(new NoData[l.size()]); |
|
120 |
return noDatas; |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* This is a utility method that return a copy of the types of |
|
125 |
* the processable band of the input buffer. |
|
126 |
* |
|
127 |
* @return list of types |
|
128 |
*/ |
|
129 |
protected List<Integer> getProcessableBandTypes() { |
|
130 |
int bands = this.getInputBuffer().getBandCount(); |
|
131 |
List<Integer> types = new ArrayList<>(); |
|
132 |
for (int band = 0; band < bands; band++) { |
|
133 |
if (this.isProcessableBand(band)) { |
|
134 |
types.add(this.getInputBuffer().getBandTypes()[band]); |
|
135 |
} |
|
136 |
} |
|
137 |
return types; |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* This is a utility method that return a copy of the types of |
|
142 |
* the processable band of the input buffer. |
|
143 |
* |
|
144 |
* @return Array of types |
|
145 |
*/ |
|
146 |
protected int[] getProcessableBandTypesAsArray() { |
|
147 |
int[] types = this.getTypesAsArray(this.getProcessableBandTypes()); |
|
148 |
return types; |
|
149 |
} |
|
150 |
|
|
151 |
protected int[] getTypesAsArray(List<Integer> theTypes) { |
|
152 |
int[] types = new int[theTypes.size()]; |
|
153 |
int n = 0; |
|
154 |
for (Integer type : theTypes) { |
|
155 |
types[n++] = type ; |
|
156 |
} |
|
157 |
return types; |
|
158 |
} |
|
159 |
|
|
85 | 160 |
} |
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.spi/src/main/java/org/gvsig/raster/lib/buffer/spi/operations/AbstractOperation.java | ||
---|---|---|
26 | 26 |
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException; |
27 | 27 |
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory; |
28 | 28 |
import org.gvsig.raster.lib.buffer.spi.exceptions.ProcessingOperationException; |
29 |
import org.gvsig.tools.ToolsLocator; |
|
29 | 30 |
import org.gvsig.tools.dynobject.DynObject; |
30 |
import org.gvsig.tools.persistence.PersistentState;
|
|
31 |
import org.gvsig.tools.persistence.exception.PersistenceException;
|
|
31 |
import org.gvsig.tools.task.TaskStatus;
|
|
32 |
import org.gvsig.tools.task.TaskStatusManager;
|
|
32 | 33 |
|
33 | 34 |
|
34 | 35 |
/** |
... | ... | |
39 | 40 |
|
40 | 41 |
static public String COPY_UNPROCESSED_BANDS_PARAM = "copy_unprocessed_bands"; |
41 | 42 |
|
42 |
protected Buffer buffer;
|
|
43 |
protected DynObject parameters;
|
|
44 |
protected Buffer outputBuffer;
|
|
45 |
protected OperationFactory factory;
|
|
46 |
protected boolean copyUnprocessedBands;
|
|
43 |
private Buffer buffer;
|
|
44 |
private DynObject parameters;
|
|
45 |
private Buffer outputBuffer;
|
|
46 |
private final OperationFactory factory;
|
|
47 |
private TaskStatus taskStatus;
|
|
47 | 48 |
|
49 |
private boolean copyUnprocessedBands; |
|
48 | 50 |
|
49 | 51 |
/** |
50 | 52 |
* |
53 |
* @param factory |
|
51 | 54 |
*/ |
52 |
public AbstractOperation() {
|
|
53 |
// Nothing to do
|
|
55 |
protected AbstractOperation(OperationFactory factory) {
|
|
56 |
this.factory = factory;
|
|
54 | 57 |
} |
55 | 58 |
|
59 |
protected boolean mustCopyUnprocessedBands() { |
|
60 |
return copyUnprocessedBands; |
|
61 |
} |
|
62 |
|
|
56 | 63 |
@Override |
57 | 64 |
public void preProcess() throws BufferOperationException { |
58 | 65 |
if (this.parameters.getDynClass().getDynField(COPY_UNPROCESSED_BANDS_PARAM) != null |
... | ... | |
64 | 71 |
} |
65 | 72 |
|
66 | 73 |
@Override |
74 |
public TaskStatus getTaskStatus() { |
|
75 |
if( this.taskStatus==null ) { |
|
76 |
TaskStatusManager taskStatusManager = ToolsLocator.getTaskStatusManager(); |
|
77 |
this.taskStatus = taskStatusManager.createDefaultSimpleTaskStatus( |
|
78 |
this.getFactory().getName()); |
|
79 |
} |
|
80 |
return this.taskStatus; |
|
81 |
} |
|
82 |
|
|
83 |
@Override |
|
67 | 84 |
public void process() throws ProcessingOperationException { |
68 | 85 |
//Nothing to do |
69 | 86 |
} |
... | ... | |
78 | 95 |
* @see org.gvsig.raster.lib.buffer.api.Operation#execute(org.gvsig.raster.lib.buffer.api.Buffer, org.gvsig.tools.dynobject.DynObject) |
79 | 96 |
*/ |
80 | 97 |
@Override |
81 |
public Buffer execute(Buffer buffer, DynObject parameters) throws BufferOperationException { |
|
98 |
public Buffer execute(TaskStatus status, Buffer buffer, DynObject parameters) throws BufferOperationException {
|
|
82 | 99 |
this.buffer = buffer; |
83 | 100 |
this.parameters = parameters; |
101 |
this.taskStatus = status; |
|
84 | 102 |
this.preProcess(); |
85 | 103 |
this.process(); |
86 | 104 |
this.postProcess(); |
... | ... | |
103 | 121 |
return parameters; |
104 | 122 |
} |
105 | 123 |
|
124 |
@Override |
|
125 |
public Object getParameter(String name, Object defaultValue) { |
|
126 |
if(this.parameters.getDynClass().getDynField(name)!=null) { |
|
127 |
return this.getParameters().getDynValue(name); |
|
128 |
} |
|
129 |
return defaultValue; |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public void setParameter(String name, Object value) { |
|
134 |
this.getParameters().setDynValue(name, value); |
|
135 |
} |
|
136 |
|
|
106 | 137 |
/* (non-Javadoc) |
107 | 138 |
* @see org.gvsig.raster.lib.buffer.spi.OperationServices#getInputBuffer() |
108 | 139 |
*/ |
... | ... | |
118 | 149 |
public Buffer getOutputBuffer() { |
119 | 150 |
return outputBuffer; |
120 | 151 |
} |
152 |
|
|
153 |
@Override |
|
154 |
public void setOutputBuffer(Buffer theOutputBuffer) { |
|
155 |
this.outputBuffer = theOutputBuffer; |
|
156 |
} |
|
157 |
|
|
158 |
|
|
121 | 159 |
} |
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.spi/src/main/java/org/gvsig/raster/lib/buffer/spi/operations/OperationServices.java | ||
---|---|---|
26 | 26 |
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException; |
27 | 27 |
import org.gvsig.raster.lib.buffer.api.operations.Operation; |
28 | 28 |
import org.gvsig.tools.dynobject.DynObject; |
29 |
import org.gvsig.tools.task.TaskStatus; |
|
29 | 30 |
|
30 | 31 |
|
31 | 32 |
/** |
... | ... | |
39 | 40 |
*/ |
40 | 41 |
public DynObject getParameters(); |
41 | 42 |
|
43 |
public Object getParameter(String name, Object defaultValue); |
|
44 |
|
|
45 |
public void setParameter(String name, Object value); |
|
42 | 46 |
/** |
43 | 47 |
* @return the input buffer |
44 | 48 |
*/ |
... | ... | |
49 | 53 |
*/ |
50 | 54 |
public Buffer getOutputBuffer(); |
51 | 55 |
|
56 |
public void setOutputBuffer(Buffer theOutputBuffer); |
|
57 |
|
|
52 | 58 |
/** |
53 | 59 |
* Prepare the process |
54 | 60 |
* @throws BufferOperationException |
... | ... | |
67 | 73 |
*/ |
68 | 74 |
void postProcess() throws BufferOperationException; |
69 | 75 |
|
76 |
TaskStatus getTaskStatus(); |
|
70 | 77 |
} |
Also available in: Unified diff