svn-gvsig-desktop / branches / v06 / libraries / libCq CMS for java.old / src / org / cresques / ui / raster / EnhancedPanel.java @ 4813
History | View | Annotate | Download (14 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.cresques.ui.raster; |
25 |
|
26 |
import java.awt.BorderLayout; |
27 |
import java.awt.FlowLayout; |
28 |
import java.awt.GridBagConstraints; |
29 |
import java.awt.GridBagLayout; |
30 |
import java.awt.Image; |
31 |
|
32 |
import javax.swing.ButtonGroup; |
33 |
import javax.swing.ImageIcon; |
34 |
import javax.swing.JCheckBox; |
35 |
import javax.swing.JLabel; |
36 |
import javax.swing.JPanel; |
37 |
import javax.swing.JRadioButton; |
38 |
import javax.swing.JSlider; |
39 |
import javax.swing.JTextField; |
40 |
|
41 |
|
42 |
/**
|
43 |
* Panel que contiene los elementos para el dialogo del filtro de realce
|
44 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
45 |
*/
|
46 |
public class EnhancedPanel extends JPanel { |
47 |
final private static long serialVersionUID = -3370601314380922368L; |
48 |
/**
|
49 |
* Nombre del panel
|
50 |
*/
|
51 |
private String nom = "Realce"; |
52 |
FilterRasterDialogPanel parent = null;
|
53 |
private JPanel jPanel = null; |
54 |
private JPanel jPanel1 = null; |
55 |
private JPanel jPanel2 = null; |
56 |
private JPanel jPanel3 = null; |
57 |
private JRadioButton jRadioButton = null; |
58 |
private JRadioButton jRadioButton1 = null; |
59 |
private JCheckBox jCheckBox = null; |
60 |
|
61 |
/**
|
62 |
* Variable accesible para la traducci?n
|
63 |
*/
|
64 |
public JLabel lLineal = null; |
65 |
|
66 |
/**
|
67 |
* Variable accesible para la traducci?n
|
68 |
*/
|
69 |
public JLabel lWithoutEnhanced = null; |
70 |
|
71 |
/**
|
72 |
* Variable accesible para la traducci?n
|
73 |
*/
|
74 |
public JPanel pGeneralEnhanced = null; |
75 |
private ButtonGroup grupo = new ButtonGroup(); |
76 |
private Image iconoLineal = null; |
77 |
private Image iconoSinRealce = null; |
78 |
private JPanel jPanel5 = null; |
79 |
private JSlider jSlider = null; |
80 |
private JTextField jTextField = null; |
81 |
private JPanel jPanel6 = null; |
82 |
private JCheckBox jCheckBox1 = null; |
83 |
|
84 |
/**
|
85 |
* Variable accesible para la traducci?n
|
86 |
*/
|
87 |
public JLabel lCut = null; |
88 |
|
89 |
/**
|
90 |
* Variable accesible para la traducci?n
|
91 |
*/
|
92 |
public JPanel pTail = null; |
93 |
|
94 |
/**
|
95 |
* Variable accesible para la traducci?n
|
96 |
*/
|
97 |
public JLabel lQueue = null; |
98 |
|
99 |
/**
|
100 |
* Variable accesible para su traducci?n
|
101 |
*/
|
102 |
public JPanel pSlider = null; |
103 |
|
104 |
/**
|
105 |
* Variable accesible para la traducci?n
|
106 |
*/
|
107 |
public JPanel pRemove = null; |
108 |
|
109 |
/**
|
110 |
* Variable accesible para la traducci?n
|
111 |
*/
|
112 |
public JLabel lRemove = null; |
113 |
|
114 |
/**
|
115 |
* Constructor.
|
116 |
* @param parent
|
117 |
*/
|
118 |
public EnhancedPanel(FilterRasterDialogPanel parent) {
|
119 |
this.parent = parent;
|
120 |
initialize(); |
121 |
} |
122 |
|
123 |
/**
|
124 |
* This method initializes this
|
125 |
*
|
126 |
* @return void
|
127 |
*/
|
128 |
private void initialize() { |
129 |
this.setLayout(new BorderLayout()); |
130 |
this.setSize(445, 239); |
131 |
this.setPreferredSize(new java.awt.Dimension(445, 239)); |
132 |
this.add(getJPanel(), java.awt.BorderLayout.CENTER);
|
133 |
|
134 |
initControls(); |
135 |
} |
136 |
|
137 |
/**
|
138 |
* Obtiene el nombre del panel
|
139 |
* @return Cadena con el nombre del panel
|
140 |
*/
|
141 |
public String getName(){ |
142 |
return this.nom; |
143 |
} |
144 |
|
145 |
/**
|
146 |
* Inicializa controles a sus valores por defecto
|
147 |
*/
|
148 |
public void initControls() { |
149 |
jRadioButton1.setSelected(true);
|
150 |
this.getTailText().setText("0.0"); |
151 |
this.getTailSlider().setValue(0); |
152 |
this.setActiveTailControl(false); |
153 |
this.getTailCheck().setEnabled(false); |
154 |
this.getRemoveCheck().setEnabled(false); |
155 |
} |
156 |
|
157 |
/**
|
158 |
* This method initializes jPanel
|
159 |
*
|
160 |
* @return javax.swing.JPanel
|
161 |
*/
|
162 |
private JPanel getJPanel() { |
163 |
if (jPanel == null) { |
164 |
FlowLayout flowLayout2 = new FlowLayout(); |
165 |
GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
166 |
jPanel = new JPanel(); |
167 |
jPanel.setLayout(flowLayout2); |
168 |
gridBagConstraints4.gridx = 0;
|
169 |
gridBagConstraints4.gridy = 0;
|
170 |
jPanel.setPreferredSize(new java.awt.Dimension(445, 239)); |
171 |
flowLayout2.setAlignment(java.awt.FlowLayout.CENTER); |
172 |
jPanel.add(getJPanel4(), null);
|
173 |
jPanel.add(getJPanel8(), null);
|
174 |
} |
175 |
|
176 |
return jPanel;
|
177 |
} |
178 |
|
179 |
/**
|
180 |
* This method initializes jPanel1
|
181 |
*
|
182 |
* @return javax.swing.JPanel
|
183 |
*/
|
184 |
private JPanel getJPanel1() { |
185 |
if (jPanel1 == null) { |
186 |
lLineal = new JLabel("Lineal directo", |
187 |
new ImageIcon("images/lineal.gif"), |
188 |
JLabel.CENTER);
|
189 |
jPanel1 = new JPanel(); |
190 |
jPanel1.setLayout(new BorderLayout()); |
191 |
jPanel1.add(getLinealDirectoRadioButton(), |
192 |
java.awt.BorderLayout.WEST); |
193 |
jPanel1.add(lLineal, java.awt.BorderLayout.EAST); |
194 |
} |
195 |
|
196 |
return jPanel1;
|
197 |
} |
198 |
|
199 |
/**
|
200 |
* This method initializes jPanel2
|
201 |
*
|
202 |
* @return javax.swing.JPanel
|
203 |
*/
|
204 |
private JPanel getJPanel2() { |
205 |
if (jPanel2 == null) { |
206 |
jPanel2 = new JPanel(); |
207 |
jPanel2.setLayout(new BorderLayout()); |
208 |
jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, |
209 |
1));
|
210 |
jPanel2.setPreferredSize(new java.awt.Dimension(220, 95)); |
211 |
jPanel2.add(getJPanel5(), java.awt.BorderLayout.CENTER); |
212 |
jPanel2.add(getJPanel6(), java.awt.BorderLayout.SOUTH); |
213 |
jPanel2.add(getJPanel7(), java.awt.BorderLayout.NORTH); |
214 |
} |
215 |
|
216 |
return jPanel2;
|
217 |
} |
218 |
|
219 |
/**
|
220 |
* This method initializes jPanel3
|
221 |
*
|
222 |
* @return javax.swing.JPanel
|
223 |
*/
|
224 |
private JPanel getJPanel3() { |
225 |
if (jPanel3 == null) { |
226 |
lWithoutEnhanced = new JLabel("Sin Realce", |
227 |
new ImageIcon("images/sinrealce.gif"), |
228 |
JLabel.CENTER);
|
229 |
jPanel3 = new JPanel(); |
230 |
jPanel3.setLayout(new BorderLayout()); |
231 |
jPanel3.add(getSinRealceRadioButton(), java.awt.BorderLayout.WEST); |
232 |
jPanel3.add(lWithoutEnhanced, java.awt.BorderLayout.EAST); |
233 |
} |
234 |
|
235 |
return jPanel3;
|
236 |
} |
237 |
|
238 |
/**
|
239 |
* This method initializes jRadioButton
|
240 |
*
|
241 |
* @return javax.swing.JRadioButton
|
242 |
*/
|
243 |
public JRadioButton getLinealDirectoRadioButton() { |
244 |
if (jRadioButton == null) { |
245 |
jRadioButton = new JRadioButton(); |
246 |
grupo.add(jRadioButton); |
247 |
} |
248 |
|
249 |
return jRadioButton;
|
250 |
} |
251 |
|
252 |
/**
|
253 |
* This method initializes jRadioButton1
|
254 |
*
|
255 |
* @return javax.swing.JRadioButton
|
256 |
*/
|
257 |
public JRadioButton getSinRealceRadioButton() { |
258 |
if (jRadioButton1 == null) { |
259 |
jRadioButton1 = new JRadioButton(); |
260 |
jRadioButton1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); |
261 |
grupo.add(jRadioButton1); |
262 |
} |
263 |
|
264 |
return jRadioButton1;
|
265 |
} |
266 |
|
267 |
/**
|
268 |
* This method initializes jCheckBox
|
269 |
*
|
270 |
* @return javax.swing.JCheckBox
|
271 |
*/
|
272 |
public JCheckBox getTailCheck() { |
273 |
if (jCheckBox == null) { |
274 |
jCheckBox = new JCheckBox(); |
275 |
} |
276 |
|
277 |
return jCheckBox;
|
278 |
} |
279 |
|
280 |
/**
|
281 |
* This method initializes jPanel4
|
282 |
*
|
283 |
* @return javax.swing.JPanel
|
284 |
*/
|
285 |
private JPanel getJPanel4() { |
286 |
if (pGeneralEnhanced == null) { |
287 |
GridBagConstraints gridBagConstraints10 = new GridBagConstraints(); |
288 |
GridBagConstraints gridBagConstraints9 = new GridBagConstraints(); |
289 |
pGeneralEnhanced = new JPanel(); |
290 |
pGeneralEnhanced.setLayout(new GridBagLayout()); |
291 |
gridBagConstraints9.gridx = 0;
|
292 |
gridBagConstraints9.gridy = 0;
|
293 |
gridBagConstraints9.insets = new java.awt.Insets(5, 0, 5, 2); |
294 |
gridBagConstraints9.anchor = java.awt.GridBagConstraints.WEST; |
295 |
gridBagConstraints10.gridx = 0;
|
296 |
gridBagConstraints10.gridy = 1;
|
297 |
gridBagConstraints10.insets = new java.awt.Insets(5, 0, 5, 5); |
298 |
pGeneralEnhanced.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, |
299 |
0, 0)); |
300 |
pGeneralEnhanced.setPreferredSize(new java.awt.Dimension(175, 200)); |
301 |
pGeneralEnhanced.add(getJPanel3(), gridBagConstraints9); |
302 |
pGeneralEnhanced.add(getJPanel1(), gridBagConstraints10); |
303 |
} |
304 |
|
305 |
return pGeneralEnhanced;
|
306 |
} |
307 |
|
308 |
/**
|
309 |
* This method initializes jPanel5
|
310 |
*
|
311 |
* @return javax.swing.JPanel
|
312 |
*/
|
313 |
private JPanel getJPanel5() { |
314 |
if (jPanel5 == null) { |
315 |
jPanel5 = new JPanel(); |
316 |
jPanel5.add(getTailSlider(), null);
|
317 |
} |
318 |
|
319 |
return jPanel5;
|
320 |
} |
321 |
|
322 |
/**
|
323 |
* This method initializes jSlider
|
324 |
*
|
325 |
* @return javax.swing.JSlider
|
326 |
*/
|
327 |
public JSlider getTailSlider() { |
328 |
if (jSlider == null) { |
329 |
jSlider = new JSlider(); |
330 |
jSlider.setPreferredSize(new java.awt.Dimension(240, 16)); |
331 |
} |
332 |
|
333 |
return jSlider;
|
334 |
} |
335 |
|
336 |
/**
|
337 |
* This method initializes jTextField
|
338 |
*
|
339 |
* @return javax.swing.JTextField
|
340 |
*/
|
341 |
public JTextField getTailText() { |
342 |
if (jTextField == null) { |
343 |
jTextField = new JTextField(); |
344 |
jTextField.setPreferredSize(new java.awt.Dimension(40, 19)); |
345 |
jTextField.setText("0.0");
|
346 |
} |
347 |
|
348 |
return jTextField;
|
349 |
} |
350 |
|
351 |
/**
|
352 |
* Activa/Desactiva los controles de Recorte de colas
|
353 |
* @param active
|
354 |
*/
|
355 |
public void setActiveTailControl(boolean active) { |
356 |
this.getTailSlider().setEnabled(active);
|
357 |
this.getTailText().setEnabled(active);
|
358 |
this.lQueue.setEnabled(active);
|
359 |
this.lCut.setEnabled(active);
|
360 |
} |
361 |
|
362 |
/**
|
363 |
*
|
364 |
* @param active
|
365 |
*/
|
366 |
public void setActiveRemoveCheck(boolean active) { |
367 |
this.getRemoveCheck().setEnabled(active);
|
368 |
this.lRemove.setEnabled(active);
|
369 |
} |
370 |
|
371 |
/**
|
372 |
* Asigna el procentaje de recorte de colas aplicado
|
373 |
* @param tail
|
374 |
*/
|
375 |
public void setPercentTail(int tail) { |
376 |
jTextField.setText(String.valueOf(tail));
|
377 |
jSlider.setValue(tail); |
378 |
} |
379 |
|
380 |
/**
|
381 |
* Asigna el filtro seleccionado cuando se abre el dialogo
|
382 |
* @param filter
|
383 |
*/
|
384 |
public void setSelectedFilter(int filter) { |
385 |
switch (filter) {
|
386 |
case 0: |
387 |
jRadioButton1.setSelected(true); //Sin realce |
388 |
jCheckBox.setEnabled(false);
|
389 |
setActiveTailControl(false);
|
390 |
this.setActiveRemoveCheck(false); |
391 |
|
392 |
break;
|
393 |
|
394 |
case 1: |
395 |
this.getRemoveCheck().setSelected(true); |
396 |
|
397 |
case 2: |
398 |
jRadioButton.setSelected(true); //Realce lineal |
399 |
this.getTailCheck().setEnabled(true); |
400 |
this.setActiveRemoveCheck(true); |
401 |
|
402 |
if (!this.getTailText().getText().equals("") && |
403 |
!this.getTailText().getText().equals("0.0")) { |
404 |
this.getTailCheck().setSelected(true); |
405 |
this.setActiveTailControl(true); |
406 |
} |
407 |
|
408 |
break;
|
409 |
} |
410 |
} |
411 |
|
412 |
/**
|
413 |
* This method initializes jPanel6
|
414 |
*
|
415 |
* @return javax.swing.JPanel
|
416 |
*/
|
417 |
private JPanel getJPanel6() { |
418 |
if (jPanel6 == null) { |
419 |
FlowLayout flowLayout3 = new FlowLayout(); |
420 |
lCut = new JLabel(); |
421 |
jPanel6 = new JPanel(); |
422 |
jPanel6.setLayout(flowLayout3); |
423 |
lCut.setText("% recorte");
|
424 |
flowLayout3.setAlignment(java.awt.FlowLayout.LEFT); |
425 |
jPanel6.add(getTailText(), null);
|
426 |
jPanel6.add(lCut, null);
|
427 |
} |
428 |
|
429 |
return jPanel6;
|
430 |
} |
431 |
|
432 |
/**
|
433 |
* This method initializes jCheckBox1
|
434 |
*
|
435 |
* @return javax.swing.JCheckBox
|
436 |
*/
|
437 |
public JCheckBox getRemoveCheck() { |
438 |
if (jCheckBox1 == null) { |
439 |
jCheckBox1 = new JCheckBox(); |
440 |
} |
441 |
|
442 |
return jCheckBox1;
|
443 |
} |
444 |
|
445 |
/**
|
446 |
* This method initializes jPanel7
|
447 |
*
|
448 |
* @return javax.swing.JPanel
|
449 |
*/
|
450 |
private JPanel getJPanel7() { |
451 |
if (pTail == null) { |
452 |
lQueue = new JLabel(); |
453 |
|
454 |
FlowLayout flowLayout1 = new FlowLayout(); |
455 |
pTail = new JPanel(); |
456 |
pTail.setLayout(flowLayout1); |
457 |
lQueue.setText("Recorte de colas");
|
458 |
flowLayout1.setAlignment(java.awt.FlowLayout.LEFT); |
459 |
pTail.add(getTailCheck(), null);
|
460 |
pTail.add(lQueue, null);
|
461 |
} |
462 |
|
463 |
return pTail;
|
464 |
} |
465 |
|
466 |
/**
|
467 |
* This method initializes jPanel8
|
468 |
*
|
469 |
* @return javax.swing.JPanel
|
470 |
*/
|
471 |
private JPanel getJPanel8() { |
472 |
if (pSlider == null) { |
473 |
pSlider = new JPanel(); |
474 |
pSlider.setLayout(new BorderLayout()); |
475 |
pSlider.setPreferredSize(new java.awt.Dimension(250, 130)); |
476 |
pSlider.add(getJPanel2(), java.awt.BorderLayout.SOUTH); |
477 |
pSlider.add(getJPanel9(), java.awt.BorderLayout.NORTH); |
478 |
} |
479 |
|
480 |
return pSlider;
|
481 |
} |
482 |
|
483 |
/**
|
484 |
* This method initializes jPanel9
|
485 |
*
|
486 |
* @return javax.swing.JPanel
|
487 |
*/
|
488 |
private JPanel getJPanel9() { |
489 |
if (pRemove == null) { |
490 |
lRemove = new JLabel(); |
491 |
|
492 |
FlowLayout flowLayout11 = new FlowLayout(); |
493 |
pRemove = new JPanel(); |
494 |
pRemove.setLayout(flowLayout11); |
495 |
lRemove.setText("Eliminar Extremos");
|
496 |
flowLayout11.setAlignment(java.awt.FlowLayout.LEFT); |
497 |
pRemove.add(getRemoveCheck(), null);
|
498 |
pRemove.add(lRemove, null);
|
499 |
} |
500 |
|
501 |
return pRemove;
|
502 |
} |
503 |
} // @jve:decl-index=0:visual-constraint="36,15"
|