gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / grid / filter / enhancement / EnhancementStretchListManager.java @ 1426
History | View | Annotate | Download (28.8 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.impl.grid.filter.enhancement; |
23 |
|
24 |
import java.util.ArrayList; |
25 |
import java.util.List; |
26 |
|
27 |
import org.gvsig.fmap.dal.coverage.RasterLibrary; |
28 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
29 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
30 |
import org.gvsig.fmap.dal.coverage.exception.FilterTypeException; |
31 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
32 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
33 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilter; |
34 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
35 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager; |
36 |
import org.gvsig.fmap.dal.coverage.store.props.Statistics; |
37 |
import org.gvsig.raster.impl.datastruct.DefaultStretch; |
38 |
import org.gvsig.raster.impl.grid.filter.RasterFilterListManagerImpl; |
39 |
import org.gvsig.raster.impl.grid.filter.statistics.StatisticsListManager; |
40 |
import org.gvsig.raster.impl.store.ParamImpl; |
41 |
import org.gvsig.tools.ToolsLocator; |
42 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
43 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
44 |
/**
|
45 |
* Gestor de la pila de filtros para el filtro de realce por intervalos.
|
46 |
*
|
47 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
48 |
*/
|
49 |
public class EnhancementStretchListManager implements RasterFilterListManager { |
50 |
protected RasterFilterList filterList = null; |
51 |
private RasterFilterListManagerImpl filterListManager = null; |
52 |
private Statistics stats = null; |
53 |
|
54 |
/**
|
55 |
* Constructor
|
56 |
* @param filterListManager
|
57 |
*/
|
58 |
public EnhancementStretchListManager(RasterFilterList filterList) {
|
59 |
this.filterList = filterList;
|
60 |
stats = (Statistics)filterList.getEnvParam("IStatistics");
|
61 |
} |
62 |
|
63 |
/**
|
64 |
* Constructor
|
65 |
* @param filterListManager
|
66 |
*/
|
67 |
public EnhancementStretchListManager(RasterFilterListManagerImpl filterListManager) {
|
68 |
this.filterListManager = filterListManager;
|
69 |
this.filterList = filterListManager.getFilterList();
|
70 |
stats = (Statistics)filterList.getEnvParam("IStatistics");
|
71 |
} |
72 |
|
73 |
public Class<?> getFilterClassByID(String id) { |
74 |
if(id.compareTo("enhanced_stretch") == 0) |
75 |
return LinearStretchEnhancementFilter.class;
|
76 |
return null; |
77 |
} |
78 |
|
79 |
/**
|
80 |
* Asigna el objeto con las estadisticas.
|
81 |
* @param stats
|
82 |
*/
|
83 |
public void setStatistics(Statistics stats) { |
84 |
this.stats = stats;
|
85 |
} |
86 |
|
87 |
/**
|
88 |
* Registra EnhancementStretchListManager en los puntos de extension de RasterFilter
|
89 |
*/
|
90 |
public static void register() { |
91 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
92 |
ExtensionPoint point = extensionPoints.get("RasterFilter");
|
93 |
point.append("EnhancementStretch", "", EnhancementStretchListManager.class); |
94 |
} |
95 |
|
96 |
/**
|
97 |
* A?ade un filtro de realce.
|
98 |
* La forma de inserci?n del filtro es fija ya que la inserci?n de un realce lleva implicita
|
99 |
* la inserci?n de un filtro de recorte de colas (tailtrim), aunque no en todos los casos.
|
100 |
* Si ya existe un filtro de realce en la lista se obtiene la posici?n de este.
|
101 |
* Si es necesario un recorte de colas entonces se comprueba si existe un uno reemplazandose
|
102 |
* por el nuevo y sino se insertar? uno. Al final reemplazamos el realce que existia.
|
103 |
*
|
104 |
* Si por el contrario no existen realce ni trim se a?aden ambos al final de la lista.
|
105 |
* @param stats Objeto de estadisticas asociado
|
106 |
* @param tailTrim porcentaje de recorte de colas. Ser? un valor entre 0 y 1.
|
107 |
* @param insertionMode Modo de inserci?n
|
108 |
* @param renderBands bandas RGB mostradas en la visualizaci?n.
|
109 |
* @throws FilterTypeException
|
110 |
*/
|
111 |
public void addEnhancedStretchFilter(DefaultLinearStretchParams leParams, Statistics stats, int[] renderBands, boolean removeEnds) throws FilterTypeException { |
112 |
try {
|
113 |
if (!leParams.hasTailTrim()) { // En este caso siempre es necesario el m?ximo y |
114 |
// m?nimo
|
115 |
if (!stats.isCalculated())
|
116 |
try {
|
117 |
stats.calculate(RasterLibrary.statisticsScale); |
118 |
} catch (FileNotOpenException e) {
|
119 |
// No podemos aplicar el filtro
|
120 |
return;
|
121 |
} catch (RasterDriverException e) {
|
122 |
// No podemos aplicar el filtro
|
123 |
return;
|
124 |
} |
125 |
} else {
|
126 |
StatisticsListManager slm = null;
|
127 |
if(filterListManager != null) |
128 |
slm = new StatisticsListManager(filterListManager, stats);
|
129 |
else
|
130 |
slm = new StatisticsListManager(filterList);
|
131 |
slm.addTailFilter(leParams.getTailTrimList(), 0D, removeEnds, stats);
|
132 |
} |
133 |
|
134 |
RasterFilter filter = createEnhancedFilter(leParams, stats, renderBands, removeEnds); |
135 |
if (filter != null) |
136 |
filterList.add(filter); |
137 |
} catch (ProcessInterruptedException e) {
|
138 |
//Si se ha interrumpido no a?adimos el filtro
|
139 |
} |
140 |
} |
141 |
|
142 |
/*
|
143 |
* (non-Javadoc)
|
144 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#addFilter(org.gvsig.fmap.dal.coverage.datastruct.Params)
|
145 |
*/
|
146 |
public void addFilter(Params params) throws FilterTypeException { |
147 |
int[] renderBands = (int[])params.getParamById("renderBands").getDefaultValue(); |
148 |
Statistics stats = (Statistics)params.getParamById("stats").getDefaultValue();
|
149 |
boolean removeEnds = ((Boolean)params.getParamById("remove").getDefaultValue()).booleanValue(); |
150 |
|
151 |
DefaultLinearStretchParams p = null;
|
152 |
|
153 |
try {
|
154 |
if( params.getParamById("tailtrim") != null && |
155 |
params.getParamById("tailtrim").getDefaultValue() != null && |
156 |
params.getParamById("rgb").getDefaultValue() != null) { |
157 |
double tailtrim = ((Double)params.getParamById("tailtrim").getDefaultValue()).doubleValue(); |
158 |
boolean rgb = ((Boolean)params.getParamById("rgb").getDefaultValue()).booleanValue(); |
159 |
p = DefaultLinearStretchParams.createStandardParam(renderBands, tailtrim, stats, rgb); |
160 |
} else {
|
161 |
//Si stretch vale null se usan los par?metros por defecto de LinearStretchParams
|
162 |
if(params.getParamById("stretchs").getDefaultValue() == null) { |
163 |
boolean rgb = false; |
164 |
if(params.getParamById("rgb").getDefaultValue() != null) |
165 |
rgb = ((Boolean)params.getParamById("rgb").getDefaultValue()).booleanValue(); |
166 |
p = DefaultLinearStretchParams.createStandardParam(renderBands, 0.0, stats, rgb);
|
167 |
} |
168 |
} |
169 |
} catch (FileNotOpenException e) {
|
170 |
throw new FilterTypeException("", e); |
171 |
} catch (RasterDriverException e) {
|
172 |
throw new FilterTypeException("", e); |
173 |
} |
174 |
addEnhancedStretchFilter(p, stats, renderBands, removeEnds); |
175 |
} |
176 |
|
177 |
/**
|
178 |
* Crea un filtro de realce por tramos de forma est?tica
|
179 |
* @param leParams Par?metros del filtro
|
180 |
* @param stats
|
181 |
* @param renderBands
|
182 |
* @return
|
183 |
*/
|
184 |
public static RasterFilter createEnhancedFilter(DefaultLinearStretchParams leParams, Statistics stats, int[] renderBands, boolean removeEnds) { |
185 |
RasterFilter filter = new LinearStretchEnhancementFloatFilter();
|
186 |
if (filter != null) { |
187 |
filter.addParam("stats", stats);
|
188 |
filter.addParam("remove", new Boolean(false)); |
189 |
filter.addParam("renderBands", renderBands);
|
190 |
filter.addParam("stretchs", leParams);
|
191 |
filter.addParam("remove", new Boolean(removeEnds)); |
192 |
} |
193 |
|
194 |
return filter;
|
195 |
} |
196 |
|
197 |
/**
|
198 |
* Convierte un array de dobles a una cadena
|
199 |
* @param values
|
200 |
* @return
|
201 |
*/
|
202 |
private String convertArrayToString(double[] values) { |
203 |
StringBuffer buffer = new StringBuffer(); |
204 |
for (int i = 0; i < values.length; i++) { |
205 |
buffer.append(values[i]); |
206 |
if (i < (values.length - 1)) |
207 |
buffer.append(",");
|
208 |
} |
209 |
return buffer.toString();
|
210 |
} |
211 |
|
212 |
/**
|
213 |
* Convierte una array de enteros a una cadena
|
214 |
* @param values
|
215 |
* @return
|
216 |
*/
|
217 |
private String convertArrayToString(int[] values) { |
218 |
StringBuffer buffer = new StringBuffer(); |
219 |
for (int i = 0; i < values.length; i++) { |
220 |
buffer.append(values[i]); |
221 |
if (i < (values.length - 1)) |
222 |
buffer.append(",");
|
223 |
} |
224 |
return buffer.toString();
|
225 |
} |
226 |
|
227 |
/**
|
228 |
* Convierte una cadena a un array de enteros
|
229 |
* @param from
|
230 |
* @return
|
231 |
*/
|
232 |
private int[] StringToIntegerArray(String from) { |
233 |
String[] valueList = from.split(","); |
234 |
int[] values = new int[valueList.length]; |
235 |
for (int i = 0; i < values.length; i++) |
236 |
try {
|
237 |
values[i] = Integer.parseInt(valueList[i]);
|
238 |
} catch (NumberFormatException e) { |
239 |
} |
240 |
return values;
|
241 |
} |
242 |
|
243 |
/**
|
244 |
* Convierte una cadena a un array de dobles
|
245 |
* @param from
|
246 |
* @return
|
247 |
*/
|
248 |
private double[] StringToDoubleArray(String from) { |
249 |
String[] valueList = from.split(","); |
250 |
double[] values = new double[valueList.length]; |
251 |
for (int i = 0; i < values.length; i++) |
252 |
try {
|
253 |
values[i] = Double.parseDouble(valueList[i]);
|
254 |
} catch (NumberFormatException e) { |
255 |
} |
256 |
return values;
|
257 |
} |
258 |
|
259 |
/**
|
260 |
* Guarda en el array de valores, todos los valores del objeto Strech para ser
|
261 |
* almacenado en el
|
262 |
* @param filterList
|
263 |
* @param band
|
264 |
* @param stretch
|
265 |
*/
|
266 |
private void putStretchBand(List<String> filterList, String band, DefaultStretch stretch) { |
267 |
filterList.add("filter.linearstretchenhancement." + band + ".maxValue=" + stretch.maxValue); |
268 |
filterList.add("filter.linearstretchenhancement." + band + ".minValue=" + stretch.minValue); |
269 |
if (stretch.offset != null) |
270 |
filterList.add("filter.linearstretchenhancement." + band + ".offset=" + convertArrayToString(stretch.offset)); |
271 |
if (stretch.scale != null) |
272 |
filterList.add("filter.linearstretchenhancement." + band + ".scale=" + convertArrayToString(stretch.scale)); |
273 |
if (stretch.stretchIn != null) |
274 |
filterList.add("filter.linearstretchenhancement." + band + ".stretchIn=" + convertArrayToString(stretch.stretchIn)); |
275 |
if (stretch.stretchOut != null) |
276 |
filterList.add("filter.linearstretchenhancement." + band + ".stretchOut=" + convertArrayToString(stretch.stretchOut)); |
277 |
filterList.add("filter.linearstretchenhancement." + band + ".tailTrimMax=" + stretch.tailTrimMax); |
278 |
filterList.add("filter.linearstretchenhancement." + band + ".tailTrimMin=" + stretch.tailTrimMin); |
279 |
filterList.add("filter.linearstretchenhancement." + band + ".tailTrimValueMax=" + stretch.tailTrimValueMax); |
280 |
filterList.add("filter.linearstretchenhancement." + band + ".tailTrimValueMin=" + stretch.tailTrimValueMin); |
281 |
filterList.add("filter.linearstretchenhancement." + band + ".functionType=" + stretch.functionType); |
282 |
filterList.add("filter.linearstretchenhancement." + band + ".valueFunction=" + stretch.valueFunction); |
283 |
} |
284 |
|
285 |
/**
|
286 |
* Obtiene un Array de Strings a partir de una pila de filtros. Cada elemento
|
287 |
* del array tendr? la forma de elemento=valor.
|
288 |
*/
|
289 |
public List<String> getStringsFromFilterList(List<String> filterList, RasterFilter rf) { |
290 |
if (rf instanceof LinearStretchEnhancementFilter) { |
291 |
LinearStretchEnhancementFilter filter = (LinearStretchEnhancementFilter) rf; |
292 |
DefaultLinearStretchParams stretchs = (DefaultLinearStretchParams) filter.getParam("stretchs");
|
293 |
int [] renderBands = (int[]) filter.getParam("renderBands"); |
294 |
|
295 |
filterList.add("filter.linearstretchenhancement.active=true");
|
296 |
filterList.add("filter.linearstretchenhancement.removeends=" + filter.getRemoveEnds());
|
297 |
putStretchBand(filterList, "red", stretchs.red);
|
298 |
putStretchBand(filterList, "green", stretchs.green);
|
299 |
putStretchBand(filterList, "blue", stretchs.blue);
|
300 |
filterList.add("filter.linearstretchenhancement.renderbands=" + convertArrayToString(renderBands));
|
301 |
filterList.add("filter.linearstretchenhancement.RGB=" + Boolean.valueOf(stretchs.rgb).toString()); |
302 |
} |
303 |
|
304 |
return filterList;
|
305 |
} |
306 |
|
307 |
/**
|
308 |
* Configura algun parametro del objeto Stretch, respecto a una banda, su
|
309 |
* propiedad y el valor, en caso de no encontrar la propiedad o no ser dicha
|
310 |
* banda, devuelve false. Es util para usarlo para extraer los valores de
|
311 |
* createFilterListFromStrings
|
312 |
* @param band
|
313 |
* @param property
|
314 |
* @param value
|
315 |
* @param stretch
|
316 |
* @return
|
317 |
*/
|
318 |
public boolean getStretchBand(String band, String property, String value, DefaultStretch stretch) { |
319 |
if (property.startsWith("filter.linearstretchenhancement." + band)) { |
320 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".maxValue")) { |
321 |
stretch.maxValue = Double.parseDouble(value);
|
322 |
return true; |
323 |
} |
324 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".minValue")) { |
325 |
stretch.minValue = Double.parseDouble(value);
|
326 |
return true; |
327 |
} |
328 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".offset")) { |
329 |
stretch.offset = StringToDoubleArray(value); |
330 |
return true; |
331 |
} |
332 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".scale")) { |
333 |
stretch.scale = StringToDoubleArray(value); |
334 |
return true; |
335 |
} |
336 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".stretchIn")) { |
337 |
stretch.stretchIn = StringToDoubleArray(value); |
338 |
return true; |
339 |
} |
340 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".stretchOut")) { |
341 |
stretch.stretchOut = StringToIntegerArray(value); |
342 |
return true; |
343 |
} |
344 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".tailTrimMax")) { |
345 |
stretch.tailTrimMax = Double.parseDouble(value);
|
346 |
return true; |
347 |
} |
348 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".tailTrimMin")) { |
349 |
stretch.tailTrimMin = Double.parseDouble(value);
|
350 |
return true; |
351 |
} |
352 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".tailTrimValueMax")) { |
353 |
stretch.tailTrimValueMax = Double.parseDouble(value);
|
354 |
return true; |
355 |
} |
356 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".tailTrimValueMin")) { |
357 |
stretch.tailTrimValueMin = Double.parseDouble(value);
|
358 |
return true; |
359 |
} |
360 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".functionType")) { |
361 |
stretch.functionType = Integer.parseInt(value);
|
362 |
return true; |
363 |
} |
364 |
if (property.startsWith("filter.linearstretchenhancement." + band + ".valueFunction")) { |
365 |
stretch.valueFunction = Double.parseDouble(value);
|
366 |
return true; |
367 |
} |
368 |
} |
369 |
return false; |
370 |
} |
371 |
|
372 |
/*
|
373 |
* (non-Javadoc)
|
374 |
* @see org.gvsig.raster.grid.filter.IRasterFilterListManager#createFilterListFromStrings(java.util.ArrayList, java.lang.String, int)
|
375 |
*/
|
376 |
public int createFilterListFromStrings(List<String> filters, String fil, int filteri) throws FilterTypeException { |
377 |
String pkgBase = "filter.linearstretchenhancement."; |
378 |
if (fil.startsWith(pkgBase + "active")) { |
379 |
boolean exec = true; |
380 |
boolean removeEnds = false; |
381 |
if ((RasterFilterListManagerImpl.getValue(fil).equals("false"))) |
382 |
exec = false;
|
383 |
filters.remove(0);
|
384 |
int[] renderBands = new int[] { 0, 0, 0 }; |
385 |
DefaultLinearStretchParams stretchParams = new DefaultLinearStretchParams();
|
386 |
|
387 |
for (int propFilter = 0; propFilter < filters.size(); propFilter++) { |
388 |
String elem = (String) filters.get(propFilter); |
389 |
String value = RasterFilterListManagerImpl.getValue(elem);
|
390 |
|
391 |
if (elem.startsWith("filter.linearstretchenhancement.renderbands")) { |
392 |
renderBands = StringToIntegerArray(value); |
393 |
continue;
|
394 |
} |
395 |
|
396 |
if (elem.startsWith("filter.linearstretchenhancement.RGB")) { |
397 |
stretchParams.rgb = Boolean.parseBoolean(value);
|
398 |
continue;
|
399 |
} |
400 |
|
401 |
if (elem
|
402 |
.startsWith("filter.linearstretchenhancement.removeends")) {
|
403 |
removeEnds = Boolean.parseBoolean(value);
|
404 |
continue;
|
405 |
} |
406 |
|
407 |
if (getStretchBand("red", elem, value, stretchParams.red)) |
408 |
continue;
|
409 |
if (getStretchBand("green", elem, value, stretchParams.green)) |
410 |
continue;
|
411 |
if (getStretchBand("blue", elem, value, stretchParams.blue)) |
412 |
continue;
|
413 |
} |
414 |
|
415 |
filterList.remove(LinearStretchEnhancementFilter.class); |
416 |
addEnhancedStretchFilter(stretchParams, stats, renderBands, |
417 |
removeEnds); |
418 |
|
419 |
LinearStretchEnhancementFilter lsef = (LinearStretchEnhancementFilter) filterList.getFilterByBaseClass(LinearStretchEnhancementFilter.class); |
420 |
lsef.setExec(exec); |
421 |
} |
422 |
return filteri;
|
423 |
} |
424 |
|
425 |
public List<Class<?>> getRasterFilterList() { |
426 |
List<Class<?>> filters = new ArrayList<Class<?>>(); |
427 |
filters.add(LinearStretchEnhancementFilter.class); |
428 |
return filters;
|
429 |
} |
430 |
|
431 |
public void addFilter(Class<?> classFilter, Params params) throws FilterTypeException { |
432 |
if (LinearStretchEnhancementFilter.class.isAssignableFrom(classFilter)) {
|
433 |
int[] renderBands = { 0, 1, 2 }; |
434 |
boolean removeEnds = false; |
435 |
|
436 |
DefaultLinearStretchParams leParams = new DefaultLinearStretchParams();
|
437 |
|
438 |
for (int i = 0; i < params.getNumParams(); i++) { |
439 |
if (((ParamImpl)params.getParam(i)).getId().equals("RenderBands") && |
440 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof String) { |
441 |
String[] bands = new String((String) ((ParamImpl)params.getParam(i)).getDefaultValue()).split(" "); |
442 |
renderBands[0] = new Integer(bands[0]).intValue(); |
443 |
renderBands[1] = new Integer(bands[1]).intValue(); |
444 |
renderBands[2] = new Integer(bands[2]).intValue(); |
445 |
continue;
|
446 |
} |
447 |
|
448 |
if (((ParamImpl)params.getParam(i)).getId().equals("Remove")) |
449 |
removeEnds = ((Boolean) ((ParamImpl)params.getParam(i)).getDefaultValue()).booleanValue();
|
450 |
|
451 |
if (((ParamImpl)params.getParam(i)).getId().equals("RGB")) |
452 |
leParams.rgb = ((Boolean) ((ParamImpl)params.getParam(i)).getDefaultValue()).booleanValue();
|
453 |
|
454 |
if (((ParamImpl)params.getParam(i)).getId().equals("StretchInRed") && |
455 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof double[]) |
456 |
leParams.red.stretchIn = ((double[]) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
457 |
if (((ParamImpl)params.getParam(i)).getId().equals("StretchInGreen") && |
458 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof double[]) |
459 |
leParams.green.stretchIn = ((double[]) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
460 |
if (((ParamImpl)params.getParam(i)).getId().equals("StretchInBlue") && |
461 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof double[]) |
462 |
leParams.blue.stretchIn = ((double[]) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
463 |
if (((ParamImpl)params.getParam(i)).getId().equals("StretchOutRed") && |
464 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof int[]) |
465 |
leParams.red.stretchOut = ((int[]) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
466 |
if (((ParamImpl)params.getParam(i)).getId().equals("StretchOutGreen") && |
467 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof int[]) |
468 |
leParams.green.stretchOut = ((int[]) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
469 |
if (((ParamImpl)params.getParam(i)).getId().equals("StretchOutBlue") && |
470 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof int[]) |
471 |
leParams.blue.stretchOut = ((int[]) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
472 |
|
473 |
|
474 |
if (((ParamImpl)params.getParam(i)).getId().equals("TailTrimRedMin") && |
475 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
476 |
leParams.red.tailTrimMin = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
477 |
if (((ParamImpl)params.getParam(i)).getId().equals("TailTrimRedMax") && |
478 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
479 |
leParams.red.tailTrimMax = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
480 |
if (((ParamImpl)params.getParam(i)).getId().equals("TailTrimGreenMin") && |
481 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
482 |
leParams.green.tailTrimMin = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
483 |
if (((ParamImpl)params.getParam(i)).getId().equals("TailTrimGreenMax") && |
484 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
485 |
leParams.green.tailTrimMax = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
486 |
if (((ParamImpl)params.getParam(i)).getId().equals("TailTrimBlueMin") && |
487 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
488 |
leParams.blue.tailTrimMin = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
489 |
if (((ParamImpl)params.getParam(i)).getId().equals("TailTrimBlueMax") && |
490 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
491 |
leParams.blue.tailTrimMax = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
492 |
|
493 |
|
494 |
if (((ParamImpl)params.getParam(i)).getId().equals("StretchRedFunctionType") && |
495 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Integer) |
496 |
leParams.red.functionType = ((Integer) ((ParamImpl)params.getParam(i)).getDefaultValue()).intValue();
|
497 |
if (((ParamImpl)params.getParam(i)).getId().equals("StretchRedValueFunction") && |
498 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
499 |
leParams.red.valueFunction = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
500 |
if (((ParamImpl)params.getParam(i)).getId().equals("StretchGreenFunctionType") && |
501 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Integer) |
502 |
leParams.green.functionType = ((Integer) ((ParamImpl)params.getParam(i)).getDefaultValue()).intValue();
|
503 |
if (((ParamImpl)params.getParam(i)).getId().equals("StretchGreenValueFunction") && |
504 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
505 |
leParams.green.valueFunction = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
506 |
if (((ParamImpl)params.getParam(i)).getId().equals("StretchBlueFunctionType") && |
507 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Integer) |
508 |
leParams.blue.functionType = ((Integer) ((ParamImpl)params.getParam(i)).getDefaultValue()).intValue();
|
509 |
if (((ParamImpl)params.getParam(i)).getId().equals("StretchBlueValueFunction") && |
510 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
511 |
leParams.blue.valueFunction = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
512 |
|
513 |
|
514 |
if (((ParamImpl)params.getParam(i)).getId().equals("TailTrimRedValueMin") && |
515 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
516 |
leParams.red.tailTrimValueMin = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
517 |
if (((ParamImpl)params.getParam(i)).getId().equals("TailTrimRedValueMax") && |
518 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
519 |
leParams.red.tailTrimValueMax = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
520 |
if (((ParamImpl)params.getParam(i)).getId().equals("TailTrimGreenValueMin") && |
521 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
522 |
leParams.green.tailTrimValueMin = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
523 |
if (((ParamImpl)params.getParam(i)).getId().equals("TailTrimGreenValueMax") && |
524 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
525 |
leParams.green.tailTrimValueMax = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
526 |
if (((ParamImpl)params.getParam(i)).getId().equals("TailTrimBlueValueMin") && |
527 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
528 |
leParams.blue.tailTrimValueMin = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
529 |
if (((ParamImpl)params.getParam(i)).getId().equals("TailTrimBlueValueMax") && |
530 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
531 |
leParams.blue.tailTrimValueMax = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
532 |
|
533 |
|
534 |
if (((ParamImpl)params.getParam(i)).getId().equals("RedMaxValue") && |
535 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
536 |
leParams.red.maxValue = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
537 |
if (((ParamImpl)params.getParam(i)).getId().equals("RedMinValue") && |
538 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
539 |
leParams.red.minValue = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
540 |
if (((ParamImpl)params.getParam(i)).getId().equals("GreenMaxValue") && |
541 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
542 |
leParams.green.maxValue = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
543 |
if (((ParamImpl)params.getParam(i)).getId().equals("GreenMinValue") && |
544 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
545 |
leParams.green.minValue = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
546 |
if (((ParamImpl)params.getParam(i)).getId().equals("BlueMaxValue") && |
547 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
548 |
leParams.blue.maxValue = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
549 |
if (((ParamImpl)params.getParam(i)).getId().equals("BlueMinValue") && |
550 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof Double) |
551 |
leParams.blue.minValue = ((Double) ((ParamImpl)params.getParam(i)).getDefaultValue()).doubleValue();
|
552 |
|
553 |
|
554 |
if (((ParamImpl)params.getParam(i)).getId().equals("RedOffset") && |
555 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof double[]) |
556 |
leParams.red.offset = ((double[]) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
557 |
if (((ParamImpl)params.getParam(i)).getId().equals("GreenOffset") && |
558 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof double[]) |
559 |
leParams.green.offset = ((double[]) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
560 |
if (((ParamImpl)params.getParam(i)).getId().equals("BlueOffset") && |
561 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof double[]) |
562 |
leParams.blue.offset = ((double[]) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
563 |
if (((ParamImpl)params.getParam(i)).getId().equals("RedScale") && |
564 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof double[]) |
565 |
leParams.red.scale = ((double[]) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
566 |
if (((ParamImpl)params.getParam(i)).getId().equals("GreenScale") && |
567 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof double[]) |
568 |
leParams.green.scale = ((double[]) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
569 |
if (((ParamImpl)params.getParam(i)).getId().equals("BlueScale") && |
570 |
((ParamImpl)params.getParam(i)).getDefaultValue() instanceof double[]) |
571 |
leParams.blue.scale = ((double[]) ((ParamImpl)params.getParam(i)).getDefaultValue()); |
572 |
} |
573 |
|
574 |
addEnhancedStretchFilter(leParams, (Statistics) filterList.getEnvParam("IStatistics"), renderBands, removeEnds);
|
575 |
} |
576 |
} |
577 |
|
578 |
/*
|
579 |
* (non-Javadoc)
|
580 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#getFilterList()
|
581 |
*/
|
582 |
public RasterFilterList getFilterList() {
|
583 |
return filterList;
|
584 |
} |
585 |
|
586 |
/*
|
587 |
* (non-Javadoc)
|
588 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#setFilterList(org.gvsig.fmap.dal.coverage.grid.RasterFilterList)
|
589 |
*/
|
590 |
public void setFilterList(RasterFilterList filterList) { |
591 |
this.filterList = filterList;
|
592 |
} |
593 |
|
594 |
/*
|
595 |
* (non-Javadoc)
|
596 |
* @see org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager#createFilter(org.gvsig.fmap.dal.coverage.datastruct.Params)
|
597 |
*/
|
598 |
public RasterFilter createFilter(Params params) throws FilterTypeException { |
599 |
int[] renderBands = null; |
600 |
Statistics stats = null;
|
601 |
Boolean removeEnds = null; |
602 |
|
603 |
if(params.getParamById("renderBands") != null) |
604 |
renderBands = (int[])params.getParamById("renderBands").getDefaultValue(); |
605 |
if(params.getParamById("stats") != null) |
606 |
stats = (Statistics)params.getParamById("stats").getDefaultValue();
|
607 |
if(params.getParamById("remove") != null) |
608 |
removeEnds = ((Boolean)params.getParamById("remove").getDefaultValue()); |
609 |
|
610 |
DefaultLinearStretchParams p = null;
|
611 |
|
612 |
try {
|
613 |
if( params.getParamById("tailtrim") != null && |
614 |
params.getParamById("rgb") != null && |
615 |
params.getParamById("tailtrim").getDefaultValue() != null && |
616 |
params.getParamById("rgb").getDefaultValue() != null) { |
617 |
double tailtrim = ((Double)params.getParamById("tailtrim").getDefaultValue()).doubleValue(); |
618 |
boolean rgb = ((Boolean)params.getParamById("rgb").getDefaultValue()).booleanValue(); |
619 |
p = DefaultLinearStretchParams.createStandardParam(renderBands, tailtrim, stats, rgb); |
620 |
} else {
|
621 |
//Si stretch vale null se usan los par?metros por defecto de LinearStretchParams
|
622 |
if( params.getParamById("stretchs") != null && |
623 |
params.getParamById("stretchs").getDefaultValue() == null) { |
624 |
p = DefaultLinearStretchParams.createStandardParam(renderBands, 0.0, stats, removeEnds.booleanValue());
|
625 |
} |
626 |
} |
627 |
} catch (FileNotOpenException e) {
|
628 |
throw new FilterTypeException("", e); |
629 |
} catch (RasterDriverException e) {
|
630 |
throw new FilterTypeException("", e); |
631 |
} |
632 |
return createEnhancedFilter(p, stats, renderBands, removeEnds != null ? removeEnds.booleanValue() : true); |
633 |
} |
634 |
} |