Revision 5247

View differences:

trunk/extensions/extRasterTools/src/org/gvsig/rasterTools/brightnessContrast/ui/CheckSliderText.java
65 65
		
66 66
	}
67 67
	
68
	public boolean isSelected(){
69
		return this.getJCheckBox().isSelected();
70
	}
71
	
68 72
	public void actionPerformed(ActionEvent e) {
69 73
		if (e.getSource() == getJCheckBox()){
70 74
			this.lName.setEnabled(getJCheckBox().isSelected());
......
72 76
		}
73 77
	}
74 78

  
79
	public void setSelected(boolean value){
80
		this.getJCheckBox().setSelected(value);
81
	}
82
	
75 83
}
trunk/extensions/extRasterTools/src/org/gvsig/rasterTools/brightnessContrast/ui/SliderTextPanel.java
124 124
			jTextField = new JTextField();
125 125
			jTextField.setPreferredSize(new java.awt.Dimension(3,19));
126 126
			jTextField.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT);
127
			jTextField.setText(String.valueOf(this.jSlider.getValue()));
127
			jTextField.setText(String.valueOf((double)this.jSlider.getValue()));
128 128
		}
129 129
		return jTextField;
130 130
	}
131 131

  
132 132
	/**
133 133
	 * Pone una cadena con el tipo de unidad del cuadro de texto entre el slider
134
	 * y el cudro.
134
	 * y el TextField.
135 135
	 * @param cadena a poner entre el slider y el cudro de texto.
136 136
	 */
137 137
	
......
171 171
	 * como parametro
172 172
	 * @param value: valor que aparecera en el campo de texto.
173 173
	 */
174
	public void setTextValue(int value){
175
		this.getJTextField().setText(String.valueOf(value));
174
	public void setTextValue(String value){
175
		this.getJTextField().setText(value);
176 176
	}
177 177

  
178
	/**
179
	 * Devuelve el valor actual del campo de texto
180
	 * @return: valor del campo de texto.
181
	 */
182
	public String getTextValue(){
183
		return this.jTextField.getText();
184
	}
185
	
178 186
	public void stateChanged(ChangeEvent e) {
179 187
		if(e.getSource() == this.jSlider){
180 188
			this.jTextField.setText(String.valueOf(this.jSlider.getValue()));
......
208 216
		
209 217
	}
210 218
	
211
	/**
212
	 * Devuelve el valor actual del campo de texto
213
	 * @return: valor del campo de texto.
214
	 */
215
	public int getTextValue(){
216
		return Integer.valueOf(this.getJTextField().getText()).intValue();
217
	}
218 219
}
trunk/extensions/extRasterTools/src/org/gvsig/rasterTools/brightnessContrast/ui/EnhancedBrightnessContrastPanel.java
4 4
import java.awt.GridBagLayout;
5 5
import java.awt.event.ActionEvent;
6 6
import java.awt.event.ActionListener;
7
import java.awt.event.MouseEvent;
8
import java.awt.event.MouseListener;
7 9

  
8
import javax.swing.JButton;
9 10
import javax.swing.JCheckBox;
10 11
import javax.swing.JLabel;
11 12
import javax.swing.JPanel;
......
29 30
 *
30 31
 */
31 32
public class EnhancedBrightnessContrastPanel extends JPanel implements ActionListener,
33
																	MouseListener,
32 34
																	IRasterPropertiesRegistrable,
33 35
																	IRasterOperationsRegistrablePanels{
34 36

  
......
41 43
	private JPanel jPanel1 = null;
42 44
	private JCheckBox cBrightC = null;
43 45
	private JLabel lBrightC = null;
44
	private JButton jButton = null;
45 46
	private JPanel pEnCheck = null;
46 47
	private JPanel pEnSlider = null;
47 48
	private JCheckBox cEnhanced = null;
......
51 52
	private CheckSliderText cstEnhanced = null;
52 53
	private JLabel jLabel = null;
53 54
	private BrightnessContrastStackManager bcManager = null;
55
	private JCheckBox jCheckBox1 = null;
56
	private JLabel jLabel1 = null;
54 57

  
55 58
	/**
56 59
	 * This is the default constructor
......
220 223
	 */
221 224
	private JPanel getJPanel1() {
222 225
		if (jPanel1 == null) {
226
			GridBagConstraints gridBagConstraints19 = new GridBagConstraints();
227
			gridBagConstraints19.gridx = 1;
228
			gridBagConstraints19.gridy = 0;
229
			jLabel1 = new JLabel();
230
			jLabel1.setText("Previsualizaci?n");
231
			jLabel1.setPreferredSize(new java.awt.Dimension(150,15));
232
			jLabel1.setSize(new java.awt.Dimension(160,15));
223 233
			GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
224
			gridBagConstraints10.insets = new java.awt.Insets(0,0,0,140);
234
			gridBagConstraints10.gridx = 0;
235
			gridBagConstraints10.insets = new java.awt.Insets(0,0,0,0);
225 236
			gridBagConstraints10.gridy = 0;
226
			gridBagConstraints10.anchor = java.awt.GridBagConstraints.CENTER;
227
			gridBagConstraints10.gridx = 0;
228 237
			jPanel1 = new JPanel();
229 238
			jPanel1.setLayout(new GridBagLayout());
230
			jPanel1.setPreferredSize(new java.awt.Dimension(180,30));
231
			jPanel1.add(getJButton(), gridBagConstraints10);
239
			jPanel1.setPreferredSize(new java.awt.Dimension(180,25));
240
			jPanel1.add(getJCheckBox1(), gridBagConstraints10);
241
			jPanel1.add(jLabel1, gridBagConstraints19);
232 242
		}
233 243
		return jPanel1;
234 244
	}
......
246 256
	}
247 257

  
248 258
	/**
249
	 * This method initializes jButton	
250
	 * 	
251
	 * @return javax.swing.JButton	
252
	 */
253
	private JButton getJButton() {
254
		if (jButton == null) {
255
			jButton = new JButton();
256
			jButton.setPreferredSize(new java.awt.Dimension(22,22));
257
		}
258
		return jButton;
259
	}
260

  
261
	/**
262 259
	 * This method initializes jPanel	
263 260
	 * 	
264 261
	 * @return javax.swing.JPanel	
......
316 313
	 * 	
317 314
	 * @return javax.swing.JCheckBox	
318 315
	 */
319
	private JCheckBox getCEnhanced() {
316
	public JCheckBox getCEnhanced() {
320 317
		if (cEnhanced == null) {
321 318
			cEnhanced = new JCheckBox();
322 319
		}
......
354 351
	 * 	
355 352
	 * @return javax.swing.JCheckBox	
356 353
	 */
357
	private JCheckBox getJCheckBox() {
354
	public JCheckBox getJCheckBox() {
358 355
		if (jCheckBox == null) {
359 356
			jCheckBox = new JCheckBox();
360 357
		}
361 358
		return jCheckBox;
362 359
	}
363 360
	
364
	private CheckSliderText getCheckSliderText(){
361
	public CheckSliderText getCheckSliderText(){
365 362
		String rcName = "Recortar Colas ( % )"; 
366 363
		if (cstEnhanced == null){
367 364
			cstEnhanced = new CheckSliderText();
368 365
			cstEnhanced.setName(rcName);
369 366
			cstEnhanced.setSliderValue(0);
370 367
			cstEnhanced.setSliderRange(0,50);
368
			cstEnhanced.setTextValue("0.0");
371 369
			
372 370
		}
373 371
		return cstEnhanced;
......
376 374
	public void setBCControlEnabled(boolean active){
377 375
		this.lstBrightness.setControlEnabled(active);
378 376
		this.lstContrast.setControlEnabled(active);
379
		this.jButton.setEnabled(active);
377
		this.getJCheckBox1().setEnabled(active);
378
		this.jLabel1.setEnabled(active);
380 379
		this.lBrightC.setEnabled(active);
381 380
	}
382 381
	
......
414 413
		// Si est? activo el panel de brillo y contraste tomamos los valores y cargamos un filtro de 
415 414
		// brillo y contraste
416 415
		if(ebcPanel.getCBrightC().isSelected()){
417
			int incrBrillo = ebcPanel.lstBrightness.getTextValue();
418
			int incrContraste = ebcPanel.lstContrast.getTextValue();
416
			int incrBrillo = Integer.valueOf(ebcPanel.lstBrightness.getTextValue()).intValue();
417
			int incrContraste = Integer.valueOf(ebcPanel.lstContrast.getTextValue()).intValue();
419 418
			bcManager.addHistogramFilter();
420 419
			bcManager.addBrightnessFilter(incrBrillo);
421 420
			bcManager.addContrastFilter(incrContraste);
......
424 423
			stackManager.removeFilter(bcManager.brightness);
425 424
			stackManager.removeFilter(bcManager.contrast);
426 425
		}
426
		//Filtro de realce lineal seleccionado
427
		if(ebcPanel.getCEnhanced().isSelected()){
428
			if((ebcPanel.getJCheckBox().isSelected()) && (!ebcPanel.getCheckSliderText().isSelected()))
429
				stackManager.addEnhancedFilter(true, fLayer.getSource().getFiles()[0].getName());
430
			else
431
				stackManager.addEnhancedFilter(false, fLayer.getSource().getFiles()[0].getName());
432
				
433
			//Recorte de colas seleccionado
434
			if(ebcPanel.getCheckSliderText().isSelected()){
435
				stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
436
				double recorte = Double.parseDouble(ebcPanel.getCheckSliderText().getTextValue())/100;
437
				if(ebcPanel.getJCheckBox().isSelected())
438
					stackManager.addTailFilter(recorte, 0D, true);
439
				else
440
					stackManager.addTailFilter(recorte, 0D, false);
441
			}else{
442
				stackManager.removeFilter(stackManager.getTypeFilter("tail"));
443
				stackManager.addComputeMinMaxFilter();
444
			}
445
			
446
		}
447
//		Sin filtro lineal seleccionado
448
		if(!ebcPanel.getCEnhanced().isSelected()){
449
			stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
450
			stackManager.removeFilter(stackManager.getTypeFilter("tail"));
451
			stackManager.removeFilter(stackManager.getTypeFilter("enhanced"));
452
		}
453
		fLayer.getFMap().invalidate();
454
		
427 455
	}
428 456

  
429 457
	public void addTabPanel(FLyrRasterAdjustPropertiesTocMenuEntry menu) {
......
455 483
		
456 484
	}
457 485

  
486
	/**
487
	 * This method initializes jCheckBox1	
488
	 * 	
489
	 * @return javax.swing.JCheckBox	
490
	 */
491
	private JCheckBox getJCheckBox1() {
492
		if (jCheckBox1 == null) {
493
			jCheckBox1 = new JCheckBox();
494
		}
495
		return jCheckBox1;
496
	}
497

  
498
	//********************************************************************
499
	//***********************EVENTOS DE RAT?N*****************************
500
	public void mouseClicked(MouseEvent e) {
501
		// TODO Auto-generated method stub
502
		
503
	}
504

  
505
	public void mouseEntered(MouseEvent e) {
506
		// TODO Auto-generated method stub
507
		
508
	}
509

  
510
	public void mouseExited(MouseEvent e) {
511
		// TODO Auto-generated method stub
512
		
513
	}
514

  
515
	public void mousePressed(MouseEvent e) {
516
		// TODO Auto-generated method stub
517
		
518
	}
519

  
520
	public void mouseReleased(MouseEvent e) {
521
		// TODO Auto-generated method stub
522
		
523
	}
524

  
458 525
}
trunk/extensions/extRasterTools/src/org/gvsig/rasterTools/brightnessContrast/filter/ContrastFilter.java
24 24
	/**
25 25
	 * Valor del estiramiento del histograma de la imagen.
26 26
	 */
27
	int estiramiento = 0;
27
	float estiramiento = 0;
28 28
	
29 29
	/**
30 30
	 * Valor que toma el pixel despues de aplicarle el algoritmo de 
......
32 32
	 */
33 33
	int result = 0;
34 34
	
35
	int est = 0;
36
	int desp = 0;
35 37
	
38
	
36 39
	/**
37 40
	 * Constructor
38 41
	 */
trunk/extensions/extRasterTools/src/org/gvsig/rasterTools/brightnessContrast/filter/ContrastImageFilter.java
26 26
        this.incrContraste = ((Integer)this.params.get("incrContraste")).intValue();
27 27
        
28 28
        desplazamiento = incrContraste/2;
29
        estiramiento = incrContraste/10;
29
        estiramiento = incrContraste/80;
30 30
       
31 31
        if(estiramiento == 0)	
32
        	estiramiento = 1;
32
        	estiramiento += 1;
33 33
        if(estiramiento < 0)
34 34
        	estiramiento = -estiramiento;
35 35
		
......
44 44
					(px & 0x000000ff)};
45 45
		
46 46
		for (int i = 1 ; i < 4 ; i++){			
47
			if(incrContraste < 0)
48
				result = (px3[i] - desplazamiento)/estiramiento;
47
			/*if(incrContraste < 0)
48
				result = (int)((px3[i] + desplazamiento) / estiramiento);
49 49
			else
50
				result = (px3[i] - desplazamiento)*estiramiento;
50
				result = (int)((px3[i] - desplazamiento) * Math.pow(estiramiento, 2));
51
			*/
52
			desp = px3[i] - desplazamiento;
53
			if(desp <= 0) desp = 1;
54
			result = desp * (int)estiramiento;
51 55
			
52 56
			if(result > 255)
53 57
				px3[i] = 255;
trunk/extensions/extRasterTools/src/org/gvsig/rasterTools/brightnessContrast/filter/BrightnessContrastStackManager.java
4 4

  
5 5
import org.cresques.io.GeoRasterFile;
6 6
import org.cresques.io.raster.IStackManager;
7
import org.cresques.io.raster.LinearEnhancementFilter;
8
import org.cresques.io.raster.LinearEnhancementImageFilter;
9
import org.cresques.io.raster.LinearEnhancementShortFilter;
7 10
import org.cresques.io.raster.RasterBuf;
8 11
import org.cresques.io.raster.RasterFilter;
9 12
import org.cresques.io.raster.RasterFilterStack;
10 13
import org.cresques.io.raster.RasterFilterStackManager;
11 14
import org.gvsig.rasterTools.histogram.filter.HistogramFilter;
12 15
import org.gvsig.rasterTools.histogram.filter.HistogramImageFilter;
13
import org.gvsig.rasterTools.histogram.filter.HistogramStackManager;
14 16

  
15 17
/**
16 18
 * Gestor de la pila de filtros para el filtro de brillo.
......
160 162
     * @param filters
161 163
     */
162 164
	public int createStackFromStrings(ArrayList filters, String fil, GeoRasterFile[] grfList, int filteri) {
165
		
163 166
		if((fil.startsWith("filter.brightness.active"))&&
164 167
				(RasterFilterStackManager.getValue(fil).equals("true"))&&
165 168
				(grfList!=null)){
......
193 196
				}
194 197
			}
195 198
		
196
			//addContrastFilter(incrContraste);
199
			addContrastFilter(incrContraste);
197 200
		}
198 201
		
199 202
		if(fil.startsWith("filter.histogram.active") && 
trunk/extensions/extRasterTools/src/org/gvsig/rasterTools/brightnessContrast/toc/BrightnessContrastTocMenuEntry.java
49 49
			if(bright.getParam("incrBrillo") != null){
50 50
				int incr = ((Integer)bright.getParam("incrBrillo")).intValue();
51 51
				bcPanel.getLabelSliderText().setSliderValue(incr);
52
				bcPanel.getLabelSliderText().setTextValue(incr);
52
				bcPanel.getLabelSliderText().setTextValue(String.valueOf(incr));
53 53
			}
54 54
		}
55 55
		
......
63 63
			if(cont.getParam("incrContraste") != null){
64 64
				int incr = ((Integer)cont.getParam("incrContraste")).intValue();
65 65
				bcPanel.getLabelSliderText1().setSliderValue(incr);
66
				bcPanel.getLabelSliderText1().setTextValue(incr);
66
				bcPanel.getLabelSliderText1().setTextValue(String.valueOf(incr));
67 67
			}
68 68
		}
69 69
		
70
		if(stackManager.isActive(stackManager.getTypeFilter("enhanced"))){
71
			EnhancedBrightnessContrastPanel bcPanel = (EnhancedBrightnessContrastPanel)((FilterRasterDialogPanel)propsDialog.getContentPane()).getPanelByClassName("EnhancedBrightnessContrastPanel");
72
			bcPanel.getCEnhanced().setSelected(true);
73
			bcPanel.setEControlEnabled(true);
74
			
75
			RasterFilter enhan = stackManager.getFilter("enhanced");
76
			RasterFilter tail = stackManager.getFilter("tail");
77
			
78
			
79
				boolean rem = ((Boolean)enhan.getParam("remove")).booleanValue();
80
				bcPanel.getJCheckBox().setSelected(rem);
81
			
82
			if(stackManager.isActive(stackManager.getTypeFilter("tail"))){
83
				double percent = (stackManager.getStackStats().tailPercent)*100;
84
				bcPanel.getCheckSliderText().setTextValue(String.valueOf(percent));
85
				bcPanel.getCheckSliderText().setSliderValue((int)percent);
86
				bcPanel.getCheckSliderText().setSelected(true);
87
				bcPanel.getCheckSliderText().setControlEnabled(true);
88
				boolean remove = ((Boolean)tail.getParam("remove")).booleanValue();
89
				if((remove == true) || (rem == true))
90
					bcPanel.getJCheckBox().setSelected(true);
91
				else 
92
					bcPanel.getJCheckBox().setSelected(false);
93
				
94
			}
95
				
96
			
97
		}
70 98
	}
71 99
	/**
72 100
	 * A?ade el panel al cuadro de dialogo de propiedades de raster.

Also available in: Unified diff