root / trunk / libraries / libCq_CMS_praster / src / org / cresques / ui / BrightnessContrast / EnhancedBrightnessContrastPanel.java @ 8026
History | View | Annotate | Download (15.2 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
|
20 |
package org.cresques.ui.BrightnessContrast; |
21 |
|
22 |
import java.awt.GridBagConstraints; |
23 |
import java.awt.GridBagLayout; |
24 |
import java.awt.event.ActionEvent; |
25 |
import java.awt.event.ActionListener; |
26 |
import java.awt.event.KeyEvent; |
27 |
import java.awt.event.KeyListener; |
28 |
import java.awt.event.MouseEvent; |
29 |
import java.awt.event.MouseListener; |
30 |
|
31 |
import javax.swing.JCheckBox; |
32 |
import javax.swing.JLabel; |
33 |
import javax.swing.JPanel; |
34 |
|
35 |
import org.cresques.filter.IStackManager; |
36 |
import org.cresques.filter.RasterFilterStackManager; |
37 |
import org.cresques.filter.enhancement.BrightnessContrastStackManager; |
38 |
import org.cresques.io.GeoRasterFile; |
39 |
import org.cresques.ui.filter.FilterRasterDialogPanel; |
40 |
|
41 |
|
42 |
/**
|
43 |
* Panel para los controles de brillo, contrase y realce.
|
44 |
* @author Miguel Angel Querol Carratal? <querol_mig@gva.es>
|
45 |
*
|
46 |
*/
|
47 |
public class EnhancedBrightnessContrastPanel extends JPanel implements ActionListener{ |
48 |
|
49 |
private String nom = "Realce"; |
50 |
private JPanel pBrightCont = null; |
51 |
private JPanel pEnhanced = null; |
52 |
public LabelSliderText lstBrightness = null; |
53 |
public LabelSliderText lstContrast = null; |
54 |
private JPanel pBCCheck = null; |
55 |
private JPanel pBCSlider = null; |
56 |
private JPanel jPanel1 = null; |
57 |
private JCheckBox cBrightC = null; |
58 |
public JLabel lBrightC = null; |
59 |
private JPanel pEnCheck = null; |
60 |
private JPanel pEnSlider = null; |
61 |
private JCheckBox cEnhanced = null; |
62 |
private JPanel pDelInt = null; |
63 |
private JCheckBox jCheckBox = null; |
64 |
|
65 |
private BrightnessContrastStackManager bcManager = null; |
66 |
private JCheckBox jCheckBox1 = null; |
67 |
public JLabel lpreview = null; |
68 |
public RasterFilterStackManager rasterStackManager = null; |
69 |
public JLabel lLineal = null; |
70 |
public JLabel lRemove = null; |
71 |
public CheckSliderText cstEnhanced = null; |
72 |
private FilterRasterDialogPanel parent = null; |
73 |
|
74 |
/**
|
75 |
* This is the default constructor
|
76 |
*/
|
77 |
public EnhancedBrightnessContrastPanel() {
|
78 |
super();
|
79 |
initialize(); |
80 |
} |
81 |
|
82 |
/**
|
83 |
* This is the default constructor
|
84 |
*/
|
85 |
public EnhancedBrightnessContrastPanel(FilterRasterDialogPanel parent) {
|
86 |
super();
|
87 |
this.parent = parent;
|
88 |
initialize(); |
89 |
} |
90 |
|
91 |
/**
|
92 |
* This method initializes this
|
93 |
*
|
94 |
* @return void
|
95 |
*/
|
96 |
private void initialize() { |
97 |
GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
98 |
gridBagConstraints3.insets = new java.awt.Insets(0,4,0,4); |
99 |
gridBagConstraints3.gridy = 0;
|
100 |
gridBagConstraints3.gridx = 1;
|
101 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
102 |
gridBagConstraints2.insets = new java.awt.Insets(0,4,0,4); |
103 |
gridBagConstraints2.gridy = 0;
|
104 |
gridBagConstraints2.gridx = 0;
|
105 |
this.setLayout(new GridBagLayout()); |
106 |
this.setSize(445, 239); |
107 |
this.setPreferredSize(new java.awt.Dimension(445,239)); |
108 |
this.add(getPBrightCont(), gridBagConstraints2);
|
109 |
this.add(getPEnhanced(), gridBagConstraints3);
|
110 |
|
111 |
this.getCBrightC().addActionListener(this); |
112 |
this.getCEnhanced().addActionListener(this); |
113 |
//this.getLabelSliderText().getJTextField().addActionListener(this);
|
114 |
//this.getLabelSliderText1().getJTextField().addActionListener(this);
|
115 |
} |
116 |
|
117 |
/**
|
118 |
* This method initializes jPanel
|
119 |
*
|
120 |
* @return javax.swing.JPanel
|
121 |
*/
|
122 |
public JPanel getPBrightCont() { |
123 |
if (pBrightCont == null) { |
124 |
GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
125 |
gridBagConstraints4.gridx = 0;
|
126 |
gridBagConstraints4.insets = new java.awt.Insets(4,0,8,0); |
127 |
gridBagConstraints4.gridy = 1;
|
128 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
129 |
gridBagConstraints.gridx = 0;
|
130 |
gridBagConstraints.insets = new java.awt.Insets(0,8,4,8); |
131 |
gridBagConstraints.gridy = 0;
|
132 |
pBrightCont = new JPanel(); |
133 |
pBrightCont.setLayout(new GridBagLayout()); |
134 |
pBrightCont.setPreferredSize(new java.awt.Dimension(210,223)); |
135 |
pBrightCont.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Brillo y contraste", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
136 |
pBrightCont.add(getPBCCheck(), gridBagConstraints); |
137 |
pBrightCont.add(getPBCSlider(), gridBagConstraints4); |
138 |
} |
139 |
return pBrightCont;
|
140 |
} |
141 |
|
142 |
/**
|
143 |
* This method initializes jPanel1
|
144 |
*
|
145 |
* @return javax.swing.JPanel
|
146 |
*/
|
147 |
public JPanel getPEnhanced() { |
148 |
if (pEnhanced == null) { |
149 |
GridBagConstraints gridBagConstraints12 = new GridBagConstraints(); |
150 |
gridBagConstraints12.gridx = 0;
|
151 |
gridBagConstraints12.insets = new java.awt.Insets(4,4,59,4); |
152 |
gridBagConstraints12.gridy = 1;
|
153 |
GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); |
154 |
gridBagConstraints11.gridx = 0;
|
155 |
gridBagConstraints11.insets = new java.awt.Insets(0,8,4,8); |
156 |
gridBagConstraints11.gridy = 0;
|
157 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
158 |
gridBagConstraints1.gridx = 0;
|
159 |
gridBagConstraints1.gridy = 0;
|
160 |
pEnhanced = new JPanel(); |
161 |
pEnhanced.setLayout(new GridBagLayout()); |
162 |
pEnhanced.setPreferredSize(new java.awt.Dimension(210,223)); |
163 |
pEnhanced.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Realce", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
164 |
pEnhanced.add(getPEnCheck(), gridBagConstraints11); |
165 |
pEnhanced.add(getPEnSlider(), gridBagConstraints12); |
166 |
} |
167 |
return pEnhanced;
|
168 |
} |
169 |
|
170 |
/**
|
171 |
* inicializa el conponente LabelSliderText
|
172 |
*/
|
173 |
public LabelSliderText getLabelSliderText(){
|
174 |
if(lstBrightness == null){ |
175 |
lstBrightness = new LabelSliderText();
|
176 |
lstBrightness.setName("Brillo");
|
177 |
lstBrightness.setSliderRange(-255,255); |
178 |
lstBrightness.setSliderValue(0);
|
179 |
} |
180 |
return lstBrightness;
|
181 |
} |
182 |
|
183 |
/**
|
184 |
* inicializa el conponente LabelSliderText
|
185 |
*/
|
186 |
public LabelSliderText getLabelSliderText1(){
|
187 |
if (lstContrast == null){ |
188 |
lstContrast = new LabelSliderText();
|
189 |
lstContrast.setName("Contraste");
|
190 |
lstContrast.setPreferredSize(new java.awt.Dimension(180,45)); |
191 |
lstContrast.setSliderRange(-255,255); |
192 |
lstContrast.setSliderValue(0);
|
193 |
} |
194 |
return lstContrast;
|
195 |
} |
196 |
|
197 |
/**
|
198 |
* This method initializes jPanel1
|
199 |
*
|
200 |
* @return javax.swing.JPanel
|
201 |
*/
|
202 |
private JPanel getPBCCheck() { |
203 |
if (pBCCheck == null) { |
204 |
GridBagConstraints gridBagConstraints9 = new GridBagConstraints(); |
205 |
gridBagConstraints9.gridx = 1;
|
206 |
gridBagConstraints9.gridy = 0;
|
207 |
lBrightC = new JLabel(); |
208 |
lBrightC.setText("Activar");
|
209 |
lBrightC.setPreferredSize(new java.awt.Dimension(160,15)); |
210 |
GridBagConstraints gridBagConstraints8 = new GridBagConstraints(); |
211 |
gridBagConstraints8.gridx = 0;
|
212 |
gridBagConstraints8.gridy = 0;
|
213 |
pBCCheck = new JPanel(); |
214 |
pBCCheck.setLayout(new GridBagLayout()); |
215 |
pBCCheck.setPreferredSize(new java.awt.Dimension(182,25)); |
216 |
pBCCheck.add(getCBrightC(), gridBagConstraints8); |
217 |
pBCCheck.add(lBrightC, gridBagConstraints9); |
218 |
} |
219 |
return pBCCheck;
|
220 |
} |
221 |
|
222 |
/**
|
223 |
* This method initializes jPanel3
|
224 |
*
|
225 |
* @return javax.swing.JPanel
|
226 |
*/
|
227 |
private JPanel getPBCSlider() { |
228 |
if (pBCSlider == null) { |
229 |
GridBagConstraints gridBagConstraints7 = new GridBagConstraints(); |
230 |
gridBagConstraints7.gridx = 0;
|
231 |
gridBagConstraints7.insets = new java.awt.Insets(0,0,2,0); |
232 |
gridBagConstraints7.gridy = 0;
|
233 |
GridBagConstraints gridBagConstraints6 = new GridBagConstraints(); |
234 |
gridBagConstraints6.gridx = 0;
|
235 |
gridBagConstraints6.insets = new java.awt.Insets(10,0,8,0); |
236 |
gridBagConstraints6.gridy = 2;
|
237 |
GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); |
238 |
gridBagConstraints5.gridx = 0;
|
239 |
gridBagConstraints5.insets = new java.awt.Insets(0,0,0,0); |
240 |
gridBagConstraints5.gridy = 1;
|
241 |
pBCSlider = new JPanel(); |
242 |
pBCSlider.setLayout(new GridBagLayout()); |
243 |
pBCSlider.setPreferredSize(new java.awt.Dimension(188,150)); |
244 |
pBCSlider.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
|
245 |
pBCSlider.add(getLabelSliderText(), gridBagConstraints7); |
246 |
pBCSlider.add(getLabelSliderText1(), gridBagConstraints5); |
247 |
pBCSlider.add(getJPanel1(), gridBagConstraints6); |
248 |
this.setBCControlEnabled(false); |
249 |
} |
250 |
return pBCSlider;
|
251 |
} |
252 |
|
253 |
/**
|
254 |
* This method initializes jPanel1
|
255 |
*
|
256 |
* @return javax.swing.JPanel
|
257 |
*/
|
258 |
private JPanel getJPanel1() { |
259 |
if (jPanel1 == null) { |
260 |
GridBagConstraints gridBagConstraints19 = new GridBagConstraints(); |
261 |
gridBagConstraints19.gridx = 1;
|
262 |
gridBagConstraints19.gridy = 0;
|
263 |
lpreview = new JLabel(); |
264 |
lpreview.setText("Previsualizacion");
|
265 |
lpreview.setPreferredSize(new java.awt.Dimension(150,15)); |
266 |
lpreview.setSize(new java.awt.Dimension(160,15)); |
267 |
GridBagConstraints gridBagConstraints10 = new GridBagConstraints(); |
268 |
gridBagConstraints10.gridx = 0;
|
269 |
gridBagConstraints10.insets = new java.awt.Insets(0,0,0,0); |
270 |
gridBagConstraints10.gridy = 0;
|
271 |
jPanel1 = new JPanel(); |
272 |
jPanel1.setLayout(new GridBagLayout()); |
273 |
jPanel1.setPreferredSize(new java.awt.Dimension(180,25)); |
274 |
jPanel1.add(getJCheckBox1(), gridBagConstraints10); |
275 |
jPanel1.add(lpreview, gridBagConstraints19); |
276 |
} |
277 |
return jPanel1;
|
278 |
} |
279 |
|
280 |
/**
|
281 |
* This method initializes jCheckBox
|
282 |
*
|
283 |
* @return javax.swing.JCheckBox
|
284 |
*/
|
285 |
public JCheckBox getCBrightC() { |
286 |
if (cBrightC == null) { |
287 |
cBrightC = new JCheckBox(); |
288 |
} |
289 |
return cBrightC;
|
290 |
} |
291 |
|
292 |
/**
|
293 |
* This method initializes jPanel
|
294 |
*
|
295 |
* @return javax.swing.JPanel
|
296 |
*/
|
297 |
private JPanel getPEnCheck() { |
298 |
if (pEnCheck == null) { |
299 |
GridBagConstraints gridBagConstraints14 = new GridBagConstraints(); |
300 |
gridBagConstraints14.insets = new java.awt.Insets(0,0,0,0); |
301 |
gridBagConstraints14.gridy = 0;
|
302 |
gridBagConstraints14.gridx = 1;
|
303 |
GridBagConstraints gridBagConstraints13 = new GridBagConstraints(); |
304 |
gridBagConstraints13.insets = new java.awt.Insets(0,0,0,0); |
305 |
gridBagConstraints13.gridy = 0;
|
306 |
gridBagConstraints13.gridx = 0;
|
307 |
lLineal = new JLabel(); |
308 |
lLineal.setText("Lineal Directo");
|
309 |
lLineal.setPreferredSize(new java.awt.Dimension(160,15)); |
310 |
pEnCheck = new JPanel(); |
311 |
pEnCheck.setLayout(new GridBagLayout()); |
312 |
pEnCheck.setPreferredSize(new java.awt.Dimension(182,25)); |
313 |
pEnCheck.add(getCEnhanced(), gridBagConstraints13); |
314 |
pEnCheck.add(lLineal, gridBagConstraints14); |
315 |
} |
316 |
return pEnCheck;
|
317 |
} |
318 |
|
319 |
/**
|
320 |
* This method initializes jPanel2
|
321 |
*
|
322 |
* @return javax.swing.JPanel
|
323 |
*/
|
324 |
private JPanel getPEnSlider() { |
325 |
if (pEnSlider == null) { |
326 |
GridBagConstraints gridBagConstraints18 = new GridBagConstraints(); |
327 |
gridBagConstraints18.insets = new java.awt.Insets(2,0,0,0); |
328 |
gridBagConstraints18.gridy = 1;
|
329 |
gridBagConstraints18.gridx = 0;
|
330 |
GridBagConstraints gridBagConstraints15 = new GridBagConstraints(); |
331 |
gridBagConstraints15.insets = new java.awt.Insets(0,0,2,0); |
332 |
gridBagConstraints15.gridy = 0;
|
333 |
gridBagConstraints15.gridx = 0;
|
334 |
pEnSlider = new JPanel(); |
335 |
pEnSlider.setLayout(new GridBagLayout()); |
336 |
pEnSlider.setPreferredSize(new java.awt.Dimension(188,100)); |
337 |
pEnSlider.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
|
338 |
pEnSlider.add(getPDelInt(), gridBagConstraints15); |
339 |
pEnSlider.add(getCheckSliderText(), gridBagConstraints18); |
340 |
this.setEControlEnabled(false); |
341 |
} |
342 |
return pEnSlider;
|
343 |
} |
344 |
|
345 |
/**
|
346 |
* This method initializes jCheckBox
|
347 |
*
|
348 |
* @return javax.swing.JCheckBox
|
349 |
*/
|
350 |
public JCheckBox getCEnhanced() { |
351 |
if (cEnhanced == null) { |
352 |
cEnhanced = new JCheckBox(); |
353 |
} |
354 |
return cEnhanced;
|
355 |
} |
356 |
|
357 |
/**
|
358 |
* This method initializes jPanel3
|
359 |
*
|
360 |
* @return javax.swing.JPanel
|
361 |
*/
|
362 |
private JPanel getPDelInt() { |
363 |
if (pDelInt == null) { |
364 |
GridBagConstraints gridBagConstraints17 = new GridBagConstraints(); |
365 |
gridBagConstraints17.gridx = 1;
|
366 |
gridBagConstraints17.gridy = 0;
|
367 |
lRemove = new JLabel(); |
368 |
lRemove.setText("Eliminar Extremos");
|
369 |
lRemove.setPreferredSize(new java.awt.Dimension(150,15)); |
370 |
GridBagConstraints gridBagConstraints16 = new GridBagConstraints(); |
371 |
gridBagConstraints16.insets = new java.awt.Insets(0,0,0,0); |
372 |
gridBagConstraints16.gridy = 0;
|
373 |
gridBagConstraints16.gridx = 0;
|
374 |
pDelInt = new JPanel(); |
375 |
pDelInt.setLayout(new GridBagLayout()); |
376 |
pDelInt.setPreferredSize(new java.awt.Dimension(180,25)); |
377 |
pDelInt.add(getJCheckBox(), gridBagConstraints16); |
378 |
pDelInt.add(lRemove, gridBagConstraints17); |
379 |
} |
380 |
return pDelInt;
|
381 |
} |
382 |
|
383 |
/**
|
384 |
* This method initializes jCheckBox
|
385 |
*
|
386 |
* @return javax.swing.JCheckBox
|
387 |
*/
|
388 |
public JCheckBox getJCheckBox() { |
389 |
if (jCheckBox == null) { |
390 |
jCheckBox = new JCheckBox(); |
391 |
} |
392 |
return jCheckBox;
|
393 |
} |
394 |
|
395 |
/**
|
396 |
* inicializa el conponente CheckSliderText
|
397 |
*/
|
398 |
public CheckSliderText getCheckSliderText(){
|
399 |
String rcName = "Recorte de colas"; |
400 |
if (cstEnhanced == null){ |
401 |
cstEnhanced = new CheckSliderText();
|
402 |
cstEnhanced.setName(rcName); |
403 |
cstEnhanced.setSliderValue(0);
|
404 |
cstEnhanced.setSliderRange(0,50); |
405 |
cstEnhanced.setDecimal(true);
|
406 |
cstEnhanced.setTextValue("0.0");
|
407 |
|
408 |
} |
409 |
return cstEnhanced;
|
410 |
} |
411 |
|
412 |
/**
|
413 |
* Habilita o dehabilita el panel de brillo y contraste
|
414 |
* @param active
|
415 |
*/
|
416 |
public void setBCControlEnabled(boolean active){ |
417 |
this.lstBrightness.setControlEnabled(active);
|
418 |
this.lstContrast.setControlEnabled(active);
|
419 |
this.getJCheckBox1().setEnabled(active);
|
420 |
this.lpreview.setEnabled(active);
|
421 |
} |
422 |
|
423 |
/**
|
424 |
* Habilita o dehabilita el panel de realce
|
425 |
* @param active
|
426 |
*/
|
427 |
public void setEControlEnabled(boolean active){ |
428 |
this.jCheckBox.setEnabled(active);
|
429 |
this.lRemove.setEnabled(active);
|
430 |
this.cstEnhanced.setControlEnabled(active);
|
431 |
} |
432 |
|
433 |
|
434 |
public void actionPerformed(ActionEvent e) { |
435 |
if(e.getSource() == this.getCBrightC()){ |
436 |
this.setBCControlEnabled(this.getCBrightC().isSelected()); |
437 |
} |
438 |
if(e.getSource() == cEnhanced){
|
439 |
this.setEControlEnabled(this.getCEnhanced().isSelected()); |
440 |
} |
441 |
} |
442 |
|
443 |
/**
|
444 |
* Asigna a este panel un stack manager
|
445 |
* @param p
|
446 |
*/
|
447 |
public void setBrightnessContrastStackManager (BrightnessContrastStackManager p){ |
448 |
this.bcManager = p;
|
449 |
} |
450 |
|
451 |
|
452 |
//-------------------------------------------------------------------------------
|
453 |
|
454 |
public void setStackManager(RasterFilterStackManager stackManager) { |
455 |
// TODO Auto-generated method stub
|
456 |
|
457 |
} |
458 |
|
459 |
public IStackManager getStackManager() {
|
460 |
// TODO Auto-generated method stub
|
461 |
return bcManager;
|
462 |
} |
463 |
|
464 |
|
465 |
//----------------------------------------------------------------------------------
|
466 |
|
467 |
|
468 |
public void removeFile(String file) { |
469 |
// TODO Auto-generated method stub
|
470 |
|
471 |
} |
472 |
|
473 |
public void addFiles(GeoRasterFile[] files) { |
474 |
// TODO Auto-generated method stub
|
475 |
|
476 |
} |
477 |
|
478 |
/**
|
479 |
* This method initializes jCheckBox1
|
480 |
*
|
481 |
* @return javax.swing.JCheckBox
|
482 |
*/
|
483 |
public JCheckBox getJCheckBox1() { |
484 |
if (jCheckBox1 == null) { |
485 |
jCheckBox1 = new JCheckBox(); |
486 |
jCheckBox1.setSelected(true);
|
487 |
} |
488 |
return jCheckBox1;
|
489 |
} |
490 |
|
491 |
/**
|
492 |
* Obtiene el nombre del panel
|
493 |
* @return Cadena con el nombre del panel
|
494 |
*/
|
495 |
public String getName(){ |
496 |
return this.nom; |
497 |
} |
498 |
|
499 |
} |
500 |
|