Revision 168

View differences:

org.gvsig.raster.app/trunk/org.gvsig.raster.app/org.gvsig.raster.app.tools/src/main/java/org/gvsig/raster/app/extension/RasterExtension.java
91 91
	 */
92 92
	public static boolean       askCoordinates = false;
93 93

  
94
//	private RasterStoreLibrary storeLibrary;
95

  
96 94
	/*
97 95
	 * (non-Javadoc)
98 96
	 * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
......
434 432
	 * (non-Javadoc)
435 433
	 * @see com.iver.andami.plugins.IExtension#isEnabled()
436 434
	 */
435
	@SuppressWarnings("deprecation")
437 436
	public boolean isEnabled() {
438 437
		org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
439 438
		if (f == null)
......
453 452
	/**
454 453
	 * Mostramos el control si hay alguna capa cargada.
455 454
	 */
455
	@SuppressWarnings("deprecation")
456 456
	public boolean isVisible() {
457 457
		org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
458 458
		if (f == null)
......
487 487
	 * (non-Javadoc)
488 488
	 * @see org.gvsig.raster.util.ConfigurationListener#actionConfigurationChanged(org.gvsig.raster.util.ConfigurationEvent)
489 489
	 */
490
	@SuppressWarnings("deprecation")
490 491
	public void actionConfigurationChanged(ConfigurationEvent e) {
491 492
		if (e.getKey().equals("nodata_transparency_enabled")) {
492 493
			boolean noDataTransparent = ((Boolean) e.getValue()).booleanValue();
org.gvsig.raster.app/trunk/org.gvsig.raster.app/org.gvsig.raster.app.tools/src/main/java/org/gvsig/raster/app/extension/tool/enhanced/EnhancedTocMenuEntry.java
45 45
 */
46 46
public class EnhancedTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem, IProcessActions {
47 47
	static private EnhancedTocMenuEntry   singleton   = null;
48
	private FLyrRaster                  lyr         = null;
48
	private FLyrRaster                    lyr         = null;
49 49

  
50 50
	/**
51 51
	 * Nadie puede crear una instancia a esta clase ?nica, hay que usar el
......
135 135
			return;
136 136
				
137 137
		this.lyr = (FLyrRaster)selectedItems[0];
138
		
138 139
		if(!lyr.getDataStore().getStatistics().isCalculated()) 
139 140
			StatisticsProcess.launcher(lyr, this);
140 141
		else
......
152 153
	/**
153 154
	 * Lanzamos la ventana al final del proceso de calculo de estad?sticas.
154 155
	 */
155
	public void end(Object param) {
156
	public synchronized void end(Object param) {
156 157
		if(param == null || param instanceof FLyrRaster) {
157 158
			HistogramProcess histogramProcess = new HistogramProcess();
158 159
			histogramProcess.setActions(this);
org.gvsig.raster.app/trunk/org.gvsig.raster.app/org.gvsig.raster.app.tools/src/main/java/org/gvsig/raster/app/extension/tool/enhanced/ui/EnhancedListener.java
29 29
import org.gvsig.andami.PluginServices;
30 30
import org.gvsig.fmap.dal.coverage.RasterLocator;
31 31
import org.gvsig.fmap.dal.coverage.datastruct.Params;
32
import org.gvsig.fmap.dal.coverage.datastruct.Stretch;
32 33
import org.gvsig.fmap.dal.coverage.exception.FilterManagerException;
33 34
import org.gvsig.fmap.dal.coverage.exception.FilterTypeException;
35
import org.gvsig.fmap.dal.coverage.grid.RasterFilter;
34 36
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList;
35 37
import org.gvsig.fmap.dal.coverage.grid.filter.LinearStretchParams;
36
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
37 38
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
38 39
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent;
39 40
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener;
......
283 284
	 * Actualiza el combo de EnhancedType para que este seleccionado siempre el
284 285
	 * item que corresponde con la grafica mostrada en ese momento
285 286
	 */
287
	@SuppressWarnings("unchecked")
286 288
	private void updateTypeSelected() {
287 289
		HistogramStatus status = graphicsPanel.getInputHistogram().getHistogramStatus(HistogramGraphicBase.DRAWED);
288 290

  
......
324 326
		if (status == null)
325 327
			return;
326 328
		
327
		switch (stretch.functionType) {
329
		switch (stretch.getFunctionType()) {
328 330
			case 0:
329 331
				if (firstBand) {
330 332
					selectorsPanel.getEnhancedType().setSelectedItem(RasterToolsUtil.getText(this, "lineal"));
......
332 334
				}
333 335
				baseFunction = new StraightLine(status.getBaseFunction().getColor());
334 336
				((StraightLine) baseFunction).clearSquares();
335
				for (int i = 0; i < stretch.stretchIn.length; i++) {
337
				for (int i = 0; i < stretch.getStretchIn().length; i++) {
336 338
					((StraightLine) baseFunction).addSquare(
337
						(stretch.stretchIn[i] - stretch.minValue) / (stretch.maxValue - stretch.minValue),
338
						stretch.stretchOut[i] / 255.0D);
339
						(stretch.getStretchIn()[i] - stretch.getMinValue()) / (stretch.getMaxValue() - stretch.getMinValue()),
340
						stretch.getStretchOut()[i] / 255.0D);
339 341
				}
340 342
				break;
341 343
			case 1:
342 344
				if (firstBand) {
343
					if (stretch.valueFunction >= 0)
345
					if (stretch.getValueFunction() >= 0)
344 346
						selectorsPanel.getEnhancedType().setSelectedItem(RasterToolsUtil.getText(this, "logaritmic"));
345 347
					else
346 348
						selectorsPanel.getEnhancedType().setSelectedItem(RasterToolsUtil.getText(this, "exponential"));
347 349
					graphicsPanel.setLevelsEnabled(false);
348 350
				}
349
				baseFunction = new LogaritmicExponentialLine(status.getBaseFunction().getColor(), stretch.valueFunction);
351
				baseFunction = new LogaritmicExponentialLine(status.getBaseFunction().getColor(), stretch.getValueFunction());
350 352
				break;
351 353
			case 2:
352 354
				if (firstBand) {
353 355
					selectorsPanel.getEnhancedType().setSelectedItem(RasterToolsUtil.getText(this, "square_root"));
354 356
					graphicsPanel.setLevelsEnabled(false);
355 357
				}
356
				baseFunction = new SquareRootPowLine(status.getBaseFunction().getColor(), stretch.valueFunction);
358
				baseFunction = new SquareRootPowLine(status.getBaseFunction().getColor(), stretch.getValueFunction());
357 359
				break;
358 360
			case 3:
359 361
				if (firstBand) {
360 362
					selectorsPanel.getEnhancedType().setSelectedItem(RasterToolsUtil.getText(this, "level_slice"));
361 363
					graphicsPanel.setLevelsEnabled(true);
362 364
				}
363
				baseFunction = new DensitySlicingLine(status.getBaseFunction().getColor(), (int) stretch.valueFunction);
365
				baseFunction = new DensitySlicingLine(status.getBaseFunction().getColor(), (int) stretch.getValueFunction());
364 366
				break;
365 367
		}
366 368
		if (baseFunction != null) {
......
374 376
	 * a sus valores correspondientes segun el filtro.
375 377
	 */
376 378
	public void firstLoad() {
377
		RasterFilterList rasterFilterList = ((FLyrRaster) enhancedDialog.getLayer()).getRenderFilterList();
379
		RasterFilterList rasterFilterList = enhancedDialog.getLayer().getRender().getFilterList();
378 380

  
379
		LinearStretchEnhancementFilter filter = (LinearStretchEnhancementFilter) rasterFilterList.getByName(LinearStretchEnhancementFilter.names[0]);
381
		RasterFilter filter = rasterFilterList.getByName("enhanced_stretch");
380 382
		if (filter != null) {
381
			LinearStretchParams stretch = filter.getStretchs();
383
			LinearStretchParams stretch = (LinearStretchParams) filter.getParam("stretchs");
382 384
			
383
			firstLoadBand(stretch.blue, HistogramGraphicBase.BLUE);
384
			firstLoadBand(stretch.green, HistogramGraphicBase.GREEN);
385
			firstLoadBand(stretch.red, HistogramGraphicBase.RED);
386
			firstLoadBand(stretch.red, HistogramGraphicBase.GRAY);
387
			graphicsPanel.getRGB().setSelected(stretch.rgb);
385
			firstLoadBand(stretch.getBlue(), HistogramGraphicBase.BLUE);
386
			firstLoadBand(stretch.getGreen(), HistogramGraphicBase.GREEN);
387
			firstLoadBand(stretch.getRed(), HistogramGraphicBase.RED);
388
			firstLoadBand(stretch.getRed(), HistogramGraphicBase.GRAY);
389
			graphicsPanel.getRGB().setSelected(stretch.isRgb());
388 390
		}
389 391
		graphicsPanel.getInputHistogram().repaint();
390 392
	}
org.gvsig.raster.app/trunk/org.gvsig.raster.app/org.gvsig.raster.app.tools/src/main/java/org/gvsig/raster/app/extension/tool/GenericToolBarModule.java
34 34
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
35 35
import org.gvsig.fmap.mapcontext.MapContext;
36 36
import org.gvsig.raster.app.extension.tool.clip.ClippingTocMenuEntry;
37
import org.gvsig.raster.app.extension.tool.enhanced.EnhancedTocMenuEntry;
37 38
import org.gvsig.raster.app.extension.tool.filter.FilterTocMenuEntry;
38 39
import org.gvsig.raster.app.extension.tool.generictoolbar.GenericToolBarMenuItem;
39 40
import org.gvsig.raster.app.extension.tool.generictoolbar.GenericToolBarPanel;
......
139 140
		point.append("SaveRaster", "", SaveRasterTocMenuEntry.getSingleton());
140 141

  
141 142
		point.append("FilterPanel", "", FilterTocMenuEntry.getSingleton());
142
		//point.append("EnhancedPanel", "", EnhancedTocMenuEntry.getSingleton());
143
		point.append("EnhancedPanel", "", EnhancedTocMenuEntry.getSingleton());
143 144
		point.append("GeoLocation", "", GeoLocationTocMenuEntry.getSingleton());
144 145
		//point.append("Vectorization", "", VectorizationTocMenuEntry.getSingleton());
145 146
		ReprojectTocMenuEntry menuEntry = ReprojectTocMenuEntry.getSingleton();
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.api/src/main/java/org/gvsig/fmap/dal/coverage/grid/RasterFilterList.java
283 283
	public Params createEmptyFilterParams();
284 284
	
285 285
	/**
286
	 * Builds an instance of a filter from its class name.
287
	 * @param strPackage package and class name
288
	 * @return Filtro instanciado
289
	 * @throws FilterTypeException
290
	 */
291
	public RasterFilter createEmptyFilter(String nameFilter) throws FilterTypeException;
292
	
293
	/**
286 294
	 * Crea una pila de filtros a partir de un Array de Strings. Cada elemento del array debe
287 295
	 * tener la forma elemento=valor.
288 296
	 * @param filters
......
290 298
	 */
291 299
	public void createFilterListFromStrings(ArrayList<String> f) throws FilterTypeException;
292 300
	
293
	
294 301
	/**
295 302
	 * Gets a specific manager using its ID
296 303
	 * @return
......
305 312
	public RasterFilterListManager getManagerByFilterClass(Class c) throws FilterManagerException;
306 313
	
307 314
	/**
315
	 * Gets the manager using its class
316
	 * @param clase
317
	 * @return
318
	 */
319
	@SuppressWarnings("unchecked")
320
	public RasterFilterListManager getManagerByClass(Class clase);
321
	
322
	/**
308 323
	 * Gets the registered list of filters
309 324
	 * @return
310 325
	 */
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.api/src/main/java/org/gvsig/fmap/dal/coverage/grid/filter/LinearStretchParams.java
21 21
 */
22 22
package org.gvsig.fmap.dal.coverage.grid.filter;
23 23

  
24
import org.gvsig.fmap.dal.coverage.datastruct.Stretch;
24 25
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
25 26

  
26 27
/**
......
73 74
	 * Aplica el eliminado de extremos. Para ello utiliza el segundo m?ximo y m?nimo de entrada.
74 75
	 */
75 76
	public void applyRemoveEndsToStretchs(Statistics stats, int[] renderBands);
77
	
78
	/**
79
	 * Gets the list of ranges in the red band
80
	 * @return
81
	 */
82
	public Stretch getRed();
83

  
84
	/**
85
	 * Sets the list of ranges in the red band
86
	 */
87
	public void setRed(Stretch red);
88

  
89
	/**
90
	 * Gets the list of ranges in the green band
91
	 */
92
	public Stretch getGreen();
93

  
94
	/**
95
	 * Sets the list of ranges in the red band
96
	 */
97
	public void setGreen(Stretch green);
98
	
99
	/**
100
	 * Gets the list of ranges in the blue band
101
	 */
102
	public Stretch getBlue();
103

  
104
	/**
105
	 * Sets the list of ranges in the blue band
106
	 */
107
	public void setBlue(Stretch blue);
108

  
109
	public boolean isRgb();
110

  
111
	public void setRgb(boolean rgb);
76 112
}
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.api/src/main/java/org/gvsig/fmap/dal/coverage/datastruct/Stretch.java
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.fmap.dal.coverage.datastruct;
23

  
24
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
25

  
26
public interface Stretch {
27
	/**
28
	 * Aplica el recorte de colas sobre los extremos de los m?ximos y m?nimos de entrada.
29
	 * La aplicaci?n de esta funci?n considera que ya se han calculado los valores con 
30
	 * loadTailTrimValues.
31
	 */
32
	public void applyTrimToStretchs();
33
	
34
	/**
35
	 * Consulta si tiene alg?n valor el recorte de colas
36
	 * @return true si tiene valor el recorte de colas y false si no lo tiene
37
	 */
38
	public boolean hasTailTrim();
39
	
40
	/**
41
	 * Calcula la escala y el desplazamiento teniendo en cuenta que
42
	 * ya tenga todos los valores de entrada asignados.
43
	 *
44
	 */
45
	public void calcLinearScaleAndOffset();
46
	
47
	/**
48
	 * Asigna el m?ximo y el m?nimo
49
	 * @param stats
50
	 * @param type
51
	 * @param band
52
	 */
53
	public void setMaxMin(Statistics stats, int band, boolean rgb);
54
	
55
	/**
56
	 * Aplica el eliminado de extremos. Para ello utiliza el segundo m?ximo y m?nimo de entrada.
57
	 */
58
	public void applyRemoveEndsToStretchs(Statistics stats, boolean rgb, int band);
59
	
60
	public double[] getOffset();
61

  
62
	public double getMaxValue();
63

  
64
	public double getMinValue();
65

  
66
	public int getFunctionType();
67
	
68
	public double[] getStretchIn();
69

  
70
	public int[] getStretchOut();
71
	
72
	public double getValueFunction();
73
}
0 74

  
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/datastruct/Stretch.java
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.datastruct;
23

  
24
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
25

  
26
public class Stretch {
27
	/**
28
	 * Valores de los datos de entrada correspondientes al m?nimo y al m?ximo de 
29
	 * cada tramo. Estos tendr?n un rango entre el m?nimo y el m?ximo en cada banda
30
	 * de la imagen. 
31
	 */
32
	public double[]        stretchIn           = null;
33
	/**
34
	 * Valores de los datos de salida correspondientes al m?nimo y al m?ximo de 
35
	 * cada tramo. Estos tendr?n un rango entre 0 y 255.
36
	 */
37
	public int[]           stretchOut          = null;
38
	/**
39
	 * Porcentajes de recorte de colas (Valores de entrada)
40
	 */
41
	public double          tailTrimMin         = 0;
42
	public double          tailTrimMax         = 0;
43
	/**
44
	 * Valores de recorte de colas (Valores de salida calculados por el filtro TailTrim)
45
	 */
46
	public double          tailTrimValueMin    = 0;
47
	public double          tailTrimValueMax    = 0;
48
	/**
49
	 * Valores de escala a calcular por el filtro lineal por tramos.
50
	 * Cada elemento del array es un tramo.
51
	 */
52
	public double[]        scale               = null;
53
	/**
54
	 * Valores de desplazamiento a calcular por el filtro lineal por tramos.
55
	 * Cada elemento del array es un tramo.
56
	 */
57
	public double[]        offset              = null;
58
	/**
59
	 * Valores m?ximos y m?nimos
60
	 */
61
	public double          maxValue            = 0;
62
	public double          minValue            = 0;
63
	
64
	/**
65
	 * Funcion grafica que se ha usado para generar el LinearStretchParams
66
	 * 0 - Lineal
67
	 * 1 - Exponencial / Logaritmica
68
	 * 2 - Raiz cuadrada / Cuadrada
69
	 * 3 - Level slice
70
	 */
71
	public int functionType = 0;
72

  
73
	/**
74
	 * Valor de la gr?fica para la funci?n. No se usa en una gr?fica lineal.
75
	 */
76
	public double valueFunction = 0.0;
77
	
78
	/**
79
	 * Aplica el recorte de colas sobre los extremos de los m?ximos y m?nimos de entrada.
80
	 * La aplicaci?n de esta funci?n considera que ya se han calculado los valores con 
81
	 * loadTailTrimValues.
82
	 */
83
	public void applyTrimToStretchs() {
84
		if(stretchIn != null && stretchIn.length >= 2) {
85
			minValue = stretchIn[0] = tailTrimValueMin;
86
			maxValue = stretchIn[stretchIn.length - 1] = tailTrimValueMax;
87
		}
88
	}
89
	
90
	/**
91
	 * Aplica el eliminado de extremos. Para ello utiliza el segundo m?ximo y m?nimo de entrada.
92
	 */
93
	/*public void applyRemoveEndsToStretchs(double secondMin, double secondMax) {
94
		if(stretchIn != null && stretchIn.length >= 2) {
95
			minValue = stretchIn[0] = secondMin;
96
			maxValue = stretchIn[stretchIn.length - 1] = secondMax;
97
		}
98
	}*/
99
	
100
	/**
101
	 * Consulta si tiene alg?n valor el recorte de colas
102
	 * @return true si tiene valor el recorte de colas y false si no lo tiene
103
	 */
104
	public boolean hasTailTrim() {
105
		return (tailTrimMin != 0 || tailTrimMax != 0);
106
	}
107
	
108
	/**
109
	 * Calcula la escala y el desplazamiento teniendo en cuenta que
110
	 * ya tenga todos los valores de entrada asignados.
111
	 *
112
	 */
113
	public void calcLinearScaleAndOffset() {
114
		if(stretchIn != null && stretchOut != null) {
115
			//simplifyStretch();
116
			scale = new double[stretchIn.length - 1];
117
			offset = new double[stretchIn.length - 1];
118
			for (int i = 0; i < scale.length; i++) {
119
				double rgbRange = (stretchOut[i + 1] - stretchOut[i]);
120
				if((stretchIn[i + 1] - stretchIn[i]) == 0)
121
					scale[i] = 0;
122
				else
123
					scale[i] = rgbRange / (stretchIn[i + 1] - stretchIn[i]);
124
				offset[i] = stretchOut[i];
125
			}
126
		}
127
	}
128
	
129
	/**
130
	 * Elimina puntos redundantes en stretchIn y stretchOut
131
	 */
132
//	private void simplifyStretch() {
133
//		boolean simplified = false;
134
//		for (int i = 0; i < (stretchIn.length - 1); i++) {
135
//			if(stretchIn[i] == stretchIn[i + 1]) {
136
//				double[] auxIn = new double[stretchIn.length -1];
137
//				int[] auxOut = new int[stretchIn.length -1];
138
//				for (int j = 0; j < auxIn.length; j++) {
139
//					if(j < i) {
140
//						auxIn[j] = stretchIn[j];
141
//						auxOut[j] = stretchOut[j];
142
//					} else {
143
//						auxIn[j] = stretchIn[j + 1];
144
//						auxOut[j] = stretchOut[j + 1];
145
//					}
146
//						
147
//				}
148
//				stretchIn = auxIn;
149
//				stretchOut = auxOut;
150
//				simplified = true;
151
//			}
152
//		}
153
//		if(simplified)
154
//			simplifyStretch();
155
//	}
156
	
157
	/**
158
	 * Asigna el m?ximo y el m?nimo
159
	 * @param stats
160
	 * @param type
161
	 * @param band
162
	 */
163
	public void setMaxMin(Statistics stats, int band, boolean rgb) {
164
		try {
165
			if (rgb) {
166
				if (stats.getMinByteUnsigned() != null)
167
					minValue = stats.getMinByteUnsigned()[band];
168
				if (stats.getMaxByteUnsigned() != null)
169
					maxValue = stats.getMaxByteUnsigned()[band];
170
			} else {
171
				if (stats.getMin() != null) {
172
					minValue = stats.getMin()[band];
173
				}
174
				if (stats.getMax() != null) {
175
					maxValue = stats.getMax()[band];
176
				}
177
			}
178
			if (stretchIn == null) {
179
				stretchIn = new double[] { minValue, maxValue };
180
			} else {
181
				stretchIn[0] = minValue;
182
				stretchIn[stretchIn.length - 1] = maxValue;
183
			}
184
		} catch (ArrayIndexOutOfBoundsException ex) {
185
			// No se asigna el m?ximo o m?nimo
186
		}
187
	}
188
	
189
	/**
190
	 * Aplica el eliminado de extremos. Para ello utiliza el segundo m?ximo y m?nimo de entrada.
191
	 */
192
	public void applyRemoveEndsToStretchs(Statistics stats, boolean rgb, int band) {
193
		if(stretchIn == null)
194
			return;
195
		try {
196
			if(rgb) {
197
				if(stats.getSecondMinByteUnsigned() != null)
198
					stretchIn[0] = minValue = stats.getSecondMinByteUnsigned()[band];
199
				if(stats.getSecondMaxByteUnsigned() != null)
200
					stretchIn[stretchIn.length - 1] = maxValue = stats.getSecondMaxByteUnsigned()[band];
201
			} else {
202
				if(stats.getSecondMin() != null)
203
					stretchIn[0] = minValue = stats.getSecondMin()[band];
204
				if(stats.getMax() != null)
205
					stretchIn[stretchIn.length - 1] = maxValue = stats.getSecondMax()[band];
206
			}
207
		} catch (ArrayIndexOutOfBoundsException ex) {
208
			//No se asigna el m?ximo o m?nimo 
209
		}
210
	}
211
}
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/datastruct/DefaultStretch.java
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.datastruct;
23

  
24
import org.gvsig.fmap.dal.coverage.datastruct.Stretch;
25
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
26

  
27
public class DefaultStretch implements Stretch {
28
	/**
29
	 * Valores de los datos de entrada correspondientes al m?nimo y al m?ximo de 
30
	 * cada tramo. Estos tendr?n un rango entre el m?nimo y el m?ximo en cada banda
31
	 * de la imagen. 
32
	 */
33
	public double[]        stretchIn           = null;
34
	/**
35
	 * Valores de los datos de salida correspondientes al m?nimo y al m?ximo de 
36
	 * cada tramo. Estos tendr?n un rango entre 0 y 255.
37
	 */
38
	public int[]           stretchOut          = null;
39
	/**
40
	 * Porcentajes de recorte de colas (Valores de entrada)
41
	 */
42
	public double          tailTrimMin         = 0;
43
	public double          tailTrimMax         = 0;
44
	/**
45
	 * Valores de recorte de colas (Valores de salida calculados por el filtro TailTrim)
46
	 */
47
	public double          tailTrimValueMin    = 0;
48
	public double          tailTrimValueMax    = 0;
49
	/**
50
	 * Valores de escala a calcular por el filtro lineal por tramos.
51
	 * Cada elemento del array es un tramo.
52
	 */
53
	public double[]        scale               = null;
54
	/**
55
	 * Valores de desplazamiento a calcular por el filtro lineal por tramos.
56
	 * Cada elemento del array es un tramo.
57
	 */
58
	public double[]        offset              = null;
59
	/**
60
	 * Valores m?ximos y m?nimos
61
	 */
62
	public double          maxValue            = 0;
63
	public double          minValue            = 0;
64
	
65
	/**
66
	 * Funcion grafica que se ha usado para generar el LinearStretchParams
67
	 * 0 - Lineal
68
	 * 1 - Exponencial / Logaritmica
69
	 * 2 - Raiz cuadrada / Cuadrada
70
	 * 3 - Level slice
71
	 */
72
	public int             functionType        = 0;
73

  
74
	/**
75
	 * Valor de la gr?fica para la funci?n. No se usa en una gr?fica lineal.
76
	 */
77
	public double          valueFunction       = 0.0;
78
	
79
	/**
80
	 * Aplica el recorte de colas sobre los extremos de los m?ximos y m?nimos de entrada.
81
	 * La aplicaci?n de esta funci?n considera que ya se han calculado los valores con 
82
	 * loadTailTrimValues.
83
	 */
84
	public void applyTrimToStretchs() {
85
		if(stretchIn != null && stretchIn.length >= 2) {
86
			minValue = stretchIn[0] = tailTrimValueMin;
87
			maxValue = stretchIn[stretchIn.length - 1] = tailTrimValueMax;
88
		}
89
	}
90
	
91
	/**
92
	 * Aplica el eliminado de extremos. Para ello utiliza el segundo m?ximo y m?nimo de entrada.
93
	 */
94
	/*public void applyRemoveEndsToStretchs(double secondMin, double secondMax) {
95
		if(stretchIn != null && stretchIn.length >= 2) {
96
			minValue = stretchIn[0] = secondMin;
97
			maxValue = stretchIn[stretchIn.length - 1] = secondMax;
98
		}
99
	}*/
100
	
101
	/**
102
	 * Consulta si tiene alg?n valor el recorte de colas
103
	 * @return true si tiene valor el recorte de colas y false si no lo tiene
104
	 */
105
	public boolean hasTailTrim() {
106
		return (tailTrimMin != 0 || tailTrimMax != 0);
107
	}
108
	
109
	/**
110
	 * Calcula la escala y el desplazamiento teniendo en cuenta que
111
	 * ya tenga todos los valores de entrada asignados.
112
	 *
113
	 */
114
	public void calcLinearScaleAndOffset() {
115
		if(stretchIn != null && stretchOut != null) {
116
			//simplifyStretch();
117
			scale = new double[stretchIn.length - 1];
118
			offset = new double[stretchIn.length - 1];
119
			for (int i = 0; i < scale.length; i++) {
120
				double rgbRange = (stretchOut[i + 1] - stretchOut[i]);
121
				if((stretchIn[i + 1] - stretchIn[i]) == 0)
122
					scale[i] = 0;
123
				else
124
					scale[i] = rgbRange / (stretchIn[i + 1] - stretchIn[i]);
125
				offset[i] = stretchOut[i];
126
			}
127
		}
128
	}
129
	
130
	/**
131
	 * Elimina puntos redundantes en stretchIn y stretchOut
132
	 */
133
//	private void simplifyStretch() {
134
//		boolean simplified = false;
135
//		for (int i = 0; i < (stretchIn.length - 1); i++) {
136
//			if(stretchIn[i] == stretchIn[i + 1]) {
137
//				double[] auxIn = new double[stretchIn.length -1];
138
//				int[] auxOut = new int[stretchIn.length -1];
139
//				for (int j = 0; j < auxIn.length; j++) {
140
//					if(j < i) {
141
//						auxIn[j] = stretchIn[j];
142
//						auxOut[j] = stretchOut[j];
143
//					} else {
144
//						auxIn[j] = stretchIn[j + 1];
145
//						auxOut[j] = stretchOut[j + 1];
146
//					}
147
//						
148
//				}
149
//				stretchIn = auxIn;
150
//				stretchOut = auxOut;
151
//				simplified = true;
152
//			}
153
//		}
154
//		if(simplified)
155
//			simplifyStretch();
156
//	}
157
	
158
	/**
159
	 * Asigna el m?ximo y el m?nimo
160
	 * @param stats
161
	 * @param type
162
	 * @param band
163
	 */
164
	public void setMaxMin(Statistics stats, int band, boolean rgb) {
165
		try {
166
			if (rgb) {
167
				if (stats.getMinByteUnsigned() != null)
168
					minValue = stats.getMinByteUnsigned()[band];
169
				if (stats.getMaxByteUnsigned() != null)
170
					maxValue = stats.getMaxByteUnsigned()[band];
171
			} else {
172
				if (stats.getMin() != null) {
173
					minValue = stats.getMin()[band];
174
				}
175
				if (stats.getMax() != null) {
176
					maxValue = stats.getMax()[band];
177
				}
178
			}
179
			if (stretchIn == null) {
180
				stretchIn = new double[] { minValue, maxValue };
181
			} else {
182
				stretchIn[0] = minValue;
183
				stretchIn[stretchIn.length - 1] = maxValue;
184
			}
185
		} catch (ArrayIndexOutOfBoundsException ex) {
186
			// No se asigna el m?ximo o m?nimo
187
		}
188
	}
189
	
190
	/**
191
	 * Aplica el eliminado de extremos. Para ello utiliza el segundo m?ximo y m?nimo de entrada.
192
	 */
193
	public void applyRemoveEndsToStretchs(Statistics stats, boolean rgb, int band) {
194
		if(stretchIn == null)
195
			return;
196
		try {
197
			if(rgb) {
198
				if(stats.getSecondMinByteUnsigned() != null)
199
					stretchIn[0] = minValue = stats.getSecondMinByteUnsigned()[band];
200
				if(stats.getSecondMaxByteUnsigned() != null)
201
					stretchIn[stretchIn.length - 1] = maxValue = stats.getSecondMaxByteUnsigned()[band];
202
			} else {
203
				if(stats.getSecondMin() != null)
204
					stretchIn[0] = minValue = stats.getSecondMin()[band];
205
				if(stats.getMax() != null)
206
					stretchIn[stretchIn.length - 1] = maxValue = stats.getSecondMax()[band];
207
			}
208
		} catch (ArrayIndexOutOfBoundsException ex) {
209
			//No se asigna el m?ximo o m?nimo 
210
		}
211
	}
212

  
213
	public double[] getOffset() {
214
		return offset;
215
	}
216

  
217
	public double getMaxValue() {
218
		return maxValue;
219
	}
220

  
221
	public double getMinValue() {
222
		return minValue;
223
	}
224

  
225
	public int getFunctionType() {
226
		return functionType;
227
	}
228

  
229
	public double[] getStretchIn() {
230
		return stretchIn;
231
	}
232

  
233
	public int[] getStretchOut() {
234
		return stretchOut;
235
	}
236

  
237
	public double getValueFunction() {
238
		return valueFunction;
239
	}
240
}
0 241

  
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/datastruct/TimeInfo.java
24 24
import java.text.ParseException;
25 25
import java.text.SimpleDateFormat;
26 26
import java.util.ArrayList;
27
import java.util.Calendar;
28 27
import java.util.Date;
29 28

  
30 29
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
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/DefaultRasterFilterList.java
21 21
 */
22 22
package org.gvsig.raster.impl.grid.filter;
23 23

  
24
import java.lang.reflect.Constructor;
25
import java.lang.reflect.InvocationTargetException;
24 26
import java.util.ArrayList;
25 27
import java.util.Iterator;
26 28
import java.util.Stack;
......
574 576
		return manager.getManagerByFilterClass(c);
575 577
	}
576 578
	
579
	/*
580
	 * (non-Javadoc)
581
	 * @see org.gvsig.fmap.dal.coverage.grid.RasterFilterList#getManagerByClass(java.lang.Class)
582
	 */
583
	@SuppressWarnings("unchecked")
584
	public RasterFilterListManager getManagerByClass(Class clase) {
585
		Object obj = null;
586
		Class[] args = { RasterFilterList.class };
587
		try {
588
			Constructor hazNuevo = clase.getConstructor(args);
589
			Object[] args2 = { this };
590
			obj = hazNuevo.newInstance(args2);
591
		} catch (SecurityException e) {
592
			e.printStackTrace();
593
		} catch (NoSuchMethodException e) {
594
			e.printStackTrace();
595
		} catch (IllegalArgumentException e) {
596
			e.printStackTrace();
597
		} catch (InstantiationException e) {
598
			e.printStackTrace();
599
		} catch (IllegalAccessException e) {
600
			e.printStackTrace();
601
		} catch (InvocationTargetException e) {
602
			e.printStackTrace();
603
		}
604
		return (RasterFilterListManager)obj;
605
	}
606
	
577 607
	/**
578 608
	 * Gets a filter class searching in the register managers by its identifier
579 609
	 * @param id
......
585 615
		ExtensionPoint point = extensionPoints.get("RasterFilter");
586 616
		Iterator it = point.iterator();
587 617
		while(it.hasNext()) {
588
			Class managerClass = (Class)it.next();
589
			RasterFilterListManager manager = getManagerByFilterClass(managerClass);
590
			Class c = manager.getFilterClassByID(id);
591
			if(c != null)
592
				return c;
618
			ExtensionPoint.Extension entry = (ExtensionPoint.Extension) it.next();
619
			if (entry != null) {
620
				Class managerClass = entry.getExtension();
621
				RasterFilterListManager manager = getManagerByClass(managerClass);
622
				if(manager != null) {
623
					Class c = manager.getFilterClassByID(id);
624
					if(c != null)
625
						return c;
626
				}
627
			}
593 628
		}
594 629
		return null;
595 630
	}
......
612 647
			manager = new RasterFilterListManagerImpl(this);
613 648
		return manager.getRasterFilterList();
614 649
	}
650
	
651
	/*
652
	 * (non-Javadoc)
653
	 * @see org.gvsig.fmap.dal.coverage.grid.RasterFilterList#createEmptyFilter(java.lang.String)
654
	 */
655
	@SuppressWarnings("unchecked")
656
	public RasterFilter createEmptyFilter(String strPackage) throws FilterTypeException {
657
		Class filterClass = null;
658
		try {
659
			filterClass = Class.forName(strPackage.trim());
660
		} catch (ClassNotFoundException e) {
661
			throw new FilterTypeException("No puedo instanciar " + strPackage.trim());
662
		}
615 663

  
664
		Constructor con = null;
665
		try {
666
			con = filterClass.getConstructor();
667
		} catch (SecurityException e) {
668
			throw new FilterTypeException("");
669
		} catch (NoSuchMethodException e) {
670
			throw new FilterTypeException("");
671
		}
672

  
673
		BaseRasterFilter newFilter = null;
674
		try {
675
			newFilter = (BaseRasterFilter) con.newInstance();
676
		} catch (IllegalArgumentException e) {
677
			throw new FilterTypeException("");
678
		} catch (InstantiationException e) {
679
			throw new FilterTypeException("");
680
		} catch (IllegalAccessException e) {
681
			throw new FilterTypeException("");
682
		} catch (InvocationTargetException e) {
683
			throw new FilterTypeException("");
684
		}
685
		return newFilter;
686
	}
687

  
616 688
	/**
617 689
	 * Releases buffer resources
618 690
	 */
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/statistics/StatisticsListManager.java
42 42
 */
43 43
public class StatisticsListManager implements RasterFilterListManager {
44 44
	protected RasterFilterList			    filterList          = null;
45
	private RasterFilterListManagerImpl	    filterListManager	= null;
46 45
	private Statistics                      stats               = null;
47 46

  
48 47
	/**
......
52 51
	 * de las extensiones
53 52
	 * @param stats Estadisticas
54 53
	 */
54
	public StatisticsListManager(RasterFilterList filterList) {
55
		this.filterList = filterList;
56
		stats = (Statistics)filterList.getEnvParam("IStatistics");
57
	}
58
	
59
	/**
60
	 * Constructor. Asigna el gestor de todos los filtros y el objeto que
61
	 * contiene las estad?sticas.
62
	 * @param filterListManager Gestor general de filtros donde se registran los gestores de filtros
63
	 * de las extensiones
64
	 * @param stats Estadisticas
65
	 */
55 66
	public StatisticsListManager(RasterFilterListManagerImpl filterListManager) {
56 67
		if(filterListManager instanceof RasterFilterListManagerImpl) {
57
			this.filterListManager = (RasterFilterListManagerImpl)filterListManager;
58 68
			this.filterList = filterListManager.getFilterList();
59 69
			stats = (Statistics)filterListManager.getFilterList().getEnvParam("IStatistics");
60 70
		}
......
189 199
	public int createFilterListFromStrings(ArrayList filters, String fil, int filteri) throws FilterTypeException {
190 200
		if (fil.startsWith("filter.tail.active") && RasterFilterListManagerImpl.getValue(fil).equals("true")) {
191 201
			filters.remove(filteri);
192
			filterListManager.removeFilter(Messages.getText(TailTrimFilter.names[0]));
202
			filterList.remove(Messages.getText(TailTrimFilter.names[0]));
193 203

  
194 204
			double recorte = 0D;
195 205
			boolean remove = false;
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/band/ColorBalanceRGBManager.java
63 63
			return ColorTableFilter.class;
64 64
		return null;
65 65
	}
66
	
67
	/**
68
	 * Constructor.
69
	 * Asigna la lista de filtros.
70
	 *
71
	 * @param filterListManager
72
	 */
73
	public ColorBalanceRGBManager(RasterFilterList filterList) {
74
		this.filterList = filterList;
75
	}
66 76

  
67 77
	/**
68 78
	 * Constructor.
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/LinearStretchEnhancementIntegerFilter.java
22 22
package org.gvsig.raster.impl.grid.filter.enhancement;
23 23

  
24 24
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
25
import org.gvsig.raster.impl.datastruct.Stretch;
25
import org.gvsig.raster.impl.datastruct.DefaultStretch;
26 26
/**
27 27
 * Filtro de realce lineal para tipos de datos int. El realce es aplicado por intervalos.
28 28
 * Para cada pixel se obtiene en que intervalo se encuentra y se aplica la scala y offset
......
62 62
	 * @param iBand N?mero de banda del valor dentro del raster
63 63
	 * @return true si ha podido ser procesado y false si no lo hace
64 64
	 */
65
	private void processValue(int p, Stretch data, int col, int line, int iBand) {
65
	private void processValue(int p, DefaultStretch data, int col, int line, int iBand) {
66 66
		if(data.scale != null) {
67 67
			if (p > data.maxValue)
68 68
				p = (int) data.maxValue;
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/LinearStretchEnhancementShortFilter.java
22 22
package org.gvsig.raster.impl.grid.filter.enhancement;
23 23

  
24 24
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
25
import org.gvsig.raster.impl.datastruct.Stretch;
25
import org.gvsig.raster.impl.datastruct.DefaultStretch;
26 26
/**
27 27
 * Filtro de realce lineal para tipos de datos short. El realce es aplicado por intervalos.
28 28
 * Para cada pixel se obtiene en que intervalo se encuentra y se aplica la scala y offset
......
62 62
	 * @param iBand N?mero de banda del valor dentro del raster
63 63
	 * @return true si ha podido ser procesado y false si no lo hace
64 64
	 */
65
	private void processValue(short p, Stretch data, int col, int line, int iBand) {
65
	private void processValue(short p, DefaultStretch data, int col, int line, int iBand) {
66 66
		if (data.scale != null) {
67 67
			if (p > data.maxValue)
68 68
				p = (short) data.maxValue;
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/LinearStretchEnhancementFloatFilter.java
22 22
package org.gvsig.raster.impl.grid.filter.enhancement;
23 23

  
24 24
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
25
import org.gvsig.raster.impl.datastruct.Stretch;
25
import org.gvsig.raster.impl.datastruct.DefaultStretch;
26 26
/**
27 27
 * Filtro de realce lineal para tipos de datos float. El realce es aplicado por intervalos.
28 28
 * Para cada pixel se obtiene en que intervalo se encuentra y se aplica la scala y offset
......
62 62
	 * @param iBand N?mero de banda del valor dentro del raster
63 63
	 * @return true si ha podido ser procesado y false si no lo hace
64 64
	 */
65
	private void processValue(float p, Stretch data, int col, int line, int iBand) {
65
	private void processValue(float p, DefaultStretch data, int col, int line, int iBand) {
66 66
		if (data.scale != null) {
67 67
			if (p > data.maxValue)
68 68
				p = (float) data.maxValue;
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
32 32
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList;
33 33
import org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager;
34 34
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
35
import org.gvsig.raster.impl.datastruct.Stretch;
35
import org.gvsig.raster.impl.datastruct.DefaultStretch;
36 36
import org.gvsig.raster.impl.grid.filter.RasterFilterListManagerImpl;
37 37
import org.gvsig.raster.impl.grid.filter.statistics.StatisticsListManager;
38 38
import org.gvsig.raster.impl.store.ParamsImpl.ParamImpl;
......
53 53
	 * Constructor
54 54
	 * @param filterListManager
55 55
	 */
56
	public EnhancementStretchListManager(RasterFilterList filterList) {
57
		this.filterList = filterList;
58
		stats = (Statistics)filterList.getEnvParam("IStatistics");
59
	}
60
	
61
	/**
62
	 * Constructor
63
	 * @param filterListManager
64
	 */
56 65
	public EnhancementStretchListManager(RasterFilterListManagerImpl filterListManager) {
57 66
		this.filterListManager = filterListManager;
58 67
		this.filterList = filterListManager.getFilterList();
......
251 260
	 * @param stretch
252 261
	 */
253 262
	@SuppressWarnings("unchecked")
254
	private void putStretchBand(ArrayList filterList, String band, Stretch stretch) {
263
	private void putStretchBand(ArrayList filterList, String band, DefaultStretch stretch) {
255 264
		filterList.add("filter.linearstretchenhancement." + band + ".maxValue=" + stretch.maxValue);
256 265
		filterList.add("filter.linearstretchenhancement." + band + ".minValue=" + stretch.minValue);
257 266
		if (stretch.offset != null)
......
304 313
	 * @param stretch
305 314
	 * @return
306 315
	 */
307
	public boolean getStretchBand(String band, String property, String value, Stretch stretch) {
316
	public boolean getStretchBand(String band, String property, String value, DefaultStretch stretch) {
308 317
		if (property.startsWith("filter.linearstretchenhancement." + band)) {
309 318
			if (property.startsWith("filter.linearstretchenhancement." + band + ".maxValue")) {
310 319
				stretch.maxValue = Double.parseDouble(value);
......
574 583
		} catch (RasterDriverException e) {
575 584
			throw new FilterTypeException("", e);
576 585
		}
577
		return createEnhancedFilter(p, stats, renderBands, removeEnds.booleanValue());
586
		return createEnhancedFilter(p, stats, renderBands, removeEnds != null ? removeEnds.booleanValue() : true);
578 587
	}
579 588
}
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/DefaultLinearStretchParams.java
21 21
 */
22 22
package org.gvsig.raster.impl.grid.filter.enhancement;
23 23

  
24
import org.gvsig.fmap.dal.coverage.datastruct.Stretch;
24 25
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException;
25 26
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
26 27
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
27 28
import org.gvsig.fmap.dal.coverage.grid.filter.LinearStretchParams;
28 29
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
29
import org.gvsig.raster.impl.datastruct.Stretch;
30
import org.gvsig.raster.impl.datastruct.DefaultStretch;
30 31
/**
31 32
 * Par?metros necesarios para el filtro de realce por tramos. Contiene
32 33
 * informaci?n de cada tramo. Valores m?ximos y m?nimos reales y correspondencia
......
39 40
 * @author Nacho Brodin nachobrodin@gmail.com
40 41
 */
41 42
public class DefaultLinearStretchParams implements LinearStretchParams {
42
	public Stretch             red               = new Stretch();
43
	public Stretch             green             = new Stretch();
44
	public Stretch             blue              = new Stretch();
45
	public boolean             rgb               = false;
43
	public DefaultStretch             red               = new DefaultStretch();
44
	public DefaultStretch             green             = new DefaultStretch();
45
	public DefaultStretch             blue              = new DefaultStretch();
46
	public boolean                    rgb               = false;
46 47
			
47 48
	/*
48 49
	 * (non-Javadoc)
......
183 184
		leParams.blue.tailTrimMax = tailTrim;
184 185
		return leParams;
185 186
	}
187

  
188
	/*
189
	 * (non-Javadoc)
190
	 * @see org.gvsig.fmap.dal.coverage.grid.filter.LinearStretchParams#getRed()
191
	 */
192
	public Stretch getRed() {
193
		return red;
194
	}
195

  
196
	/*
197
	 * (non-Javadoc)
198
	 * @see org.gvsig.fmap.dal.coverage.grid.filter.LinearStretchParams#setRed(org.gvsig.fmap.dal.coverage.datastruct.Stretch)
199
	 */
200
	public void setRed(Stretch red) {
201
		this.red = (DefaultStretch)red;
202
	}
203

  
204
	/*
205
	 * (non-Javadoc)
206
	 * @see org.gvsig.fmap.dal.coverage.grid.filter.LinearStretchParams#getGreen()
207
	 */
208
	public Stretch getGreen() {
209
		return green;
210
	}
211

  
212
	/*
213
	 * (non-Javadoc)
214
	 * @see org.gvsig.fmap.dal.coverage.grid.filter.LinearStretchParams#setGreen(org.gvsig.fmap.dal.coverage.datastruct.Stretch)
215
	 */
216
	public void setGreen(Stretch green) {
217
		this.green = (DefaultStretch)green;
218
	}
219
	
220
	/*
221
	 * (non-Javadoc)
222
	 * @see org.gvsig.fmap.dal.coverage.grid.filter.LinearStretchParams#getBlue()
223
	 */
224
	public Stretch getBlue() {
225
		return blue;
226
	}
227

  
228
	/*
229
	 * (non-Javadoc)
230
	 * @see org.gvsig.fmap.dal.coverage.grid.filter.LinearStretchParams#setBlue(org.gvsig.fmap.dal.coverage.datastruct.Stretch)
231
	 */
232
	public void setBlue(Stretch blue) {
233
		this.blue = (DefaultStretch)blue;
234
	}
235

  
236
	/*
237
	 * (non-Javadoc)
238
	 * @see org.gvsig.fmap.dal.coverage.grid.filter.LinearStretchParams#isRgb()
239
	 */
240
	public boolean isRgb() {
241
		return rgb;
242
	}
243

  
244
	/*
245
	 * (non-Javadoc)
246
	 * @see org.gvsig.fmap.dal.coverage.grid.filter.LinearStretchParams#setRgb(boolean)
247
	 */
248
	public void setRgb(boolean rgb) {
249
		this.rgb = rgb;
250
	}
186 251
}
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/LinearStretchEnhancementFilter.java
30 30
import org.gvsig.fmap.dal.coverage.store.props.Statistics;
31 31
import org.gvsig.raster.impl.DefaultRasterManager;
32 32
import org.gvsig.raster.impl.buffer.cache.RasterReadOnlyBuffer;
33
import org.gvsig.raster.impl.datastruct.Stretch;
33
import org.gvsig.raster.impl.datastruct.DefaultStretch;
34 34
import org.gvsig.raster.impl.store.ParamsImpl;
35 35
/**
36 36
 * Clase base para los filtros de realzado lineal. Lee el m?nimo y m?xmo de la
......
55 55
	private boolean                    removeEnds        = false;
56 56

  
57 57
	protected DefaultLinearStretchParams      stretchs          = null;
58
	protected Stretch[]                scaleOffsetList   = null;
58
	protected DefaultStretch[]                scaleOffsetList   = null;
59 59

  
60 60
	/**
61 61
	 * Construye un LinearEnhancementFilter
......
135 135
	 * escaleOffsetList tendr? stretchs.red en las 3 posiciones.
136 136
	 */
137 137
	private void loadStretchList() {
138
		scaleOffsetList = new Stretch[3];
138
		scaleOffsetList = new DefaultStretch[3];
139 139
		scaleOffsetList[0] = stretchs.red;
140 140
		scaleOffsetList[1] = stretchs.green;
141 141
		scaleOffsetList[2] = stretchs.blue;
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/LinearStretchEnhancementByteFilter.java
22 22
package org.gvsig.raster.impl.grid.filter.enhancement;
23 23

  
24 24
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
25
import org.gvsig.raster.impl.datastruct.Stretch;
25
import org.gvsig.raster.impl.datastruct.DefaultStretch;
26 26
/**
27 27
 * Filtro de realce lineal para tipos de datos byte. El realce es aplicado por intervalos.
28 28
 * Para cada pixel se obtiene en que intervalo se encuentra y se aplica la scala y offset
......
67 67
	 * @param iBand N?mero de banda del valor dentro del raster
68 68
	 * @return true si ha podido ser procesado y false si no lo hace
69 69
	 */
70
	private void processValue(int p, Stretch data, int col, int line, int iBand) {
70
	private void processValue(int p, DefaultStretch data, int col, int line, int iBand) {
71 71
		if(data.scale != null) {
72 72
			if (p > data.maxValue)
73 73
				p = (int) data.maxValue;
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/LinearStretchEnhancementDoubleFilter.java
22 22
package org.gvsig.raster.impl.grid.filter.enhancement;
23 23

  
24 24
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
25
import org.gvsig.raster.impl.datastruct.Stretch;
25
import org.gvsig.raster.impl.datastruct.DefaultStretch;
26 26
/**
27 27
 * Filtro de realce lineal para tipos de datos double. El realce es aplicado por intervalos.
28 28
 * Para cada pixel se obtiene en que intervalo se encuentra y se aplica la scala y offset
......
62 62
	 * @param iBand N?mero de banda del valor dentro del raster
63 63
	 * @return true si ha podido ser procesado y false si no lo hace
64 64
	 */
65
	private void processValue(double p, Stretch data, int col, int line, int iBand) {
65
	private void processValue(double p, DefaultStretch data, int col, int line, int iBand) {
66 66
		if(data.scale != null) {
67 67
			if (p > data.maxValue)
68 68
				p = (double) data.maxValue;

Also available in: Unified diff