Revision 12180 trunk/libraries/libRaster/src/org/gvsig/raster/grid/filter/RasterFilterList.java
RasterFilterList.java | ||
---|---|---|
57 | 57 |
} |
58 | 58 |
|
59 | 59 |
/** |
60 |
* Controla que los tipos de entrada y salida de los filtros sean los |
|
61 |
* correctos |
|
62 |
*/ |
|
63 |
public void controlTypes() { |
|
64 |
RasterFilterListManager stackManager = new RasterFilterListManager(this); |
|
65 |
stackManager.controlTypes(); |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
60 | 69 |
* A?ade un filtro al final de la lista |
61 | 70 |
* @param filter filtro a?adido |
62 | 71 |
*/ |
... | ... | |
65 | 74 |
replace(filter, filter.getName()); |
66 | 75 |
} else { |
67 | 76 |
list.add(filter); |
77 |
controlTypes(); |
|
68 | 78 |
} |
69 | 79 |
} |
70 | 80 |
|
71 | 81 |
/** |
82 |
* Sustituye un filtro de una posici?n de la pila por otro |
|
83 |
* @param filter |
|
84 |
* @param i |
|
85 |
*/ |
|
86 |
public void replace(RasterFilter filter, String name) { |
|
87 |
boolean changed = false; |
|
88 |
|
|
89 |
for (int i = list.size() - 1; i >= 0; i--) |
|
90 |
if (((RasterFilter) list.get(i)).getName().equals(name)) { |
|
91 |
list.remove(i); |
|
92 |
list.add(i, filter); |
|
93 |
changed = true; |
|
94 |
} |
|
95 |
|
|
96 |
if (changed) |
|
97 |
controlTypes(); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
72 | 101 |
* A?ade un filtro en la lista en la posici?n indicada. |
73 | 102 |
* @param filter filtro a?adido |
74 | 103 |
* @param pos posici?n |
... | ... | |
76 | 105 |
public void add(RasterFilter filter, int pos) { |
77 | 106 |
try { |
78 | 107 |
list.add(pos, filter); |
108 |
controlTypes(); |
|
79 | 109 |
} catch (IndexOutOfBoundsException e) { |
80 | 110 |
add(filter); |
81 | 111 |
} |
... | ... | |
86 | 116 |
* @param name Nombre del filtro a eliminar |
87 | 117 |
*/ |
88 | 118 |
public void remove(String name) { |
89 |
for (int i = list.size() - 1; i >= 0; i--) { |
|
90 |
if (((RasterFilter) list.get(i)).getName().equals(name)) |
|
119 |
boolean changed = false; |
|
120 |
for (int i = list.size() - 1; i >= 0; i--) |
|
121 |
if (((RasterFilter) list.get(i)).getName().equals(name)) { |
|
91 | 122 |
list.remove(i); |
92 |
} |
|
123 |
changed = true; |
|
124 |
} |
|
125 |
if (changed) |
|
126 |
controlTypes(); |
|
93 | 127 |
} |
94 | 128 |
|
95 | 129 |
/** |
... | ... | |
97 | 131 |
* @param type |
98 | 132 |
*/ |
99 | 133 |
public void remove(RasterFilter filter) { |
100 |
for (int i = list.size() - 1; i >= 0; i--) { |
|
101 |
if (((RasterFilter) list.get(i)).equals(filter)) |
|
134 |
boolean changed = false; |
|
135 |
for (int i = list.size() - 1; i >= 0; i--) |
|
136 |
if (((RasterFilter) list.get(i)).equals(filter)) { |
|
102 | 137 |
list.remove(i); |
103 |
} |
|
138 |
changed = true; |
|
139 |
} |
|
140 |
if (changed) |
|
141 |
controlTypes(); |
|
104 | 142 |
} |
105 | 143 |
|
106 | 144 |
/** |
... | ... | |
109 | 147 |
* @param baseFilterClass |
110 | 148 |
*/ |
111 | 149 |
public void remove(Class baseFilterClass) { |
112 |
for (int i = 0; i < lenght(); i++) { |
|
150 |
boolean changed = false; |
|
151 |
for (int i = 0; i < lenght(); i++) |
|
113 | 152 |
if (baseFilterClass.isInstance(((RasterFilter) list.get(i)))) { |
114 | 153 |
list.remove(i); |
115 | 154 |
i--; |
155 |
changed = true; |
|
116 | 156 |
} |
117 |
} |
|
157 |
if (changed) |
|
158 |
controlTypes(); |
|
118 | 159 |
} |
119 | 160 |
|
120 | 161 |
/** |
... | ... | |
142 | 183 |
* @param b Nombre de filtro |
143 | 184 |
* @return |
144 | 185 |
*/ |
186 |
/* |
|
145 | 187 |
private boolean isOnTop(String a, String b) { |
146 | 188 |
int posA = -1; |
147 | 189 |
int posB = -1; |
... | ... | |
162 | 204 |
else |
163 | 205 |
return false; |
164 | 206 |
} |
165 |
|
|
207 |
*/ |
|
166 | 208 |
/** |
167 | 209 |
* Dado un modo de inserci?n se obtiene el tipo de dato del filtro a |
168 | 210 |
* introducir. Se insertionMode es ADD_END quiere decir que se a?adir? al |
... | ... | |
283 | 325 |
* @param filter |
284 | 326 |
* @param i |
285 | 327 |
*/ |
286 |
public void replace(RasterFilter filter, String name) { |
|
287 |
for (int i = list.size() - 1; i >= 0; i--) { |
|
288 |
if (((RasterFilter) list.get(i)).getName().equals(name)) { |
|
289 |
list.remove(i); |
|
290 |
list.add(i, filter); |
|
291 |
} |
|
292 |
} |
|
293 |
} |
|
294 |
|
|
295 |
/** |
|
296 |
* Sustituye un filtro de una posici?n de la pila por otro |
|
297 |
* @param filter |
|
298 |
* @param i |
|
299 |
*/ |
|
300 | 328 |
public void replace(RasterFilter filter, int i) { |
301 | 329 |
list.remove(i); |
302 | 330 |
list.add(i, filter); |
... | ... | |
375 | 403 |
* @param dataType |
376 | 404 |
*/ |
377 | 405 |
private void executeFilterByDataType(int dataType) { |
406 |
// RasterFilterListManager stackManager = new RasterFilterListManager(this); |
|
407 |
// stackManager.controlTypes(); |
|
408 |
/* |
|
409 |
System.out.println("-----------------"); |
|
410 |
for (int i=0; i<this.lenght(); i++) { |
|
411 |
System.out.println(this.get(i).getInRasterDataType()); |
|
412 |
System.out.println(this.get(i).getClass()); |
|
413 |
System.out.println(this.get(i).getOutRasterDataType()); |
|
414 |
} |
|
415 |
System.out.println("+++++++++++++++++"); |
|
416 |
*/ |
|
417 |
|
|
378 | 418 |
for (int i = 0; i < list.size(); i++) { |
379 | 419 |
RasterFilter filter = ((RasterFilter) list.get(i)); |
380 | 420 |
|
421 |
// TODO: Arquitectura. Quitar el ControlTypes y en este momento |
|
422 |
// cerciorarse de si el tipo del filtro es totalmente el correcto o hay |
|
423 |
// que recrearlo. Ejemplo: |
|
424 |
// Si el filtro que tenemos antes de preprocesar es de tipo Byte y la |
|
425 |
// entrada de datos es de tipo float, reconstruir solo este filtro para |
|
426 |
// que sea de tipo float |
|
427 |
|
|
381 | 428 |
filter.addParam("raster", rasterBuf); |
382 | 429 |
filter.execute(); |
383 | 430 |
|
... | ... | |
403 | 450 |
public void show() { |
404 | 451 |
System.out.println("--------------------------------------------"); |
405 | 452 |
|
406 |
for (int i = list.size() - 1; i >= 0; i--) {
|
|
453 |
for (int i = 0; i < list.size() ; i++) {
|
|
407 | 454 |
System.out.println("FILTRO:" + i + " NAME:" + ((RasterFilter) list.get(i)).getName() + " FIL:" + ((RasterFilter) list.get(i)).toString()); |
408 | 455 |
} |
409 | 456 |
} |
Also available in: Unified diff