svn-gvsig-desktop / branches / v10 / libraries / libCq CMS for java.old / src / org / cresques / ui / filter / EnhancedPanel.java @ 9056
History | View | Annotate | Download (16.8 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.filter; |
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 |
import java.awt.event.ComponentEvent; |
32 |
import java.awt.event.ComponentListener; |
33 |
|
34 |
import javax.swing.ButtonGroup; |
35 |
import javax.swing.ImageIcon; |
36 |
import javax.swing.JCheckBox; |
37 |
import javax.swing.JLabel; |
38 |
import javax.swing.JPanel; |
39 |
import javax.swing.JRadioButton; |
40 |
import javax.swing.JSlider; |
41 |
import javax.swing.JTextField; |
42 |
|
43 |
|
44 |
|
45 |
/**
|
46 |
* Panel que contiene los elementos para el dialogo del filtro de realce
|
47 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
48 |
*/
|
49 |
public class EnhancedPanel extends JPanel implements ComponentListener{ |
50 |
final private static long serialVersionUID = -3370601314380922368L; |
51 |
/**
|
52 |
* Nombre del panel
|
53 |
*/
|
54 |
private String nom = "Realce"; |
55 |
FilterRasterDialogPanel parent = null;
|
56 |
private JPanel jPanel = null; |
57 |
private JPanel jPanel1 = null; |
58 |
private JPanel jPanel2 = null; |
59 |
private JPanel jPanel3 = null; |
60 |
private JRadioButton jRadioButton = null; |
61 |
private JRadioButton jRadioButton1 = null; |
62 |
private JCheckBox jCheckBox = null; |
63 |
|
64 |
/**
|
65 |
* Variable accesible para la traducci?n
|
66 |
*/
|
67 |
public JLabel lLineal = null; |
68 |
|
69 |
/**
|
70 |
* Variable accesible para la traducci?n
|
71 |
*/
|
72 |
public JLabel lWithoutEnhanced = null; |
73 |
|
74 |
/**
|
75 |
* Variable accesible para la traducci?n
|
76 |
*/
|
77 |
public JPanel pGeneralEnhanced = null; |
78 |
private ButtonGroup grupo = new ButtonGroup(); |
79 |
private Image iconoLineal = null; |
80 |
private Image iconoSinRealce = null; |
81 |
private JPanel jPanel5 = null; |
82 |
private JSlider jSlider = null; |
83 |
private JTextField jTextField = null; |
84 |
private JPanel jPanel6 = null; |
85 |
private JCheckBox jCheckBox1 = null; |
86 |
|
87 |
/**
|
88 |
* Variable accesible para la traducci?n
|
89 |
*/
|
90 |
public JLabel lCut = null; |
91 |
|
92 |
/**
|
93 |
* Variable accesible para la traducci?n
|
94 |
*/
|
95 |
public JPanel pTail = null; |
96 |
|
97 |
/**
|
98 |
* Variable accesible para la traducci?n
|
99 |
*/
|
100 |
public JLabel lQueue = null; |
101 |
|
102 |
/**
|
103 |
* Variable accesible para su traducci?n
|
104 |
*/
|
105 |
public JPanel pSlider = null; |
106 |
|
107 |
/**
|
108 |
* Variable accesible para la traducci?n
|
109 |
*/
|
110 |
public JPanel pRemove = null; |
111 |
|
112 |
/**
|
113 |
* Variable accesible para la traducci?n
|
114 |
*/
|
115 |
public JLabel lRemove = null; |
116 |
|
117 |
/**
|
118 |
* Constructor.
|
119 |
* @param parent
|
120 |
*/
|
121 |
public EnhancedPanel(FilterRasterDialogPanel parent) {
|
122 |
this.parent = parent;
|
123 |
initialize(); |
124 |
} |
125 |
|
126 |
/**
|
127 |
* This method initializes this
|
128 |
*
|
129 |
* @return void
|
130 |
*/
|
131 |
private void initialize() { |
132 |
this.setLayout(new BorderLayout()); |
133 |
this.setSize(445, 239); |
134 |
this.setPreferredSize(new java.awt.Dimension(445, 239)); |
135 |
this.add(getJPanel(), java.awt.BorderLayout.CENTER);
|
136 |
|
137 |
initControls(); |
138 |
this.addComponentListener(this); |
139 |
} |
140 |
|
141 |
/**
|
142 |
* Obtiene el nombre del panel
|
143 |
* @return Cadena con el nombre del panel
|
144 |
*/
|
145 |
public String getName(){ |
146 |
return this.nom; |
147 |
} |
148 |
|
149 |
/**
|
150 |
* Inicializa controles a sus valores por defecto
|
151 |
*/
|
152 |
public void initControls() { |
153 |
jRadioButton1.setSelected(true);
|
154 |
this.getTailText().setText("0.0"); |
155 |
this.getTailSlider().setValue(0); |
156 |
this.setActiveTailControl(false); |
157 |
this.getTailCheck().setEnabled(false); |
158 |
this.getRemoveCheck().setEnabled(false); |
159 |
} |
160 |
|
161 |
/**
|
162 |
* This method initializes jPanel
|
163 |
*
|
164 |
* @return javax.swing.JPanel
|
165 |
*/
|
166 |
private JPanel getJPanel() { |
167 |
if (jPanel == null) { |
168 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
169 |
gridBagConstraints1.insets = new java.awt.Insets(40,3,69,8); |
170 |
gridBagConstraints1.gridy = 0;
|
171 |
gridBagConstraints1.gridx = 1;
|
172 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
173 |
gridBagConstraints.insets = new java.awt.Insets(5,7,34,2); |
174 |
gridBagConstraints.gridy = 0;
|
175 |
gridBagConstraints.gridx = 0;
|
176 |
GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
177 |
jPanel = new JPanel(); |
178 |
jPanel.setLayout(new GridBagLayout()); |
179 |
gridBagConstraints4.gridx = 0;
|
180 |
gridBagConstraints4.gridy = 0;
|
181 |
jPanel.setPreferredSize(new java.awt.Dimension(445, 239)); |
182 |
jPanel.add(getJPanel4(), gridBagConstraints); |
183 |
jPanel.add(getJPanel8(), gridBagConstraints1); |
184 |
} |
185 |
|
186 |
return jPanel;
|
187 |
} |
188 |
|
189 |
/**
|
190 |
* This method initializes jPanel1
|
191 |
*
|
192 |
* @return javax.swing.JPanel
|
193 |
*/
|
194 |
private JPanel getJPanel1() { |
195 |
if (jPanel1 == null) { |
196 |
lLineal = new JLabel("Lineal directo", |
197 |
new ImageIcon("images/lineal.gif"), |
198 |
JLabel.CENTER);
|
199 |
jPanel1 = new JPanel(); |
200 |
jPanel1.setLayout(new BorderLayout()); |
201 |
jPanel1.add(getLinealDirectoRadioButton(), |
202 |
java.awt.BorderLayout.WEST); |
203 |
jPanel1.add(lLineal, java.awt.BorderLayout.EAST); |
204 |
} |
205 |
|
206 |
return jPanel1;
|
207 |
} |
208 |
|
209 |
/**
|
210 |
* This method initializes jPanel2
|
211 |
*
|
212 |
* @return javax.swing.JPanel
|
213 |
*/
|
214 |
private JPanel getJPanel2() { |
215 |
if (jPanel2 == null) { |
216 |
jPanel2 = new JPanel(); |
217 |
jPanel2.setLayout(new BorderLayout()); |
218 |
jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, |
219 |
1));
|
220 |
jPanel2.setPreferredSize(new java.awt.Dimension(220, 95)); |
221 |
jPanel2.add(getJPanel5(), java.awt.BorderLayout.CENTER); |
222 |
jPanel2.add(getJPanel6(), java.awt.BorderLayout.SOUTH); |
223 |
jPanel2.add(getJPanel7(), java.awt.BorderLayout.NORTH); |
224 |
} |
225 |
|
226 |
return jPanel2;
|
227 |
} |
228 |
|
229 |
/**
|
230 |
* This method initializes jPanel3
|
231 |
*
|
232 |
* @return javax.swing.JPanel
|
233 |
*/
|
234 |
private JPanel getJPanel3() { |
235 |
if (jPanel3 == null) { |
236 |
lWithoutEnhanced = new JLabel("Sin Realce", |
237 |
new ImageIcon("images/sinrealce.gif"), |
238 |
JLabel.CENTER);
|
239 |
jPanel3 = new JPanel(); |
240 |
jPanel3.setLayout(new BorderLayout()); |
241 |
jPanel3.add(getSinRealceRadioButton(), java.awt.BorderLayout.WEST); |
242 |
jPanel3.add(lWithoutEnhanced, java.awt.BorderLayout.EAST); |
243 |
} |
244 |
|
245 |
return jPanel3;
|
246 |
} |
247 |
|
248 |
/**
|
249 |
* This method initializes jRadioButton
|
250 |
*
|
251 |
* @return javax.swing.JRadioButton
|
252 |
*/
|
253 |
public JRadioButton getLinealDirectoRadioButton() { |
254 |
if (jRadioButton == null) { |
255 |
jRadioButton = new JRadioButton(); |
256 |
grupo.add(jRadioButton); |
257 |
} |
258 |
|
259 |
return jRadioButton;
|
260 |
} |
261 |
|
262 |
/**
|
263 |
* This method initializes jRadioButton1
|
264 |
*
|
265 |
* @return javax.swing.JRadioButton
|
266 |
*/
|
267 |
public JRadioButton getSinRealceRadioButton() { |
268 |
if (jRadioButton1 == null) { |
269 |
jRadioButton1 = new JRadioButton(); |
270 |
jRadioButton1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); |
271 |
grupo.add(jRadioButton1); |
272 |
} |
273 |
|
274 |
return jRadioButton1;
|
275 |
} |
276 |
|
277 |
/**
|
278 |
* This method initializes jCheckBox
|
279 |
*
|
280 |
* @return javax.swing.JCheckBox
|
281 |
*/
|
282 |
public JCheckBox getTailCheck() { |
283 |
if (jCheckBox == null) { |
284 |
jCheckBox = new JCheckBox(); |
285 |
} |
286 |
|
287 |
return jCheckBox;
|
288 |
} |
289 |
|
290 |
/**
|
291 |
* This method initializes jPanel4
|
292 |
*
|
293 |
* @return javax.swing.JPanel
|
294 |
*/
|
295 |
private JPanel getJPanel4() { |
296 |
if (pGeneralEnhanced == null) { |
297 |
GridBagConstraints gridBagConstraints10 = new GridBagConstraints(); |
298 |
GridBagConstraints gridBagConstraints9 = new GridBagConstraints(); |
299 |
pGeneralEnhanced = new JPanel(); |
300 |
pGeneralEnhanced.setLayout(new GridBagLayout()); |
301 |
gridBagConstraints9.gridx = 0;
|
302 |
gridBagConstraints9.gridy = 0;
|
303 |
gridBagConstraints9.insets = new java.awt.Insets(5, 0, 5, 2); |
304 |
gridBagConstraints9.anchor = java.awt.GridBagConstraints.WEST; |
305 |
gridBagConstraints10.gridx = 0;
|
306 |
gridBagConstraints10.gridy = 1;
|
307 |
gridBagConstraints10.insets = new java.awt.Insets(5, 0, 5, 5); |
308 |
pGeneralEnhanced.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, |
309 |
0, 0)); |
310 |
pGeneralEnhanced.setPreferredSize(new java.awt.Dimension(175, 200)); |
311 |
pGeneralEnhanced.add(getJPanel3(), gridBagConstraints9); |
312 |
pGeneralEnhanced.add(getJPanel1(), gridBagConstraints10); |
313 |
} |
314 |
|
315 |
return pGeneralEnhanced;
|
316 |
} |
317 |
|
318 |
/**
|
319 |
* This method initializes jPanel5
|
320 |
*
|
321 |
* @return javax.swing.JPanel
|
322 |
*/
|
323 |
private JPanel getJPanel5() { |
324 |
if (jPanel5 == null) { |
325 |
jPanel5 = new JPanel(); |
326 |
jPanel5.add(getTailSlider(), null);
|
327 |
} |
328 |
|
329 |
return jPanel5;
|
330 |
} |
331 |
|
332 |
/**
|
333 |
* This method initializes jSlider
|
334 |
*
|
335 |
* @return javax.swing.JSlider
|
336 |
*/
|
337 |
public JSlider getTailSlider() { |
338 |
if (jSlider == null) { |
339 |
jSlider = new JSlider(); |
340 |
jSlider.setPreferredSize(new java.awt.Dimension(240, 16)); |
341 |
} |
342 |
|
343 |
return jSlider;
|
344 |
} |
345 |
|
346 |
/**
|
347 |
* This method initializes jTextField
|
348 |
*
|
349 |
* @return javax.swing.JTextField
|
350 |
*/
|
351 |
public JTextField getTailText() { |
352 |
if (jTextField == null) { |
353 |
jTextField = new JTextField(); |
354 |
jTextField.setPreferredSize(new java.awt.Dimension(40, 19)); |
355 |
jTextField.setText("0.0");
|
356 |
} |
357 |
|
358 |
return jTextField;
|
359 |
} |
360 |
|
361 |
/**
|
362 |
* Activa/Desactiva los controles de Recorte de colas
|
363 |
* @param active
|
364 |
*/
|
365 |
public void setActiveTailControl(boolean active) { |
366 |
this.getTailSlider().setEnabled(active);
|
367 |
this.getTailText().setEnabled(active);
|
368 |
this.lQueue.setEnabled(active);
|
369 |
this.lCut.setEnabled(active);
|
370 |
} |
371 |
|
372 |
/**
|
373 |
*
|
374 |
* @param active
|
375 |
*/
|
376 |
public void setActiveRemoveCheck(boolean active) { |
377 |
this.getRemoveCheck().setEnabled(active);
|
378 |
this.lRemove.setEnabled(active);
|
379 |
} |
380 |
|
381 |
/**
|
382 |
* Asigna el procentaje de recorte de colas aplicado
|
383 |
* @param tail
|
384 |
*/
|
385 |
public void setPercentTail(int tail) { |
386 |
jTextField.setText(String.valueOf(tail));
|
387 |
jSlider.setValue(tail); |
388 |
} |
389 |
|
390 |
/**
|
391 |
* Asigna el filtro seleccionado cuando se abre el dialogo
|
392 |
* @param filter
|
393 |
*/
|
394 |
public void setSelectedFilter(int filter) { |
395 |
switch (filter) {
|
396 |
case 0: |
397 |
jRadioButton1.setSelected(true); //Sin realce |
398 |
jCheckBox.setEnabled(false);
|
399 |
setActiveTailControl(false);
|
400 |
this.setActiveRemoveCheck(false); |
401 |
|
402 |
break;
|
403 |
|
404 |
case 1: |
405 |
this.getRemoveCheck().setSelected(true); |
406 |
|
407 |
case 2: |
408 |
jRadioButton.setSelected(true); //Realce lineal |
409 |
this.getTailCheck().setEnabled(true); |
410 |
this.setActiveRemoveCheck(true); |
411 |
|
412 |
if (!this.getTailText().getText().equals("") && |
413 |
!this.getTailText().getText().equals("0.0")) { |
414 |
this.getTailCheck().setSelected(true); |
415 |
this.setActiveTailControl(true); |
416 |
} |
417 |
|
418 |
break;
|
419 |
} |
420 |
} |
421 |
|
422 |
/**
|
423 |
* This method initializes jPanel6
|
424 |
*
|
425 |
* @return javax.swing.JPanel
|
426 |
*/
|
427 |
private JPanel getJPanel6() { |
428 |
if (jPanel6 == null) { |
429 |
FlowLayout flowLayout3 = new FlowLayout(); |
430 |
lCut = new JLabel(); |
431 |
jPanel6 = new JPanel(); |
432 |
jPanel6.setLayout(flowLayout3); |
433 |
lCut.setText("% recorte");
|
434 |
flowLayout3.setAlignment(java.awt.FlowLayout.LEFT); |
435 |
jPanel6.add(getTailText(), null);
|
436 |
jPanel6.add(lCut, null);
|
437 |
} |
438 |
|
439 |
return jPanel6;
|
440 |
} |
441 |
|
442 |
/**
|
443 |
* This method initializes jCheckBox1
|
444 |
*
|
445 |
* @return javax.swing.JCheckBox
|
446 |
*/
|
447 |
public JCheckBox getRemoveCheck() { |
448 |
if (jCheckBox1 == null) { |
449 |
jCheckBox1 = new JCheckBox(); |
450 |
} |
451 |
|
452 |
return jCheckBox1;
|
453 |
} |
454 |
|
455 |
/**
|
456 |
* This method initializes jPanel7
|
457 |
*
|
458 |
* @return javax.swing.JPanel
|
459 |
*/
|
460 |
private JPanel getJPanel7() { |
461 |
if (pTail == null) { |
462 |
lQueue = new JLabel(); |
463 |
|
464 |
FlowLayout flowLayout1 = new FlowLayout(); |
465 |
pTail = new JPanel(); |
466 |
pTail.setLayout(flowLayout1); |
467 |
lQueue.setText("Recorte de colas");
|
468 |
flowLayout1.setAlignment(java.awt.FlowLayout.LEFT); |
469 |
pTail.add(getTailCheck(), null);
|
470 |
pTail.add(lQueue, null);
|
471 |
} |
472 |
|
473 |
return pTail;
|
474 |
} |
475 |
|
476 |
/**
|
477 |
* This method initializes jPanel8
|
478 |
*
|
479 |
* @return javax.swing.JPanel
|
480 |
*/
|
481 |
private JPanel getJPanel8() { |
482 |
if (pSlider == null) { |
483 |
GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
484 |
gridBagConstraints3.insets = new java.awt.Insets(0,0,2,0); |
485 |
gridBagConstraints3.gridy = 0;
|
486 |
gridBagConstraints3.ipadx = 101;
|
487 |
gridBagConstraints3.gridx = 0;
|
488 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
489 |
gridBagConstraints2.insets = new java.awt.Insets(2,0,0,0); |
490 |
gridBagConstraints2.gridy = 1;
|
491 |
gridBagConstraints2.ipadx = 30;
|
492 |
gridBagConstraints2.gridx = 0;
|
493 |
pSlider = new JPanel(); |
494 |
pSlider.setLayout(new GridBagLayout()); |
495 |
pSlider.setPreferredSize(new java.awt.Dimension(250, 130)); |
496 |
pSlider.add(getJPanel2(), gridBagConstraints2); |
497 |
pSlider.add(getJPanel9(), gridBagConstraints3); |
498 |
} |
499 |
|
500 |
return pSlider;
|
501 |
} |
502 |
|
503 |
/**
|
504 |
* This method initializes jPanel9
|
505 |
*
|
506 |
* @return javax.swing.JPanel
|
507 |
*/
|
508 |
private JPanel getJPanel9() { |
509 |
if (pRemove == null) { |
510 |
lRemove = new JLabel(); |
511 |
|
512 |
FlowLayout flowLayout11 = new FlowLayout(); |
513 |
pRemove = new JPanel(); |
514 |
pRemove.setLayout(flowLayout11); |
515 |
lRemove.setText("Eliminar Extremos");
|
516 |
flowLayout11.setAlignment(java.awt.FlowLayout.LEFT); |
517 |
pRemove.add(getRemoveCheck(), null);
|
518 |
pRemove.add(lRemove, null);
|
519 |
} |
520 |
|
521 |
return pRemove;
|
522 |
} |
523 |
|
524 |
public void componentHidden(ComponentEvent e) { |
525 |
// TODO Auto-generated method stub
|
526 |
|
527 |
} |
528 |
|
529 |
public void componentMoved(ComponentEvent e) { |
530 |
// TODO Auto-generated method stub
|
531 |
|
532 |
} |
533 |
/**
|
534 |
* Redimesiona el panel cuando hay un cambio en el tama?o de su
|
535 |
* contenedor.
|
536 |
*/
|
537 |
public void componentResized(ComponentEvent e) { |
538 |
if(e.getSource() == this){ |
539 |
int difWidth = this.getWidth() - 445; |
540 |
int difHeight = this.getHeight() - 239; |
541 |
this.pGeneralEnhanced.setLocation(this.pGeneralEnhanced.getX() - difWidth/2, this.pGeneralEnhanced.getY() - difHeight/2); |
542 |
this.pGeneralEnhanced.setSize(this.pGeneralEnhanced.getWidth() + difWidth/2, this.pGeneralEnhanced.getHeight() + difHeight/2); |
543 |
this.jPanel3.setLocation(this.jPanel3.getX() + difWidth/4, this.jPanel3.getY() + difHeight/2); |
544 |
this.jPanel1.setLocation(this.jPanel1.getX() + difWidth/4, this.jPanel1.getY() + difHeight/2); |
545 |
this.pSlider.setLocation(this.pSlider.getX(), this.pSlider.getY()-difHeight/2); |
546 |
this.pSlider.setSize(this.pSlider.getWidth() + difWidth/2, this.pSlider.getHeight() + difHeight ); |
547 |
this.jPanel2.setSize(this.jPanel2.getWidth() + difWidth/2, this.jPanel2.getHeight() + difHeight ); |
548 |
this.pTail.setLocation(this.pTail.getX(), this.pTail.getY() + difHeight/2); |
549 |
this.jPanel5.setLocation(this.jPanel5.getX(), this.jPanel5.getY() + difHeight/2); |
550 |
this.jPanel6.setLocation(this.jPanel6.getX(), this.jPanel6.getY() + difHeight/2); |
551 |
this.jPanel5.setSize(this.jPanel5.getWidth() + difWidth/2, this.jPanel5.getHeight()); |
552 |
this.jSlider.setSize(this.jSlider.getWidth() + difWidth/2, this.jSlider.getHeight()); |
553 |
//System.out.println("--->"+this.pSlider.getX()+"---"+pSlider.getY());
|
554 |
} |
555 |
|
556 |
} |
557 |
|
558 |
public void componentShown(ComponentEvent e) { |
559 |
// TODO Auto-generated method stub
|
560 |
|
561 |
} |
562 |
} // @jve:decl-index=0:visual-constraint="36,15"
|