root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / properties / panels / EnhancedWithTrimPanel.java @ 12180
History | View | Annotate | Download (8.78 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 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 |
package org.gvsig.rastertools.properties.panels; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
import java.awt.GridBagConstraints; |
23 |
import java.awt.GridBagLayout; |
24 |
import java.awt.GridLayout; |
25 |
import java.awt.Insets; |
26 |
import java.awt.event.ActionEvent; |
27 |
import java.awt.event.ActionListener; |
28 |
|
29 |
import javax.swing.JCheckBox; |
30 |
import javax.swing.JPanel; |
31 |
import javax.swing.JRadioButton; |
32 |
|
33 |
import org.gvsig.gui.beans.slidertext.SliderTextContainer; |
34 |
|
35 |
import com.iver.andami.PluginServices; |
36 |
/**
|
37 |
* Panel para los controles de brillo y contraste.
|
38 |
*
|
39 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
40 |
*/
|
41 |
public class EnhancedWithTrimPanel extends JPanel implements ActionListener { |
42 |
private static final long serialVersionUID = 9023137365069951866L; |
43 |
public static final int LINEAR = 0; |
44 |
private TrimPanel trimPanel = null; |
45 |
private SelectorPanel selectorPanel = null; |
46 |
private JCheckBox active = null; |
47 |
|
48 |
/**
|
49 |
* Panel con los controles de eliminar extremos, recorte de colas y slider
|
50 |
* con el porcentaje de recorte.
|
51 |
*
|
52 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
53 |
*/
|
54 |
public class TrimPanel extends JPanel implements ActionListener { |
55 |
private static final long serialVersionUID = -6435560458161006843L; |
56 |
private SliderTextContainer trimSlider = null; |
57 |
private JCheckBox removeCheck = null; |
58 |
private JCheckBox trimCheck = null; |
59 |
private JPanel panel = null; |
60 |
|
61 |
/**
|
62 |
* Contructor
|
63 |
*/
|
64 |
public TrimPanel() {
|
65 |
init(); |
66 |
getTrimCheck().addActionListener(this);
|
67 |
} |
68 |
|
69 |
private void init() { |
70 |
setBorder(javax.swing.BorderFactory.createTitledBorder(null, null, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
71 |
this.setLayout(new BorderLayout()); |
72 |
this.add(getPanel(), BorderLayout.NORTH); |
73 |
this.add(getTrimSlider(), BorderLayout.CENTER); |
74 |
} |
75 |
|
76 |
/**
|
77 |
* Obtiene el control con el slider de recorte de colas
|
78 |
* @return SliderTextContainer
|
79 |
*/
|
80 |
public SliderTextContainer getTrimSlider() {
|
81 |
if (trimSlider == null) { |
82 |
trimSlider = new SliderTextContainer(0, 100, 50); |
83 |
trimSlider.setDecimal(true);
|
84 |
trimSlider.setBorder("");
|
85 |
} |
86 |
return trimSlider;
|
87 |
} |
88 |
|
89 |
public JPanel getPanel() { |
90 |
if (panel == null) { |
91 |
panel = new JPanel(); |
92 |
panel.setLayout(new GridBagLayout()); |
93 |
GridBagConstraints gbc = new GridBagConstraints(); |
94 |
gbc.insets = new Insets(9, 0, 0, 0); |
95 |
gbc.anchor = GridBagConstraints.WEST;
|
96 |
gbc.gridx = 0;
|
97 |
gbc.gridy = 0;
|
98 |
gbc.weightx = 8;
|
99 |
|
100 |
GridBagConstraints gbc1 = new GridBagConstraints(); |
101 |
gbc1.insets = new Insets(9, 0, 9, 0); |
102 |
gbc1.gridx = 0;
|
103 |
gbc1.gridy = 1;
|
104 |
gbc1.anchor = GridBagConstraints.WEST;
|
105 |
gbc1.weightx = 8;
|
106 |
|
107 |
panel.add(getRemoveCheck(), gbc); |
108 |
panel.add(getTrimCheck(), gbc1); |
109 |
} |
110 |
return panel;
|
111 |
} |
112 |
|
113 |
/**
|
114 |
* Obtiene el check de eliminar extremos
|
115 |
* @return
|
116 |
*/
|
117 |
public JCheckBox getRemoveCheck() { |
118 |
if (removeCheck == null) { |
119 |
removeCheck = new JCheckBox(PluginServices.getText(this, "eliminar_extremos")); |
120 |
} |
121 |
return removeCheck;
|
122 |
} |
123 |
|
124 |
/**
|
125 |
* Obtiene el check de recorte de colas
|
126 |
* @return
|
127 |
*/
|
128 |
public JCheckBox getTrimCheck() { |
129 |
if (trimCheck == null) { |
130 |
trimCheck = new JCheckBox(PluginServices.getText(this, "recorte_colas")); |
131 |
} |
132 |
return trimCheck;
|
133 |
} |
134 |
|
135 |
/**
|
136 |
* Activa o desactiva el control
|
137 |
* @param enable true activa y false desactiva los controles del panel
|
138 |
*/
|
139 |
public void setControlEnabled(boolean enabled) { |
140 |
if (enabled && getTrimCheck().isSelected())
|
141 |
getTrimSlider().setControlEnabled(true);
|
142 |
else
|
143 |
getTrimSlider().setControlEnabled(false);
|
144 |
getRemoveCheck().setEnabled(enabled); |
145 |
getTrimCheck().setEnabled(enabled); |
146 |
} |
147 |
|
148 |
/**
|
149 |
* Maneja eventos de activar y desactivar el panel
|
150 |
*/
|
151 |
public void actionPerformed(ActionEvent e) { |
152 |
if (e.getSource() == getTrimCheck())
|
153 |
getTrimSlider().setControlEnabled(getTrimCheck().isSelected()); |
154 |
} |
155 |
} |
156 |
|
157 |
/**
|
158 |
* Panel con los controles de selecci?n para el tipo de filtro
|
159 |
* de realce.
|
160 |
*
|
161 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
162 |
*/
|
163 |
class SelectorPanel extends JPanel { |
164 |
private static final long serialVersionUID = 9036702518290091787L; |
165 |
private JRadioButton rb = null; |
166 |
|
167 |
/**
|
168 |
* Constructor
|
169 |
*/
|
170 |
public SelectorPanel() {
|
171 |
setLayout(new GridLayout(1, 1)); |
172 |
add(getLineal()); |
173 |
} |
174 |
|
175 |
/**
|
176 |
* Obtiene el radio button de selecci?n de filtro lineal
|
177 |
* @return JRadioButton
|
178 |
*/
|
179 |
private JRadioButton getLineal() { |
180 |
if (rb == null) { |
181 |
rb = new JRadioButton(PluginServices.getText(this, "lineal_directo")); |
182 |
rb.setSelected(true);
|
183 |
} |
184 |
return rb;
|
185 |
} |
186 |
|
187 |
/**
|
188 |
* Activa o desactiva el control
|
189 |
* @param enable true activa y false desactiva los controles del panel
|
190 |
*/
|
191 |
public void setControlEnabled(boolean enabled) { |
192 |
rb.setEnabled(enabled); |
193 |
} |
194 |
} |
195 |
|
196 |
/**
|
197 |
* Contructor
|
198 |
*/
|
199 |
public EnhancedWithTrimPanel() {
|
200 |
super();
|
201 |
initialize(); |
202 |
} |
203 |
|
204 |
public SelectorPanel getSelectorPanel() {
|
205 |
if (selectorPanel == null) { |
206 |
selectorPanel = new SelectorPanel();
|
207 |
} |
208 |
return selectorPanel;
|
209 |
} |
210 |
|
211 |
public TrimPanel getTrimPanel() {
|
212 |
if (trimPanel == null) { |
213 |
trimPanel = new TrimPanel();
|
214 |
} |
215 |
return trimPanel;
|
216 |
} |
217 |
|
218 |
private void initialize() { |
219 |
setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "realce"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
220 |
setLayout(new BorderLayout()); |
221 |
add(getActive(), BorderLayout.NORTH);
|
222 |
add(getSelectorPanel(), BorderLayout.CENTER);
|
223 |
add(getTrimPanel(), BorderLayout.SOUTH);
|
224 |
getActive().addActionListener(this);
|
225 |
} |
226 |
|
227 |
/**
|
228 |
* Obtiene el check de activar
|
229 |
* @return
|
230 |
*/
|
231 |
public JCheckBox getActive() { |
232 |
if (active == null) { |
233 |
active = new JCheckBox(PluginServices.getText(this, "activar")); |
234 |
active.setSelected(false);
|
235 |
this.setControlEnabled(false); |
236 |
} |
237 |
return active;
|
238 |
} |
239 |
|
240 |
/**
|
241 |
* Activa o desactiva el control
|
242 |
* @param enable true activa y false desactiva los controles del panel
|
243 |
*/
|
244 |
public void setControlEnabled(boolean enabled) { |
245 |
getActive().setSelected(enabled); |
246 |
getTrimPanel().setControlEnabled(enabled); |
247 |
getSelectorPanel().setControlEnabled(enabled); |
248 |
} |
249 |
|
250 |
/**
|
251 |
* Maneja eventos de activar y desactivar el panel
|
252 |
*/
|
253 |
public void actionPerformed(ActionEvent e) { |
254 |
if (e.getSource() == getActive()) {
|
255 |
if (getActive().isSelected())
|
256 |
setControlEnabled(true);
|
257 |
else
|
258 |
setControlEnabled(false);
|
259 |
} |
260 |
} |
261 |
|
262 |
/**
|
263 |
* Obtiene el valor de selecci?n del check de eliminar extremos
|
264 |
* @return boolean, true si est? seleccionado y false si no lo est?.
|
265 |
*/
|
266 |
public boolean isRemoveEndsSelected() { |
267 |
return getTrimPanel().getRemoveCheck().isSelected();
|
268 |
} |
269 |
|
270 |
/**
|
271 |
* Obtiene el valor de selecci?n del check de recorte de colas.
|
272 |
* @return boolean, true si est? seleccionado y false si no lo est?.
|
273 |
*/
|
274 |
public boolean isTailTrimCheckSelected() { |
275 |
return getTrimPanel().getTrimCheck().isSelected();
|
276 |
} |
277 |
|
278 |
/**
|
279 |
* Obtiene el valor de recorte de colas seleccionado en el slider
|
280 |
* @return double
|
281 |
*/
|
282 |
public double getTrimValue() { |
283 |
return getTrimPanel().getTrimSlider().getValue();
|
284 |
} |
285 |
|
286 |
/**
|
287 |
* Activa o desactiva el checkbox de recorte de colas
|
288 |
* @param active true si deseamos activarlo y false para desactivarlo
|
289 |
*/
|
290 |
public void setTailTrimCheckActive(boolean active) { |
291 |
getTrimPanel().getTrimCheck().setSelected(active); |
292 |
} |
293 |
|
294 |
/**
|
295 |
* Activa o desactiva el checkbox de eliminar extremos
|
296 |
* @param active true si deseamos activarlo y false para desactivarlo
|
297 |
*/
|
298 |
public void setRemoveEndsActive(boolean active) { |
299 |
getTrimPanel().getRemoveCheck().setSelected(active); |
300 |
} |
301 |
|
302 |
/**
|
303 |
* Asigna un valor al slider de porcentaje de recorte
|
304 |
* @param active true si deseamos activarlo y false para desactivarlo
|
305 |
*/
|
306 |
public void setTailTrimValue(double value) { |
307 |
getTrimPanel().getTrimSlider().setValue(value); |
308 |
} |
309 |
|
310 |
/**
|
311 |
* Selecciona un metodo de realce entre los disponibles (linear)
|
312 |
* @param method
|
313 |
*/
|
314 |
public void setEnhancedMethod(int method) { |
315 |
switch (method) {
|
316 |
case LINEAR:
|
317 |
break;
|
318 |
} |
319 |
} |
320 |
} |