svn-gvsig-desktop / trunk / extensions / extRasterTools / src / org / gvsig / rasterTools / brightnessContrast / ui / CheckSliderText.java @ 5497
History | View | Annotate | Download (3.04 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.gvsig.rasterTools.brightnessContrast.ui; |
21 |
|
22 |
import java.awt.GridBagConstraints; |
23 |
import java.awt.Insets; |
24 |
import java.awt.event.ActionEvent; |
25 |
import java.awt.event.ActionListener; |
26 |
|
27 |
import javax.swing.JCheckBox; |
28 |
import javax.swing.JLabel; |
29 |
|
30 |
/**
|
31 |
* Clase que contiene slider, campo de texto, etiqueta para el nombre y un
|
32 |
* checkBox para habilitar o deshabilitar el slider y el campo de texto.
|
33 |
* @author Miguel ?ngel Querol Carratal? <querol_mig@gva.es>
|
34 |
*
|
35 |
*/
|
36 |
public class CheckSliderText extends SliderTextPanel implements ActionListener{ |
37 |
|
38 |
public JLabel lName = null; |
39 |
public JCheckBox cSliderText = null; |
40 |
|
41 |
/**
|
42 |
* Constructor
|
43 |
*
|
44 |
*/
|
45 |
|
46 |
public CheckSliderText(){
|
47 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
48 |
gridBagConstraints1.insets = new Insets(0,0,0,0); |
49 |
super.getJPanel().add(getJCheckBox());
|
50 |
super.getJPanel().add(getLName(), gridBagConstraints1);
|
51 |
this.getJCheckBox().addActionListener(this); |
52 |
if(cSliderText.isSelected() == false){ |
53 |
super.setControlEnabled(false); |
54 |
lName.setEnabled(false);
|
55 |
} |
56 |
} |
57 |
/**
|
58 |
* Inicializa cSliderText
|
59 |
* @return
|
60 |
*/
|
61 |
public JCheckBox getJCheckBox(){ |
62 |
if(cSliderText == null){ |
63 |
cSliderText = new JCheckBox(); |
64 |
} |
65 |
return cSliderText;
|
66 |
} |
67 |
|
68 |
public JLabel getLName(){ |
69 |
if(lName == null){ |
70 |
lName = new JLabel(); |
71 |
lName.setText("Nombre");
|
72 |
lName.setPreferredSize(new java.awt.Dimension(150,15)); |
73 |
lName.setSize(150, 15); |
74 |
} |
75 |
return lName;
|
76 |
} |
77 |
|
78 |
/**
|
79 |
* Pone nombre al panel en la etiqueta que est? encima del slider
|
80 |
*/
|
81 |
public void setName(String name){ |
82 |
lName.setText(name); |
83 |
} |
84 |
|
85 |
/**
|
86 |
* Activa o desactiva el slider y el campo de texto
|
87 |
*/
|
88 |
public void setControlEnabled(boolean active){ |
89 |
this.cSliderText.setEnabled(active);
|
90 |
this.lName.setEnabled(active);
|
91 |
this.getJTextField().setEnabled(active);
|
92 |
super.setControlEnabled(active);
|
93 |
if(cSliderText.isSelected() == false){ |
94 |
super.setControlEnabled(false); |
95 |
} |
96 |
|
97 |
} |
98 |
|
99 |
|
100 |
public void actionPerformed(ActionEvent e) { |
101 |
super.actionPerformed(e);
|
102 |
if (e.getSource() == getJCheckBox()){
|
103 |
this.lName.setEnabled(getJCheckBox().isSelected());
|
104 |
super.setControlEnabled(getJCheckBox().isSelected());
|
105 |
} |
106 |
} |
107 |
|
108 |
public void setSelected(boolean value){ |
109 |
this.getJCheckBox().setSelected(value);
|
110 |
} |
111 |
|
112 |
} |