root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / properties / panels / EnhancedWithTrimPanel.java @ 17495
History | View | Annotate | Download (8.78 KB)
1 | 10740 | nacho | /* 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 | 12154 | bsanchez | * Panel para los controles de brillo y contraste.
|
38 | 10740 | nacho | *
|
39 | * @author Nacho Brodin (nachobrodin@gmail.com)
|
||
40 | */
|
||
41 | 12154 | bsanchez | 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 | 10740 | nacho | /**
|
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 | 12180 | bsanchez | public class TrimPanel extends JPanel implements ActionListener { |
55 | 12154 | bsanchez | private static final long serialVersionUID = -6435560458161006843L; |
56 | private SliderTextContainer trimSlider = null; |
||
57 | 12180 | bsanchez | private JCheckBox removeCheck = null; |
58 | 12154 | bsanchez | private JCheckBox trimCheck = null; |
59 | 12180 | bsanchez | private JPanel panel = null; |
60 | 12154 | bsanchez | |
61 | 10740 | nacho | /**
|
62 | * Contructor
|
||
63 | */
|
||
64 | 12154 | bsanchez | public TrimPanel() {
|
65 | 10740 | nacho | init(); |
66 | 12180 | bsanchez | getTrimCheck().addActionListener(this);
|
67 | 10740 | nacho | } |
68 | 12154 | bsanchez | |
69 | private void init() { |
||
70 | 10740 | nacho | 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 | 12180 | bsanchez | this.add(getPanel(), BorderLayout.NORTH); |
73 | this.add(getTrimSlider(), BorderLayout.CENTER); |
||
74 | 10740 | nacho | } |
75 | 12154 | bsanchez | |
76 | 10740 | nacho | /**
|
77 | * Obtiene el control con el slider de recorte de colas
|
||
78 | * @return SliderTextContainer
|
||
79 | */
|
||
80 | 12154 | bsanchez | public SliderTextContainer getTrimSlider() {
|
81 | 12180 | bsanchez | if (trimSlider == null) { |
82 | 10740 | nacho | trimSlider = new SliderTextContainer(0, 100, 50); |
83 | 12180 | bsanchez | trimSlider.setDecimal(true);
|
84 | trimSlider.setBorder("");
|
||
85 | } |
||
86 | 10740 | nacho | return trimSlider;
|
87 | } |
||
88 | 12154 | bsanchez | |
89 | 12180 | bsanchez | public JPanel getPanel() { |
90 | if (panel == null) { |
||
91 | panel = new JPanel(); |
||
92 | panel.setLayout(new GridBagLayout()); |
||
93 | 10740 | nacho | 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 | 12154 | bsanchez | |
100 | 10740 | nacho | 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 | 12154 | bsanchez | |
107 | 12180 | bsanchez | panel.add(getRemoveCheck(), gbc); |
108 | panel.add(getTrimCheck(), gbc1); |
||
109 | 10740 | nacho | } |
110 | 12180 | bsanchez | return panel;
|
111 | 10740 | nacho | } |
112 | 12154 | bsanchez | |
113 | 10740 | nacho | /**
|
114 | * Obtiene el check de eliminar extremos
|
||
115 | * @return
|
||
116 | */
|
||
117 | 12180 | bsanchez | public JCheckBox getRemoveCheck() { |
118 | if (removeCheck == null) { |
||
119 | removeCheck = new JCheckBox(PluginServices.getText(this, "eliminar_extremos")); |
||
120 | } |
||
121 | return removeCheck;
|
||
122 | 10740 | nacho | } |
123 | 12154 | bsanchez | |
124 | 10740 | nacho | /**
|
125 | * Obtiene el check de recorte de colas
|
||
126 | * @return
|
||
127 | */
|
||
128 | 12180 | bsanchez | public JCheckBox getTrimCheck() { |
129 | if (trimCheck == null) { |
||
130 | 10740 | nacho | trimCheck = new JCheckBox(PluginServices.getText(this, "recorte_colas")); |
131 | 12180 | bsanchez | } |
132 | 10740 | nacho | return trimCheck;
|
133 | } |
||
134 | 12154 | bsanchez | |
135 | 10740 | nacho | /**
|
136 | * Activa o desactiva el control
|
||
137 | * @param enable true activa y false desactiva los controles del panel
|
||
138 | */
|
||
139 | 12154 | bsanchez | public void setControlEnabled(boolean enabled) { |
140 | 12180 | bsanchez | if (enabled && getTrimCheck().isSelected())
|
141 | getTrimSlider().setControlEnabled(true);
|
||
142 | 10740 | nacho | else
|
143 | 12180 | bsanchez | getTrimSlider().setControlEnabled(false);
|
144 | getRemoveCheck().setEnabled(enabled); |
||
145 | getTrimCheck().setEnabled(enabled); |
||
146 | 10740 | nacho | } |
147 | 12154 | bsanchez | |
148 | 10740 | nacho | /**
|
149 | * Maneja eventos de activar y desactivar el panel
|
||
150 | */
|
||
151 | public void actionPerformed(ActionEvent e) { |
||
152 | 12180 | bsanchez | if (e.getSource() == getTrimCheck())
|
153 | getTrimSlider().setControlEnabled(getTrimCheck().isSelected()); |
||
154 | 10740 | nacho | } |
155 | } |
||
156 | 12154 | bsanchez | |
157 | 10740 | nacho | /**
|
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 | 12154 | bsanchez | class SelectorPanel extends JPanel { |
164 | private static final long serialVersionUID = 9036702518290091787L; |
||
165 | private JRadioButton rb = null; |
||
166 | |||
167 | 10740 | nacho | /**
|
168 | * Constructor
|
||
169 | */
|
||
170 | 12154 | bsanchez | public SelectorPanel() {
|
171 | 10740 | nacho | setLayout(new GridLayout(1, 1)); |
172 | add(getLineal()); |
||
173 | } |
||
174 | 12154 | bsanchez | |
175 | 10740 | nacho | /**
|
176 | * Obtiene el radio button de selecci?n de filtro lineal
|
||
177 | * @return JRadioButton
|
||
178 | */
|
||
179 | 12154 | bsanchez | private JRadioButton getLineal() { |
180 | if (rb == null) { |
||
181 | 10740 | nacho | rb = new JRadioButton(PluginServices.getText(this, "lineal_directo")); |
182 | rb.setSelected(true);
|
||
183 | } |
||
184 | return rb;
|
||
185 | } |
||
186 | 12154 | bsanchez | |
187 | 10740 | nacho | /**
|
188 | * Activa o desactiva el control
|
||
189 | * @param enable true activa y false desactiva los controles del panel
|
||
190 | */
|
||
191 | 12154 | bsanchez | public void setControlEnabled(boolean enabled) { |
192 | 10740 | nacho | rb.setEnabled(enabled); |
193 | } |
||
194 | } |
||
195 | 12154 | bsanchez | |
196 | 10740 | nacho | /**
|
197 | * Contructor
|
||
198 | */
|
||
199 | 12154 | bsanchez | public EnhancedWithTrimPanel() {
|
200 | 10740 | nacho | super();
|
201 | initialize(); |
||
202 | } |
||
203 | 12154 | bsanchez | |
204 | 12180 | bsanchez | 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 | 10740 | nacho | 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 | 12180 | bsanchez | add(getSelectorPanel(), BorderLayout.CENTER);
|
223 | add(getTrimPanel(), BorderLayout.SOUTH);
|
||
224 | 10740 | nacho | getActive().addActionListener(this);
|
225 | } |
||
226 | 12154 | bsanchez | |
227 | 10740 | nacho | /**
|
228 | * Obtiene el check de activar
|
||
229 | * @return
|
||
230 | */
|
||
231 | 12154 | bsanchez | public JCheckBox getActive() { |
232 | if (active == null) { |
||
233 | 10740 | nacho | active = new JCheckBox(PluginServices.getText(this, "activar")); |
234 | active.setSelected(false);
|
||
235 | this.setControlEnabled(false); |
||
236 | } |
||
237 | return active;
|
||
238 | } |
||
239 | 12154 | bsanchez | |
240 | 10740 | nacho | /**
|
241 | * Activa o desactiva el control
|
||
242 | * @param enable true activa y false desactiva los controles del panel
|
||
243 | */
|
||
244 | 12154 | bsanchez | public void setControlEnabled(boolean enabled) { |
245 | 10740 | nacho | getActive().setSelected(enabled); |
246 | 12180 | bsanchez | getTrimPanel().setControlEnabled(enabled); |
247 | getSelectorPanel().setControlEnabled(enabled); |
||
248 | 10740 | nacho | } |
249 | 12154 | bsanchez | |
250 | 10740 | nacho | /**
|
251 | * Maneja eventos de activar y desactivar el panel
|
||
252 | */
|
||
253 | public void actionPerformed(ActionEvent e) { |
||
254 | 12154 | bsanchez | if (e.getSource() == getActive()) {
|
255 | if (getActive().isSelected())
|
||
256 | 10740 | nacho | setControlEnabled(true);
|
257 | else
|
||
258 | setControlEnabled(false);
|
||
259 | } |
||
260 | } |
||
261 | 12154 | bsanchez | |
262 | 10740 | nacho | /**
|
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 | 12154 | bsanchez | public boolean isRemoveEndsSelected() { |
267 | 12180 | bsanchez | return getTrimPanel().getRemoveCheck().isSelected();
|
268 | 10740 | nacho | } |
269 | 12154 | bsanchez | |
270 | 10740 | nacho | /**
|
271 | * Obtiene el valor de selecci?n del check de recorte de colas.
|
||
272 | 12154 | bsanchez | * @return boolean, true si est? seleccionado y false si no lo est?.
|
273 | 10740 | nacho | */
|
274 | 12154 | bsanchez | public boolean isTailTrimCheckSelected() { |
275 | 12180 | bsanchez | return getTrimPanel().getTrimCheck().isSelected();
|
276 | 10740 | nacho | } |
277 | 12154 | bsanchez | |
278 | 10740 | nacho | /**
|
279 | * Obtiene el valor de recorte de colas seleccionado en el slider
|
||
280 | * @return double
|
||
281 | */
|
||
282 | 12154 | bsanchez | public double getTrimValue() { |
283 | 12180 | bsanchez | return getTrimPanel().getTrimSlider().getValue();
|
284 | 10740 | nacho | } |
285 | 12154 | bsanchez | |
286 | 10740 | nacho | /**
|
287 | * Activa o desactiva el checkbox de recorte de colas
|
||
288 | * @param active true si deseamos activarlo y false para desactivarlo
|
||
289 | */
|
||
290 | 12154 | bsanchez | public void setTailTrimCheckActive(boolean active) { |
291 | 12180 | bsanchez | getTrimPanel().getTrimCheck().setSelected(active); |
292 | 10740 | nacho | } |
293 | 12154 | bsanchez | |
294 | 10740 | nacho | /**
|
295 | * Activa o desactiva el checkbox de eliminar extremos
|
||
296 | * @param active true si deseamos activarlo y false para desactivarlo
|
||
297 | */
|
||
298 | 12154 | bsanchez | public void setRemoveEndsActive(boolean active) { |
299 | 12180 | bsanchez | getTrimPanel().getRemoveCheck().setSelected(active); |
300 | 10740 | nacho | } |
301 | 12154 | bsanchez | |
302 | 10740 | nacho | /**
|
303 | * Asigna un valor al slider de porcentaje de recorte
|
||
304 | * @param active true si deseamos activarlo y false para desactivarlo
|
||
305 | */
|
||
306 | 12154 | bsanchez | public void setTailTrimValue(double value) { |
307 | 12180 | bsanchez | getTrimPanel().getTrimSlider().setValue(value); |
308 | 10740 | nacho | } |
309 | 12154 | bsanchez | |
310 | 10740 | nacho | /**
|
311 | * Selecciona un metodo de realce entre los disponibles (linear)
|
||
312 | * @param method
|
||
313 | */
|
||
314 | 12154 | bsanchez | public void setEnhancedMethod(int method) { |
315 | switch (method) {
|
||
316 | case LINEAR:
|
||
317 | break;
|
||
318 | 10740 | nacho | } |
319 | } |
||
320 | 12154 | bsanchez | } |