Revision 2167

View differences:

branches/gvSIG_GisPlanet/applications/appgvSIG/text.properties
40 40
Anadir_todos=A?adir Todos
41 41
Anadir_todos=A?adir todos
42 42
ancho=Ancho
43
ancho_alto=Ancho X Alto:
43 44
Ancho_Contorno=Ancho Contorno
44 45
Ancho_de_l?nea=Ancho de l?nea
45 46
anchura=Anchura:
......
107 108
Configurar_localizador=Configurar Localizador ...
108 109
confirmar_borrar=?Seguro que desea borrar el elemento?
109 110
conservar_escala_visualizacion=Conservar escala de visualizaci?n
111
coor_geograficas=Coor. Geograficas
110 112
creation_date=Fecha de creaci?n
111 113
Cruz=Cruz
112 114
Cuadrado=Cuadrado
......
134 136
Elegir_Color=Elegir Color
135 137
Elegir_Fuente=Elegir Fuente
136 138
Eliminar=Eliminar
139
eliminar_extremos=Eliminar Extremos
137 140
eliminar_capa=Eliminar Capa
138 141
Encuadre=Encuadre
139 142
Encuadre_Vista=Encuadre sobre la Vista
......
163 166
exportar_a=Exportar a...
164 167
extension=Extensi?n
165 168
Fichero=Fichero
169
Fichero_=Fichero:
166 170
fichero_existe=El fichero seleccionado ya existe como banda de la capa
167 171
filtro=Filtro
168 172
finalizar=Finalizar
169 173
Font=Fuente
174
formato=Formato:
170 175
Fuente=Fuente
171 176
fuente=Fuente
172 177
General=General
......
234 239
Linea=L?nea
235 240
linea=L?nea
236 241
linea_grafica=L?nea gr?fica
242
lineal_directo=Lineal Directo
237 243
Link=Enlace
238 244
malla_activada=Malla activada
239 245
mantener_intervalo=Mantener intervalo
......
275 281
nuevo_proyecto=Nuevo proyecto
276 282
nuevo_tamano_fuente=Nuevo tama?o de fuente: 
277 283
nuevo_tooltip=Crea un nuevo proyecto
284
num_bandas=N?mero de bandas:
278 285
N?m_intervalos=N?m. intervalos  
286
opacidad=Opacidad
279 287
ok=Ok
280 288
orientacion=Orientaci?n:
281 289
Origen_de_Datos=Origen de Datos: 
......
322 330
Quitar_todos=Quitar todos
323 331
Rango_de_escalas=Rango de escalas
324 332
Rasterfiles=Ficheros r?ster
333
recorte=% recorte
334
recorte_colas=Recorte de Colas
325 335
recorte_vista=Recorte a vista
326 336
recta=Recta
327 337
rectangulo=Rect?ngulo
......
360 370
Simbolog?a=Simbolog?a
361 371
Simbolo_unico=S?mbolo ?nico
362 372
simplificar=Simplificar
373
sin_realce=Sin Realce
363 374
sin_titulo=Sin t?tulo
364 375
sincronizar_color_borde_relleno=Sincronizar el color del borde con el del relleno:
365 376
Size=Size
......
381 392
tarea_en_progreso=Tarea en progreso
382 393
Tema=Capa
383 394
texto=Texto
395
tipo_dato=Tipo de Dato:
384 396
tipos_de_documentos=Tipos de documentos
385 397
Tipo_de_intervalos=Tipo de intervalos
386 398
Tipo_de_leyenda=Tipo de leyenda
......
400 412
unidades=Unidades:
401 413
untitled=Sin t?tulo
402 414
Un_Layer=Debe seleccionar al menos una capa.
415
usar_rango=Usa un rango: 1,3,5:8
403 416
utilizar_margenes_impresora=Utilizar m?rgenes de la impresora.
404 417
vacia=Vac?a
405 418
Valor=Valor
406 419
Valor=Valor
420
Valor_Bandas=Valor Banda: 
407 421
Valores=Valores
408 422
Valores_unicos=Valores ?nicos
409 423
Valores_?nicos=Valores ?nicos
424
Valor_azul=Valor Azul:
425
Valor_rojo=Valor Rojo:
426
Valor_verde=Valor Verde: 
410 427
ventana_proyecto=Ventana de proyecto
411 428
Ver=Ver
412 429
vertical=Vertical
......
420 437
Visualizacion=Visualizaci?n
421 438
visualizar_cuadricula=Visualizar Malla
422 439
WMS=WMS
440
xmax= - X m?xima:
441
ymax= - Y m?xima:
442
xmin= - X m?nima:
443
ymin= - Y m?nima:
423 444
Yardas=Yardas
424 445
Zoom_al_Tema=Zoom al Tema
425 446
Zoom_Completo=Zoom Completo
branches/gvSIG_GisPlanet/applications/appgvSIG/src/com/iver/cit/gvsig/gui/Panels/PropertiesRasterDialog.java
48 48

  
49 49
import java.awt.Container;
50 50
import java.awt.event.ActionEvent;
51
import java.awt.event.KeyEvent;
52
import java.awt.event.KeyListener;
53 51
import java.awt.geom.Rectangle2D;
54 52
import java.io.File;
55 53
import java.util.ArrayList;
......
65 63
import org.cresques.io.raster.RasterFilterStackManager;
66 64
import org.cresques.px.Extent;
67 65
import org.cresques.ui.raster.BandSetupPanel;
66
import org.cresques.ui.raster.EnhancedPanel;
68 67
import org.cresques.ui.raster.FilterRasterDialogPanel;
68
import org.cresques.ui.raster.RasterTransparencyPanel;
69 69

  
70 70
import com.hardcode.driverManager.Driver;
71 71
import com.hardcode.driverManager.DriverLoadException;
......
268 268
			rasterStatus = (StatusLayerRaster)fLayer.getStatus();
269 269
		initialize();
270 270
		this.setRanges(rangeR, rangeG, rangeB);
271
		setTranslation();
271 272
	}
272 273
	
273 274
	/**
275
	 * Asigna los textos a los paneles
276
	 */
277
	private void setTranslation(){
278
		this.getBandSetup().getFileList().getJButton2().setText(PluginServices.getText(this,"Anadir"));
279
		this.getBandSetup().getFileList().getJButton3().setText(PluginServices.getText(this,"Eliminar"));
280
		
281
		RasterTransparencyPanel tpan = this.getTransparencyPanel();
282
		if(tpan.nBands==1)
283
			tpan.jLabel1.setText(PluginServices.getText(this,"Valor_banda"));
284
		else
285
			tpan.jLabel1.setText(PluginServices.getText(this,"Valor_verde"));
286
		tpan.jLabel.setText(PluginServices.getText(this,"Valor_rojo"));
287
		tpan.jLabel2.setText(PluginServices.getText(this,"Valor_azul"));
288
		tpan.getTransparencyCheck().setText(PluginServices.getText(this,"transparencia"));
289
		tpan.getOpacityCheck().setText(PluginServices.getText(this,"opacidad"));
290
		tpan.jLabel3.setText(PluginServices.getText(this,"usar_rango"));
291
		
292
		EnhancedPanel ep = this.getEnhancedPanel();
293
		ep.jLabel.setText(PluginServices.getText(this,"lineal_directo"));
294
		ep.jLabel1.setText(PluginServices.getText(this,"recorte_colas"));
295
		ep.jLabel2.setText(PluginServices.getText(this,"sin_realce"));
296
		ep.jLabel4.setText(PluginServices.getText(this,"recorte"));
297
		ep.jLabel5.setText(PluginServices.getText(this,"eliminar_extremos"));
298
		
299
		
300
		
301
		
302
	}
303
	
304
	/**
274 305
	 * Asigna un FLayerRaster
275 306
	 * @param layer	capa a asignar
276 307
	 */
......
293 324
	private void loadInfoData(){
294 325
		if(fLayer.getSource()!=null){
295 326
			props = new Object[nprops][2];
296
			props[0][0] = new String("Fichero: ");
327
			props[0][0] = new String(PluginServices.getText(this,"Fichero_"));
297 328
			props[0][1] = filename;
298
			props[1][0] = new String("N?mero de Bandas: ");
329
			props[1][0] = new String(PluginServices.getText(this,"num_bandas"));
299 330
			props[1][1] = new String(String.valueOf(fLayer.getSource().getNumBands()));
300
			props[2][0] = new String("Ancho X Alto: ");
331
			props[2][0] = new String(PluginServices.getText(this,"ancho_alto"));
301 332
			props[2][1] = this.width+" X "+this.height;
302
			props[3][0] = new String("Formato: ");
333
			props[3][0] = new String(PluginServices.getText(this,"formato"));
303 334
			props[3][1] = filename.substring(
304 335
						filename.lastIndexOf('.')+1, 
305 336
						filename.length());
306
			props[4][0] = new String("Tipo de dato: ");
337
			props[4][0] = new String(PluginServices.getText(this,"tipo_dato"));
307 338
			String type = null;
308 339
			switch(fLayer.getSource().getDataType()){
309 340
				case 0: type = new String("BYTE");break;
......
315 346
				default: type = new String("UNDEFINED");break;
316 347
			}
317 348
		    props[4][1] = type;
318
			props[5][0] = new String("Coor. Geograficas");
319
			props[6][0] = new String(" - X m?nima:");
349
			props[5][0] = new String(PluginServices.getText(this,"coor_geograficas"));
350
			props[6][0] = new String(PluginServices.getText(this,"xmin"));
320 351
			props[6][1] = String.valueOf(fLayer.getSource().getFullExtent().getMinX());
321
			props[7][0] = new String(" - Y m?nima:");
352
			props[7][0] = new String(PluginServices.getText(this,"ymin"));
322 353
			props[7][1] = String.valueOf(fLayer.getSource().getFullExtent().getMinY());
323
			props[8][0] = new String(" - X m?xima:");
354
			props[8][0] = new String(PluginServices.getText(this,"xmax"));
324 355
			props[8][1] = String.valueOf(fLayer.getSource().getFullExtent().getMaxX());
325
			props[9][0] = new String(" - Y m?xima:");
356
			props[9][0] = new String(PluginServices.getText(this,"ymax"));
326 357
			props[9][1] = String.valueOf(fLayer.getSource().getFullExtent().getMaxY());
327 358
			
328 359
		}else{
......
534 565
			if(	this.getEnhancedPanel().getLinealDirectoRadioButton().isSelected()){
535 566
				if(	this.getEnhancedPanel().getRemoveCheck().isSelected() &&
536 567
					!this.getEnhancedPanel().getTailCheck().isSelected())
537
					stackManager.addEnhancedFilter(true);
568
					stackManager.addEnhancedFilter(true, fLayer.getSource().getFiles()[0].getName());
538 569
				else
539
					stackManager.addEnhancedFilter(false);
570
					stackManager.addEnhancedFilter(false, fLayer.getSource().getFiles()[0].getName());
540 571
				
541 572
				//Recorte de colas seleccionado
542 573
				if(this.getEnhancedPanel().getTailCheck().isSelected()){
branches/gvSIG_GisPlanet/applications/appgvSIG/src/com/iver/cit/gvsig/RasterizerLayer.java
51 51
import java.awt.Graphics2D;
52 52
import java.awt.geom.Rectangle2D;
53 53
import java.awt.image.BufferedImage;
54
import java.util.ArrayList;
54 55

  
55 56
import javax.swing.JProgressBar;
56 57

  
57 58
import org.cresques.io.Rasterizer;
59
import org.cresques.io.raster.RasterBuf;
60
import org.cresques.io.raster.RasterStats;
61
import org.cresques.io.raster.RasterStats.History;
58 62

  
59 63
import com.iver.cit.gvsig.fmap.DriverException;
60 64
import com.iver.cit.gvsig.fmap.MapControl;
61 65
import com.iver.cit.gvsig.fmap.ViewPort;
62 66
import com.iver.cit.gvsig.fmap.layers.FLayers;
67
import com.iver.cit.gvsig.fmap.layers.FLyrRaster;
63 68
import com.iver.cit.gvsig.fmap.operations.Cancellable;
64 69

  
65 70
/**
......
78 83
	private Color			backgroundColor = null;
79 84
	private JProgressBar	progressBar = null;
80 85
	private double			incrProgressBar = 0;
81
	
86
	private boolean			firstRead = true;
87
    private int 			nBlocks = 0;
88
 	
82 89
	/**
83 90
	 * Calculo del viewPort
84 91
	 * @param vp
......
131 138

  
132 139
		calcViewPort(viewPort);
133 140
		
134
		int nBlocks = (int)(vp.getImageHeight()/sizeBlock);
141
		nBlocks = (int)(vp.getImageHeight()/sizeBlock);
135 142
		incrProgressBar = 100.0/((double)nBlocks);
136
		System.out.println("===>NBLOCKS="+nBlocks+" INCR="+incrProgressBar);
143
		//System.out.println("===>NBLOCKS="+nBlocks+" INCR="+incrProgressBar);
137 144
		
138 145
		//Tama?o de ?ltimo bloque en pixeles
139 146
		lastBlock = Math.round(vp.getImageHeight()-(nBlocks*sizeBlock));
......
162 169
			g.setColor(backgroundColor);
163 170
			g.fillRect(0, 0, viewPortBlock.getImageWidth(), viewPortBlock.getImageHeight());
164 171
			try{
172
				//Si es la primera lectura salvamos los valores de m?ximo y m?nimo para la aplicaci?n
173
				//de realce si la imagen es de 16 bits.
174
				if(firstRead){
175
					for(int i=0;i<flayers.getLayersCount();i++){
176
						if(flayers.getLayer(i) instanceof FLyrRaster){
177
							FLyrRaster raster = (FLyrRaster)flayers.getLayer(i);
178
							if(	raster.getSource().getDataType() == RasterBuf.TYPE_SHORT || 
179
								raster.getSource().getDataType() == RasterBuf.TYPE_USHORT){
180
								RasterStats stats = raster.getSource().getFilterStack().getStats();
181
								stats.history.add(stats.new History(raster.getName(), stats.minBandValue, stats.maxBandValue, stats.secondMinBandValue, stats.secondMaxBandValue));	
182
							}	
183
						}
184
					}
185
					firstRead = false;
186
				}
187
				
165 188
				flayers.draw(img, g, viewPortBlock,new Cancellable() {
166 189
					public boolean isCanceled() {
167 190
						return false;
168 191
					}
169 192
				});
193
									
194
				//Si es el ?ltimo bloque vaciamos el historial de m?ximos y m?nimos
195
				if((contBlocks+1)==nBlocks){
196
					for(int i=0;i<flayers.getLayersCount();i++){
197
						if(flayers.getLayer(i) instanceof FLyrRaster){
198
							FLyrRaster raster = (FLyrRaster)flayers.getLayer(i);
199
							if(	raster.getSource().getDataType() == RasterBuf.TYPE_SHORT || 
200
								raster.getSource().getDataType() == RasterBuf.TYPE_USHORT){
201
								raster.getSource().getFilterStack().getStats().history.clear();
202
								RasterStats stats = raster.getSource().getFilterStack().getStats();
203
							}
204
						}
205
					}
206
				}
207
					
208
				
170 209
			}catch (DriverException e) {
171 210
				e.printStackTrace();
172 211
			}
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/raster/EnhancedPanel.java
86 86
	private JRadioButton jRadioButton = null;
87 87
	private JRadioButton jRadioButton1 = null;
88 88
	private JCheckBox jCheckBox = null;
89
	private JLabel jLabel = null;
90
	private JLabel jLabel2 = null;
91
	private JPanel jPanel4 = null;
89
	public JLabel jLabel = null;
90
	public JLabel jLabel2 = null;
91
	public JPanel jPanel4 = null;
92 92
	private	ButtonGroup grupo= new ButtonGroup();
93 93
	private Image iconoLineal = null;
94 94
	private Image iconoSinRealce = null;
......
100 100
	
101 101
	private JPanel jPanel6 = null;
102 102
	private JCheckBox jCheckBox1 = null;
103
	private JLabel jLabel4 = null;
104
	private JPanel jPanel7 = null;
105
	private JLabel jLabel1 = null;
106
	private JPanel jPanel8 = null;
107
	private JPanel jPanel9 = null;
108
	private JLabel jLabel5 = null;
103
	public JLabel jLabel4 = null;
104
	public JPanel jPanel7 = null;
105
	public JLabel jLabel1 = null;
106
	public JPanel jPanel8 = null;
107
	public JPanel jPanel9 = null;
108
	public JLabel jLabel5 = null;
109 109
	public EnhancedPanel(FilterRasterDialogPanel parent){
110 110
		this.parent = parent;
111 111
		
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/raster/RasterTransparencyPanel.java
19 19
	
20 20
	String 						nom = "Transparencia";
21 21
	FilterRasterDialogPanel 	parent = null;
22
	private int 				nBands = 3;
22
	public int 					nBands = 3;
23 23
	private String[]			nameBands = {"Rojo","Verde","Azul"};				
24 24
	
25 25
	private JPanel jPanel = null;
......
27 27
	private JPanel jPanel2 = null;
28 28
	private JPanel jPanel3 = null;
29 29
	private JCheckBox cbTransparencia = null;
30
	private JLabel jLabel = null;
30
	public JLabel jLabel = null;
31 31
	private JTextField tRojo = null;
32
	private JLabel jLabel1 = null;
32
	public JLabel jLabel1 = null;
33 33
	private JTextField tVerde = null;
34
	private JLabel jLabel2 = null;
34
	public JLabel jLabel2 = null;
35 35
	private JTextField tAzul = null;
36
	private JPanel jPanel4 = null;
36
	public JPanel jPanel4 = null;
37 37
	private JCheckBox cbOpacidad = null;
38 38
	private JSlider slOpacidad = null;
39 39
	private JTextField tOpacidad = null;
40 40
	private JPanel jPanel5 = null;
41
	private JLabel jLabel3 = null;
41
	public JLabel jLabel3 = null;
42 42
	
43 43
	public RasterTransparencyPanel(FilterRasterDialogPanel parent){
44 44
		this.parent = parent;
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/raster/FileList.java
54 54
	public JButton getJButton2() {
55 55
		if (jButton2 == null) {
56 56
			jButton2 = new JButton("A?adir");
57
			//jButton2.setText(PluginServices.getText(this, "Anadir"));
58
			jButton2.setPreferredSize(new java.awt.Dimension(72,25));
57
			jButton2.setPreferredSize(new java.awt.Dimension(80,25));
59 58
		}
60 59
		return jButton2;
61 60
	}
......
67 66
	public JButton getJButton3() {
68 67
		if (jButton3 == null) {
69 68
			jButton3 = new JButton("Eliminar");
70
			//jButton3.setText(PluginServices.getText(this, "Eliminar"));
71
			jButton3.setPreferredSize(new java.awt.Dimension(72,25));
69
			jButton3.setPreferredSize(new java.awt.Dimension(80,25));
72 70
		}
73 71
		return jButton3;
74 72
	}
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/raster/LinearEnhancementImageFilter.java
20 20
		this.image = (Image)params.get("raster");
21 21
		this.stats = (RasterStats)params.get("stats");
22 22
		this.removeExtrema = ((Boolean)params.get("remove")).booleanValue();
23
		this.filename = (String)params.get("filename");
23 24
		height = image.getHeight(null);
24 25
		width = image.getWidth(null);
25 26
		super.pre();
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/raster/LinearEnhancementShortFilter.java
21 21
		this.raster = (RasterBuf)params.get("raster");
22 22
		this.stats = (RasterStats)params.get("stats");
23 23
		this.removeExtrema = ((Boolean)params.get("remove")).booleanValue();
24
		this.filename = (String)params.get("filename");
24 25
		height = raster.getHeight();
25 26
		width = raster.getWidth();
26 27
		super.pre();
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/raster/RasterFilter.java
21 21
	protected Hashtable 	params = new Hashtable();
22 22
	protected int			incX = 1;
23 23
	protected int			incY = 1;
24
	protected boolean		exec = true;	//Si est? a false no se ejecuta el  filtro
24 25
		
25 26
	public RasterFilter(){}
26 27
	
......
29 30
	 */
30 31
	public void execute() {
31 32
		pre();
32
		for (int y=0; y<height; y=y+incY)
33
			for (int x=0; x<width; x=x+incX) {
34
				process(x, y);
35
			}
33
		if(exec){
34
			for (int y=0; y<height; y=y+incY)
35
				for (int x=0; x<width; x=x+incX) {
36
					process(x, y);
37
				}
38
		}
36 39
		post();
37 40
	}
38 41
	
......
40 43
	 * Aplica el filtro sobre el raster pasado por lineas
41 44
	 */
42 45
	public void executeLines() {
43
		for (int y=0; y<height; y++)
44
			processLine(y);
46
		if(exec){
47
			for (int y=0; y<height; y++)
48
				processLine(y);
49
		}
45 50
	}
46 51
	
47 52
	/**
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/raster/PercentTailTrimFilter.java
47 47
package org.cresques.io.raster;
48 48

  
49 49
import java.awt.Image;
50
import java.util.ArrayList;
50 51

  
51 52
/**
52 53
 * @author Nacho Brodin <brodin_ign@gva.es>
......
71 72
	
72 73
	//Par?metros del filtro
73 74
	protected	double		tailPercent = 0D;
74
	public double			percentSamples = 0D;		
75
	public double			percentSamples = 0D;	
76
	protected ArrayList		fileList = new ArrayList();
75 77
	
78
	
76 79
	public PercentTailTrimFilter(){}
77 80
		
78 81
	/**
......
85 88
		this.tailPercent = ((Double)params.get("tail")).doubleValue();
86 89
		this.percentSamples = ((Double)params.get("samples")).doubleValue();
87 90
		this.removeMaxValue = ((Boolean)params.get("remove")).booleanValue();
88
		this.stats.tailPercent = this.tailPercent;
89
		count = 0;
90 91
		
91
		if(this.percentSamples == 0){	//Se toman todos los pixeles de la imagen 
92
			nSamples = height*width;
93
			sample = new int[3][height*width];
94
			tailSize = (int) Math.round(this.tailPercent*nSamples);
95
		}else{		//Se toma un porcentaje de pixeles de la imagen para el calculo
96
			incX = (int)Math.round(width/(int)Math.round(this.percentSamples*width));
97
			incY = (int)Math.round(height/(int)Math.round(this.percentSamples*height));
98
			nSamples = (int)((Math.round(width/incX)+1)*(Math.round(height/incY)+1));
99
			sample = new int[3][nSamples];
100
			tailSize = (int) (nSamples * this.tailPercent);
92
		if(exec){
93
			this.stats.tailPercent = this.tailPercent;
94
			count = 0;
95
			
96
			if(this.percentSamples == 0){	//Se toman todos los pixeles de la imagen 
97
				nSamples = height*width;
98
				sample = new int[3][height*width];
99
				tailSize = (int) Math.round(this.tailPercent*nSamples);
100
			}else{		//Se toma un porcentaje de pixeles de la imagen para el calculo
101
				incX = (int)Math.round(width/(int)Math.round(this.percentSamples*width));
102
				incY = (int)Math.round(height/(int)Math.round(this.percentSamples*height));
103
				nSamples = (int)((Math.round(width/incX)+1)*(Math.round(height/incY)+1));
104
				sample = new int[3][nSamples];
105
				tailSize = (int) (nSamples * this.tailPercent);
106
			}
101 107
		}
102 108
	}
103 109
	
104 110
	/**
105
	 * Ordena las muestras , recorta y asigna m?ximo y m?nimo dependiendo del porcentaje de recorte
111
	 * Ordena las muestras , recorta y asigna m?ximo y m?nimo dependiendo del porcentaje 
112
	 * de recorte
106 113
	 */
107 114
	public void post(){
108
		QuickSort q = new QuickSort();
109
		
110
		int posInit = 0;
111
		int posFin = sample[0].length-1;
112
		
113
		//Ordenamos los vectores
114
		for (int i=0; i<3; i++) 
115
			q.quicksort(sample[i]);
116
		
117
		//Si est? marcada la opci?n removeMaxValue se calcula la posici?n en la que el m?ximo valor
118
		//y el m?nimo ya no estan, teniendo as? un subconjunto del vector que elimina estos valores
119
		
120
		if(removeMaxValue){
121
			for(int i=0; i<sample[0].length;i++){
122
				if(	sample[0][i]!=sample[0][0] ||
123
					sample[1][i]!=sample[1][0] ||
124
					sample[2][i]!=sample[2][0]){
125
					posInit = i;
126
					break;
115
		if(exec){
116
			QuickSort q = new QuickSort();
117
			
118
			int posInit = 0;
119
			int posFin = sample[0].length-1;
120
			
121
			//Ordenamos los vectores
122
			for (int i=0; i<3; i++) 
123
				q.quicksort(sample[i]);
124
			
125
			//Si est? marcada la opci?n removeMaxValue se calcula la posici?n en la que el m?ximo valor
126
			//y el m?nimo ya no estan, teniendo as? un subconjunto del vector que elimina estos valores
127
			
128
			if(removeMaxValue){
129
				for(int i=0; i<sample[0].length;i++){
130
					if(	sample[0][i]!=sample[0][0] ||
131
						sample[1][i]!=sample[1][0] ||
132
						sample[2][i]!=sample[2][0]){
133
						posInit = i;
134
						break;
135
					}
127 136
				}
128
			}
129
			for(int i=sample[0].length-1; i>0;i--){
130
				if(	sample[0][i]!=sample[0][sample[0].length-1] ||
131
					sample[1][i]!=sample[1][sample[0].length-1] ||
132
					sample[2][i]!=sample[2][sample[0].length-1]){
133
					posFin = i;
134
					break;
137
				for(int i=sample[0].length-1; i>0;i--){
138
					if(	sample[0][i]!=sample[0][sample[0].length-1] ||
139
						sample[1][i]!=sample[1][sample[0].length-1] ||
140
						sample[2][i]!=sample[2][sample[0].length-1]){
141
						posFin = i;
142
						break;
143
					}
135 144
				}
145
				
146
				//Calculamos de nuevo el n?mero de muestras ya que hemos quitado los valores m?ximo y m?nimo
147
				nSamples = posFin-posInit;
148
				
149
				//Como ha podido cambiar nSamples recalculamos tailsize
150
				tailSize = (int) (nSamples * this.tailPercent);
136 151
			}
137 152
			
138
			//Calculamos de nuevo el n?mero de muestras ya que hemos quitado los valores m?ximo y m?nimo
139
			nSamples = posFin-posInit;
140
			
141
			//Como ha podido cambiar nSamples recalculamos tailsize
142
			tailSize = (int) (nSamples * this.tailPercent);
153
			//Ordenamos los elementos y cogemos el minimo y m?ximo para cada banda
154
			for (int i=0; i<3; i++) {
155
				stats.minBandValue[i] = sample[i][posInit+tailSize];
156
				stats.maxBandValue[i] = sample[i][posInit+nSamples - tailSize - 1];
157
			}
143 158
		}
144
		
145
		//Ordenamos los elementos y cogemos el minimo y m?ximo para cada banda
146
		for (int i=0; i<3; i++) {
147
			stats.minBandValue[i] = sample[i][posInit+tailSize];
148
			stats.maxBandValue[i] = sample[i][posInit+nSamples - tailSize - 1];
149
		}
150 159
	}
151 160
	
152 161
	
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/raster/RasterStats.java
3 3
 */
4 4
package org.cresques.io.raster;
5 5

  
6
import java.util.ArrayList;
7

  
6 8
/**
7 9
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
8 10
 */
9 11
public class RasterStats {
12
	public class History{
13
		public String file = null;
14
		public int[] min = null;
15
		public int[] max = null;
16
		public int[] secMin = null;
17
		public int[] secMax = null;
18
		
19
		public History(String file, int[] min, int[] max, int[] secMin, int[] secMax){
20
			this.file = file;
21
			this.min = (int[])min.clone();
22
			this.max = (int[])max.clone();
23
			this.secMin = (int[])secMin.clone();
24
			this.secMax = (int[])secMax.clone();
25
		}
26
	}
27
	
10 28
	public int [] 	minBandValue = {Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE};
11 29
	public int [] 	maxBandValue = {Integer.MIN_VALUE,Integer.MIN_VALUE,Integer.MIN_VALUE};
12 30
	public int [] 	secondMinBandValue = {Integer.MAX_VALUE,Integer.MAX_VALUE,Integer.MAX_VALUE};
13 31
	public int [] 	secondMaxBandValue = {Integer.MIN_VALUE,Integer.MIN_VALUE,Integer.MIN_VALUE};
32
	
33
	public ArrayList history = new ArrayList();
14 34

  
15 35
	public double	tailPercent = 0D;					//porcentaje de recorte de colas 
16 36
	
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/raster/PercentTailTrimImageFilter.java
1 1
/*
2
 * Created on 31-mar-2005
2
 * Created on 16-may-2005
3 3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Style - Code Templates
4
 * To change the template for this generated file go to
5
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
6 6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
7 47
package org.cresques.io.raster;
8 48

  
9 49
import java.awt.Image;
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/raster/LinearEnhancementFilter.java
1 1
/*
2
 * Created on 25-feb-2005
2
 * Created on 17-feb-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
3 6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
4 47
package org.cresques.io.raster;
5 48

  
6
import java.awt.Image;
7 49

  
8 50
/**
9
 * Realzado Lineal (Amplitude Rescaling).
10
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
51
 * Clase base para los filtros de realzado lineal. Lee el m?nimo y m?xmo de la clase
52
 * RasterStats que ser?n calculados por PercentTailTrimFilter o ComputeMinMaxFilter dependiendo
53
 * de si est? activado el recorte de colas o no. En RasterStats tambi?n est?n los segundos 
54
 * valores despu?s del m?nimo y m?ximo que son los que se utilizan con la opci?n eliminar 
55
 * extremos activada. Estos se usaran en vez del m?nimo y m?ximo cuando la variable 
56
 * removeExtrema est? a true.
11 57
 */
12 58
public abstract class LinearEnhancementFilter extends RasterFilter {
13 59
	protected double [] scale = new double[3];
......
15 61
	protected int [] 	minBandValue = null;
16 62
	protected int [] 	maxBandValue = null;
17 63
	protected boolean	removeExtrema = false;
64
	protected String	filename = null;
18 65
	
19 66
	public LinearEnhancementFilter(){
20 67
		super();
21 68
	}
22 69
		
23 70
	public void pre(){
24
		if(removeExtrema){
25
			this.minBandValue = stats.secondMinBandValue;
26
			this.maxBandValue = stats.secondMaxBandValue;
27
			System.out.println("L27 LINEARENHANCEMENTFILTER ELIMINAR EXTREMOS ACTIVO="+minBandValue[0]+" "+maxBandValue[0]+" "+minBandValue[1]+" "+maxBandValue[1]+" "+minBandValue[2]+" "+maxBandValue[2]);
28
		}else{
29
			this.minBandValue = stats.minBandValue;
30
			this.maxBandValue = stats.maxBandValue;
31
			System.out.println("L31 LINEARENHANCEMENTFILTER ELIMINAR EXTREMOS NO ACTIVO="+minBandValue[0]+" "+maxBandValue[0]+" "+minBandValue[1]+" "+maxBandValue[1]+" "+minBandValue[2]+" "+maxBandValue[2]);
71
		if(removeExtrema){	//Si est? activado eliminar extremos gastamos el 2? m?ximo/m?nimo
72
			if(filename!=null && !filename.equals("")){
73
				for(int i=0;i<stats.history.size();i++){
74
					RasterStats.History history = (RasterStats.History)stats.history.get(i);
75
					if(history.file.equals(filename.substring((filename.lastIndexOf("/")+1), filename.length()))){
76
						this.minBandValue = history.secMin;
77
						this.maxBandValue = history.secMax;
78
					}
79
				}
80
			}
81
			if(this.minBandValue == null || this.maxBandValue == null){
82
				this.minBandValue = stats.secondMinBandValue;
83
				this.maxBandValue = stats.secondMaxBandValue;
84
			}
85
		}else{				//Si no est? activado eliminar extremos
86
			if(filename!=null && !filename.equals("")){
87
				for(int i=0;i<stats.history.size();i++){
88
					RasterStats.History history = (RasterStats.History)stats.history.get(i);
89
					if(history.file.equals(filename.substring((filename.lastIndexOf("/")+1), filename.length()))){
90
						this.minBandValue = history.min;
91
						this.maxBandValue = history.max;
92
					}
93
				}
94
			}
95
			if(this.minBandValue == null || this.maxBandValue == null){
96
				this.minBandValue = stats.minBandValue;
97
				this.maxBandValue = stats.maxBandValue;
98
			}
32 99
		}
33 100
		for (int i=0; i<3; i++) {
34 101
			scale[i] = 255D/(maxBandValue[i]-minBandValue[i]);
......
36 103
		}
37 104
	}
38 105
	
39
	
40
	/*public LinearEnhancementFilter(RasterBuf raster, RasterStats stats) {
41
	super(raster, stats);
42
	for (int i=0; i<3; i++) {
43
		scale[i] = 255D/(stats.maxBandValue[i]-stats.minBandValue[i]);
44
		offset[i] = (255D*stats.minBandValue[i])/(stats.minBandValue[i]-stats.maxBandValue[i]);
45
	}
46
	execute();
47
	}
48

  
49
	public LinearEnhancementFilter(Image image, RasterStats stats) {
50
	super(image, stats);
51
	for (int i=0; i<3; i++) {
52
		scale[i] = 255D/(stats.maxBandValue[i]-stats.minBandValue[i]);
53
		offset[i] = (255D*stats.minBandValue[i])/(stats.minBandValue[i]-stats.maxBandValue[i]);
54
	}
55
	execute();
56
	}*/	
57
	
58 106
	/**
59 107
	 * Obtiene true si est? activado el flag de eliminar extremos y false si no lo est?
60 108
	 */
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/io/raster/RasterFilterStackManager.java
1 1
/*
2
 * Created on 17-feb-2004
2
 * Created on 17-may-2005
3 3
 *
4 4
 * To change the template for this generated file go to
5 5
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
......
222 222
	}
223 223
	
224 224
	/**
225
	 * A?ade un filtro de recorte de colas
225
	 * A?ade un filtro de recorte de colas.
226 226
	 * @param tail	porcentaje de recorte
227 227
	 * @param samples	porcentaje de muestras tomadas del total de la imagen
228 228
	 */
......
241 241
		filtro.addParam("tail", new Double(tail));
242 242
		filtro.addParam("samples", new Double(samples));
243 243
		filtro.addParam("remove", new Boolean(removeMaxValue));
244
		
244 245
		filterStack.addFilter(((Integer)typeFilters.get("tail")).intValue(), filtro);
245 246
		this.controlTypes();
246 247
	}
247 248
	
248 249
	/**
249
	 * A?ade un filtro de realce
250
	 * A?ade un filtro de realce. Esta versi?n tiene el par?metro para a?adirle el nombre
251
	 * del fichero. Esto se usa para que si a un fichero se le ha calculado ya el recorte de colas
252
	 * no se vuelva a calcular, evitando as? que si hacemos un draw a una imagen por bloques cada
253
	 * bloque tenga un calculo distinto para el recorte.
250 254
	 */
251
	public void addEnhancedFilter(boolean remove){
255
	public void addEnhancedFilter(boolean remove, String fileName){
252 256
		if(filterStack.isActive(((Integer)typeFilters.get("enhanced")).intValue()))
253 257
			filterStack.removeFilter(((Integer)typeFilters.get("enhanced")).intValue());
254 258
				
......
264 268
			filtro.addParam("remove", new Boolean(true));
265 269
		else
266 270
			filtro.addParam("remove", new Boolean(false));
271
		if(fileName != null)
272
			filtro.addParam("filename", fileName);
273
		else
274
			filtro.addParam("filename", new String(""));
267 275
		filterStack.addFilter(((Integer)typeFilters.get("enhanced")).intValue(), filtro);
268 276
		this.controlTypes();
269 277
	}
270 278
	
271 279
	/**
280
	 * A?ade un filtro de realce
281
	 */
282
	public void addEnhancedFilter(boolean remove){
283
		addEnhancedFilter( remove, "");
284
	}
285
	
286
	/**
272 287
	 * A?ade un filtro ComputeMinMax
273 288
	 */
274 289
	public void addComputeMinMaxFilter(){
branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/px/PxRaster.java
1 1
/*
2
 * PxRaster.java
2
 * Created on 17-feb-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
3 6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
4 47
package org.cresques.px;
5 48

  
6 49
import java.awt.Color;
......
22 65
import org.cresques.io.GdalFile;
23 66
import org.cresques.io.GeoRasterFile;
24 67
import org.cresques.io.raster.RasterBuf;
68
import org.cresques.io.raster.RasterFilter;
25 69
import org.cresques.io.raster.RasterFilterStack;
26 70
import org.cresques.io.raster.RasterFilterStackManager;
27 71
import org.cresques.io.raster.RasterStats;
......
785 829
				//Si la imagen es de 16 bits lleva un filtro de realce por defecto
786 830
				if(stackManager == null){
787 831
					stackManager = new RasterFilterStackManager(filterStack);
788
					stackManager.addEnhancedFilter(false);
832
					stackManager.addEnhancedFilter(false, geoFile[0].getName());
789 833
					stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
790 834
					stackManager.addTailFilter( this.percentFilterInit, 0D, false);								
791 835
				}

Also available in: Unified diff