Revision 29786
branches/v2_0_0_prep/libraries/libRaster/src/org/gvsig/raster/grid/filter/enhancement/EnhancementStretchListManager.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
|
2 | 2 |
* |
3 | 3 |
* Copyright (C) 2006 IVER T.I. and Generalitat Valenciana. |
4 | 4 |
* |
... | ... | |
72 | 72 |
} |
73 | 73 |
|
74 | 74 |
/** |
75 |
* A?ade un filtro de realce.
|
|
76 |
* La forma de inserci?n del filtro es fija ya que la inserci?n de un realce lleva implicita
|
|
77 |
* la inserci?n de un filtro de recorte de colas (tailtrim), aunque no en todos los casos.
|
|
78 |
* Si ya existe un filtro de realce en la lista se obtiene la posici?n de este.
|
|
75 |
* A�ade un filtro de realce.
|
|
76 |
* La forma de inserci�n del filtro es fija ya que la inserci�n de un realce lleva implicita
|
|
77 |
* la inserci�n de un filtro de recorte de colas (tailtrim), aunque no en todos los casos.
|
|
78 |
* Si ya existe un filtro de realce en la lista se obtiene la posici�n de este.
|
|
79 | 79 |
* Si es necesario un recorte de colas entonces se comprueba si existe un uno reemplazandose |
80 |
* por el nuevo y sino se insertar? uno. Al final reemplazamos el realce que existia.
|
|
80 |
* por el nuevo y sino se insertar� uno. Al final reemplazamos el realce que existia.
|
|
81 | 81 |
* |
82 |
* Si por el contrario no existen realce ni trim se a?aden ambos al final de la lista.
|
|
82 |
* Si por el contrario no existen realce ni trim se a�aden ambos al final de la lista.
|
|
83 | 83 |
* @param stats Objeto de estadisticas asociado |
84 |
* @param tailTrim porcentaje de recorte de colas. Ser? un valor entre 0 y 1.
|
|
85 |
* @param insertionMode Modo de inserci?n
|
|
86 |
* @param renderBands bandas RGB mostradas en la visualizaci?n.
|
|
84 |
* @param tailTrim porcentaje de recorte de colas. Ser� un valor entre 0 y 1.
|
|
85 |
* @param insertionMode Modo de inserci�n
|
|
86 |
* @param renderBands bandas RGB mostradas en la visualizaci�n.
|
|
87 | 87 |
* @throws FilterTypeException |
88 | 88 |
*/ |
89 | 89 |
public void addEnhancedStretchFilter(LinearStretchParams leParams, IStatistics stats, int[] renderBands, boolean removeEnds) throws FilterTypeException { |
90 | 90 |
try { |
91 |
if (!leParams.hasTailTrim()) { // En este caso siempre es necesario el m?ximo y
|
|
92 |
// m?nimo
|
|
91 |
if (!leParams.hasTailTrim()) { // En este caso siempre es necesario el m�ximo y
|
|
92 |
// m�nimo
|
|
93 | 93 |
if (!stats.isCalculated()) |
94 | 94 |
try { |
95 | 95 |
stats.calcFullStatistics(); |
... | ... | |
109 | 109 |
if (filter != null) |
110 | 110 |
filterList.add(filter); |
111 | 111 |
} catch (InterruptedException e) { |
112 |
//Si se ha interrumpido no a?adimos el filtro
|
|
112 |
//Si se ha interrumpido no a�adimos el filtro
|
|
113 | 113 |
} |
114 | 114 |
} |
115 | 115 |
|
116 | 116 |
/** |
117 |
* Crea un filtro de realce por tramos de forma est?tica
|
|
118 |
* @param leParams Par?metros del filtro
|
|
117 |
* Crea un filtro de realce por tramos de forma est�tica
|
|
118 |
* @param leParams Par�metros del filtro
|
|
119 | 119 |
* @param stats |
120 | 120 |
* @param renderBands |
121 | 121 |
* @return |
... | ... | |
223 | 223 |
|
224 | 224 |
/** |
225 | 225 |
* Obtiene un Array de Strings a partir de una pila de filtros. Cada elemento |
226 |
* del array tendr? la forma de elemento=valor.
|
|
226 |
* del array tendr� la forma de elemento=valor.
|
|
227 | 227 |
*/ |
228 | 228 |
public ArrayList getStringsFromFilterList(ArrayList filterList, RasterFilter rf) { |
229 | 229 |
if (rf instanceof LinearStretchEnhancementFilter) { |
230 | 230 |
LinearStretchEnhancementFilter filter = (LinearStretchEnhancementFilter) rf; |
231 |
|
|
231 |
LinearStretchParams stretchs = (LinearStretchParams) filter.getParam("stretchs"); |
|
232 |
int [] renderBands = (int[]) filter.getParam("renderBands"); |
|
233 |
|
|
232 | 234 |
filterList.add("filter.linearstretchenhancement.active=true"); |
233 | 235 |
filterList.add("filter.linearstretchenhancement.removeends=" + filter.getRemoveEnds()); |
234 |
putStretchBand(filterList, "red", filter.stretchs.red);
|
|
235 |
putStretchBand(filterList, "green", filter.stretchs.green);
|
|
236 |
putStretchBand(filterList, "blue", filter.stretchs.blue);
|
|
237 |
filterList.add("filter.linearstretchenhancement.renderbands=" + convertArrayToString(filter.renderBands));
|
|
238 |
filterList.add("filter.linearstretchenhancement.RGB=" + Boolean.valueOf(filter.stretchs.rgb).toString());
|
|
236 |
putStretchBand(filterList, "red", stretchs.red); |
|
237 |
putStretchBand(filterList, "green", stretchs.green); |
|
238 |
putStretchBand(filterList, "blue", stretchs.blue); |
|
239 |
filterList.add("filter.linearstretchenhancement.renderbands=" + convertArrayToString(renderBands)); |
|
240 |
filterList.add("filter.linearstretchenhancement.RGB=" + Boolean.valueOf(stretchs.rgb).toString()); |
|
239 | 241 |
} |
240 | 242 |
|
241 | 243 |
return filterList; |
branches/v2_0_0_prep/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/control/EnhancedControl.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
|
2 | 2 |
* |
3 | 3 |
* Copyright (C) 2007 IVER T.I. and Generalitat Valenciana. |
4 | 4 |
* |
... | ... | |
59 | 59 |
|
60 | 60 |
|
61 | 61 |
/** |
62 |
* Clase que hace de interfaz entre los objetos que contienen la informaci?n de
|
|
62 |
* Clase que hace de interfaz entre los objetos que contienen la informaci�n de
|
|
63 | 63 |
* realce y el panel. |
64 | 64 |
* |
65 | 65 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
... | ... | |
128 | 128 |
* Manejador de eventos del panel EnhancedWithTrim. |
129 | 129 |
* |
130 | 130 |
* @version 14/06/2007 |
131 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
|
131 |
* @author BorSanZa - Borja S�nchez Zamorano (borja.sanchez@iver.es)
|
|
132 | 132 |
*/ |
133 | 133 |
class EnhancedWithTrimListener implements ActionListener, SliderListener { |
134 | 134 |
JCheckBox active = null; |
... | ... | |
200 | 200 |
private void setValuesFromFilterToPanel() { |
201 | 201 |
// BRILLO |
202 | 202 |
BrightnessFilter bFilter = (BrightnessFilter) filterList.getByName(BrightnessFilter.names[0]); |
203 |
if (bFilter != null) |
|
204 |
bcPanel.setBrightnessValue((double) bFilter.getBrightnessIncrease()); |
|
205 |
else |
|
203 |
if (bFilter != null){ |
|
204 |
int incr = ((Integer)bFilter.getParam("incrBrillo")).intValue(); |
|
205 |
bcPanel.setBrightnessValue((double) incr); |
|
206 |
}else |
|
206 | 207 |
bcPanel.setBrightnessValue(0); |
207 | 208 |
|
208 | 209 |
// CONTRASTE |
209 | 210 |
ContrastFilter cFilter = (ContrastFilter) filterList.getByName(ContrastFilter.names[0]); |
210 |
if (cFilter != null) |
|
211 |
bcPanel.setContrastValue((double) cFilter.getContrastIncrease()); |
|
211 |
if (cFilter != null){ |
|
212 |
int incr = ((Integer)cFilter.getParam("incrContraste")).intValue(); |
|
213 |
bcPanel.setContrastValue((double) incr); |
|
214 |
} |
|
212 | 215 |
else |
213 | 216 |
bcPanel.setContrastValue(0); |
214 | 217 |
|
... | ... | |
221 | 224 |
LinearStretchEnhancementFilter eFilter = (LinearStretchEnhancementFilter) filterList.getByName(LinearStretchEnhancementFilter.names[0]); |
222 | 225 |
if (eFilter != null) { |
223 | 226 |
ePanel.setControlEnabled(true); |
224 |
ePanel.setRemoveEndsActive(eFilter.getRemoveEnds().booleanValue()); |
|
225 |
if (eFilter.getTailTrim().doubleValue() != 0) { |
|
227 |
|
|
228 |
// Comprueba si esta activo eliminar extremos |
|
229 |
boolean removeEnds = false; |
|
230 |
if (eFilter.getParam("remove") != null) |
|
231 |
removeEnds = ((Boolean) eFilter.getParam("remove")).booleanValue(); |
|
232 |
ePanel.setRemoveEndsActive(removeEnds); |
|
233 |
|
|
234 |
// Comprueba si hay recorte de colas |
|
235 |
LinearStretchParams stretchs = (LinearStretchParams) eFilter.getParam("stretchs"); |
|
236 |
double[] tailTrimList; |
|
237 |
if (stretchs != null) |
|
238 |
tailTrimList = stretchs.getTailTrimList(); |
|
239 |
else |
|
240 |
tailTrimList = new double[0]; |
|
241 |
double median = 0; |
|
242 |
double nValues = tailTrimList.length; |
|
243 |
for (int i = 0; i < tailTrimList.length; i++) |
|
244 |
median += tailTrimList[i]; |
|
245 |
double tailTrim = new Double(nValues > 0 ? median / nValues : median).doubleValue(); |
|
246 |
|
|
247 |
if (tailTrim != 0) { |
|
226 | 248 |
ePanel.setTailTrimCheckActive(true); |
227 |
ePanel.setTailTrimValue(eFilter.getTailTrim().doubleValue() * 100);
|
|
249 |
ePanel.setTailTrimValue(tailTrim * 100);
|
|
228 | 250 |
} else { |
229 | 251 |
ePanel.setTailTrimCheckActive(false); |
230 | 252 |
ePanel.setTailTrimValue(0); |
... | ... | |
251 | 273 |
stats = dataset.getDataSource().getStatistics(); |
252 | 274 |
if (lyr instanceof IRasterRendering) |
253 | 275 |
renderBands = ((IRasterRendering) lyr).getRender().getRenderBands(); |
254 |
// En este caso siempre es necesario el m?ximo y m?nimo
|
|
276 |
// En este caso siempre es necesario el m�ximo y m�nimo
|
|
255 | 277 |
try { |
256 | 278 |
if(!stats.isCalculated() && lyr instanceof FLyrRasterSE) |
257 | 279 |
StatisticsProcess.launcher((FLyrRasterSE)lyr, this); |
... | ... | |
266 | 288 |
} |
267 | 289 |
} |
268 | 290 |
} catch (FileNotOpenException e) { |
269 |
throw new FilterAddException("No se han podido calcular estadisticas. Error al a?adir realce;" + e.getMessage());
|
|
291 |
throw new FilterAddException("No se han podido calcular estadisticas. Error al a�adir realce;" + e.getMessage());
|
|
270 | 292 |
} catch (RasterDriverException e) { |
271 |
throw new FilterAddException("No se han podido calcular estadisticas. Error al a?adir realce; " + e.getMessage());
|
|
293 |
throw new FilterAddException("No se han podido calcular estadisticas. Error al a�adir realce; " + e.getMessage());
|
|
272 | 294 |
} |
273 | 295 |
} else { |
274 | 296 |
filterList.remove(LinearStretchEnhancementFilter.class); |
... | ... | |
292 | 314 |
} |
293 | 315 |
|
294 | 316 |
/** |
295 |
* Acciones realizadas al final la aplicaci?n de filtros
|
|
317 |
* Acciones realizadas al final la aplicaci�n de filtros
|
|
296 | 318 |
* @throws FilterTypeException |
297 | 319 |
*/ |
298 | 320 |
@SuppressWarnings("unchecked") |
... | ... | |
362 | 384 |
} |
363 | 385 |
|
364 | 386 |
/** |
365 |
* Consulta si el filtro especificado en el par?metro name est? dentro
|
|
387 |
* Consulta si el filtro especificado en el par�metro name est� dentro
|
|
366 | 388 |
* de la lista filter. |
367 | 389 |
* @param filter Lista donde se consulta |
368 |
* @param name Nombre a comprobar si est? en la lista
|
|
369 |
* @return true si est? en la lista y false si no est?.
|
|
390 |
* @param name Nombre a comprobar si est� en la lista
|
|
391 |
* @return true si est� en la lista y false si no est�.
|
|
370 | 392 |
*/ |
371 | 393 |
@SuppressWarnings("unchecked") |
372 | 394 |
private int hasFilter(ArrayList filter, String name) { |
Also available in: Unified diff