Revision 29786 branches/v2_0_0_prep/extensions/extRasterTools-SE/src/org/gvsig/rastertools/properties/control/EnhancedControl.java

View differences:

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 informacin 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 Snchez 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 aadir 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 aadir 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 aplicacin 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