svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / ui / raster / EnhancedPanel.java @ 2312
History | View | Annotate | Download (11.3 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 |
|
28 |
import javax.swing.JPanel; |
29 |
|
30 |
import org.cresques.ui.raster.FilterRasterDialogPanel; |
31 |
|
32 |
import java.awt.Canvas; |
33 |
import java.awt.Dimension; |
34 |
import java.awt.Graphics; |
35 |
import java.awt.GridBagLayout; |
36 |
import java.awt.GridBagConstraints; |
37 |
import java.awt.Image; |
38 |
import java.awt.Toolkit; |
39 |
|
40 |
import javax.swing.ButtonGroup; |
41 |
import javax.swing.ImageIcon; |
42 |
import javax.swing.JRadioButton; |
43 |
import javax.swing.JCheckBox; |
44 |
import javax.swing.JLabel; |
45 |
import javax.swing.JButton; |
46 |
import javax.swing.JSlider; |
47 |
import javax.swing.JTextField; |
48 |
import java.awt.FlowLayout; |
49 |
/**
|
50 |
* Panel que contiene los elementos para el dialogo del filtro de realce
|
51 |
* @author Nacho Brodin <brodin_ign@gva.es>
|
52 |
*/
|
53 |
public class EnhancedPanel extends JPanel{ |
54 |
|
55 |
public String nom = "Realce"; |
56 |
FilterRasterDialogPanel parent = null;
|
57 |
|
58 |
private JPanel jPanel = null; |
59 |
private JPanel jPanel1 = null; |
60 |
private JPanel jPanel2 = null; |
61 |
private JPanel jPanel3 = null; |
62 |
private JRadioButton jRadioButton = null; |
63 |
private JRadioButton jRadioButton1 = null; |
64 |
private JCheckBox jCheckBox = null; |
65 |
public JLabel jLabel = null; |
66 |
public JLabel jLabel2 = null; |
67 |
public JPanel jPanel4 = null; |
68 |
private ButtonGroup grupo= new ButtonGroup(); |
69 |
private Image iconoLineal = null; |
70 |
private Image iconoSinRealce = null; |
71 |
|
72 |
private JPanel jPanel5 = null; |
73 |
private JSlider jSlider = null; |
74 |
private JTextField jTextField = null; |
75 |
|
76 |
|
77 |
private JPanel jPanel6 = null; |
78 |
private JCheckBox jCheckBox1 = null; |
79 |
public JLabel jLabel4 = null; |
80 |
public JPanel jPanel7 = null; |
81 |
public JLabel jLabel1 = null; |
82 |
public JPanel jPanel8 = null; |
83 |
public JPanel jPanel9 = null; |
84 |
public JLabel jLabel5 = null; |
85 |
|
86 |
/**
|
87 |
* Constructor.
|
88 |
* @param parent
|
89 |
*/
|
90 |
public EnhancedPanel(FilterRasterDialogPanel parent){
|
91 |
this.parent = parent;
|
92 |
initialize(); |
93 |
} |
94 |
|
95 |
/**
|
96 |
* This method initializes this
|
97 |
*
|
98 |
* @return void
|
99 |
*/
|
100 |
private void initialize() { |
101 |
this.setLayout(new BorderLayout()); |
102 |
this.setSize(445, 239); |
103 |
this.setPreferredSize(new java.awt.Dimension(445,239)); |
104 |
this.add(getJPanel(), java.awt.BorderLayout.CENTER);
|
105 |
|
106 |
initControls(); |
107 |
} |
108 |
|
109 |
/**
|
110 |
* Inicializa controles a sus valores por defecto
|
111 |
*/
|
112 |
public void initControls(){ |
113 |
jRadioButton1.setSelected(true);
|
114 |
this.getTailText().setText("0.0"); |
115 |
this.getTailSlider().setValue(0); |
116 |
this.setActiveTailControl(false); |
117 |
this.getTailCheck().setEnabled(false); |
118 |
this.getRemoveCheck().setEnabled(false); |
119 |
} |
120 |
|
121 |
|
122 |
/**
|
123 |
* This method initializes jPanel
|
124 |
*
|
125 |
* @return javax.swing.JPanel
|
126 |
*/
|
127 |
private JPanel getJPanel() { |
128 |
if (jPanel == null) { |
129 |
FlowLayout flowLayout2 = new FlowLayout(); |
130 |
GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
131 |
jPanel = new JPanel(); |
132 |
jPanel.setLayout(flowLayout2); |
133 |
gridBagConstraints4.gridx = 0;
|
134 |
gridBagConstraints4.gridy = 0;
|
135 |
jPanel.setPreferredSize(new java.awt.Dimension(445,239)); |
136 |
flowLayout2.setAlignment(java.awt.FlowLayout.CENTER); |
137 |
jPanel.add(getJPanel4(), null);
|
138 |
jPanel.add(getJPanel8(), null);
|
139 |
} |
140 |
return jPanel;
|
141 |
} |
142 |
/**
|
143 |
* This method initializes jPanel1
|
144 |
*
|
145 |
* @return javax.swing.JPanel
|
146 |
*/
|
147 |
private JPanel getJPanel1() { |
148 |
if (jPanel1 == null) { |
149 |
jLabel = new JLabel("Lineal directo",new ImageIcon("images/lineal.gif"), JLabel.CENTER); |
150 |
jPanel1 = new JPanel(); |
151 |
jPanel1.setLayout(new BorderLayout()); |
152 |
jPanel1.add(getLinealDirectoRadioButton(), java.awt.BorderLayout.WEST); |
153 |
jPanel1.add(jLabel, java.awt.BorderLayout.EAST); |
154 |
} |
155 |
return jPanel1;
|
156 |
} |
157 |
/**
|
158 |
* This method initializes jPanel2
|
159 |
*
|
160 |
* @return javax.swing.JPanel
|
161 |
*/
|
162 |
private JPanel getJPanel2() { |
163 |
if (jPanel2 == null) { |
164 |
jPanel2 = new JPanel(); |
165 |
jPanel2.setLayout(new BorderLayout()); |
166 |
jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
|
167 |
jPanel2.setPreferredSize(new java.awt.Dimension(220,95)); |
168 |
jPanel2.add(getJPanel5(), java.awt.BorderLayout.CENTER); |
169 |
jPanel2.add(getJPanel6(), java.awt.BorderLayout.SOUTH); |
170 |
jPanel2.add(getJPanel7(), java.awt.BorderLayout.NORTH); |
171 |
} |
172 |
return jPanel2;
|
173 |
} |
174 |
/**
|
175 |
* This method initializes jPanel3
|
176 |
*
|
177 |
* @return javax.swing.JPanel
|
178 |
*/
|
179 |
private JPanel getJPanel3() { |
180 |
if (jPanel3 == null) { |
181 |
jLabel2 = new JLabel("Sin Realce",new ImageIcon("images/sinrealce.gif"), JLabel.CENTER); |
182 |
jPanel3 = new JPanel(); |
183 |
jPanel3.setLayout(new BorderLayout()); |
184 |
jPanel3.add(getSinRealceRadioButton(), java.awt.BorderLayout.WEST); |
185 |
jPanel3.add(jLabel2, java.awt.BorderLayout.EAST); |
186 |
} |
187 |
return jPanel3;
|
188 |
} |
189 |
/**
|
190 |
* This method initializes jRadioButton
|
191 |
*
|
192 |
* @return javax.swing.JRadioButton
|
193 |
*/
|
194 |
public JRadioButton getLinealDirectoRadioButton() { |
195 |
if (jRadioButton == null) { |
196 |
jRadioButton = new JRadioButton(); |
197 |
grupo.add(jRadioButton); |
198 |
} |
199 |
return jRadioButton;
|
200 |
} |
201 |
/**
|
202 |
* This method initializes jRadioButton1
|
203 |
*
|
204 |
* @return javax.swing.JRadioButton
|
205 |
*/
|
206 |
public JRadioButton getSinRealceRadioButton() { |
207 |
if (jRadioButton1 == null) { |
208 |
jRadioButton1 = new JRadioButton(); |
209 |
jRadioButton1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); |
210 |
grupo.add(jRadioButton1); |
211 |
} |
212 |
return jRadioButton1;
|
213 |
} |
214 |
/**
|
215 |
* This method initializes jCheckBox
|
216 |
*
|
217 |
* @return javax.swing.JCheckBox
|
218 |
*/
|
219 |
public JCheckBox getTailCheck() { |
220 |
if (jCheckBox == null) { |
221 |
jCheckBox = new JCheckBox(); |
222 |
} |
223 |
return jCheckBox;
|
224 |
} |
225 |
/**
|
226 |
* This method initializes jPanel4
|
227 |
*
|
228 |
* @return javax.swing.JPanel
|
229 |
*/
|
230 |
private JPanel getJPanel4() { |
231 |
if (jPanel4 == null) { |
232 |
GridBagConstraints gridBagConstraints10 = new GridBagConstraints(); |
233 |
GridBagConstraints gridBagConstraints9 = new GridBagConstraints(); |
234 |
jPanel4 = new JPanel(); |
235 |
jPanel4.setLayout(new GridBagLayout()); |
236 |
gridBagConstraints9.gridx = 0;
|
237 |
gridBagConstraints9.gridy = 0;
|
238 |
gridBagConstraints9.insets = new java.awt.Insets(5,0,5,2); |
239 |
gridBagConstraints9.anchor = java.awt.GridBagConstraints.WEST; |
240 |
gridBagConstraints10.gridx = 0;
|
241 |
gridBagConstraints10.gridy = 1;
|
242 |
gridBagConstraints10.insets = new java.awt.Insets(5,0,5,5); |
243 |
jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0)); |
244 |
jPanel4.setPreferredSize(new java.awt.Dimension(175,200)); |
245 |
jPanel4.add(getJPanel3(), gridBagConstraints9); |
246 |
jPanel4.add(getJPanel1(), gridBagConstraints10); |
247 |
} |
248 |
return jPanel4;
|
249 |
} |
250 |
|
251 |
|
252 |
/**
|
253 |
* This method initializes jPanel5
|
254 |
*
|
255 |
* @return javax.swing.JPanel
|
256 |
*/
|
257 |
private JPanel getJPanel5() { |
258 |
if (jPanel5 == null) { |
259 |
jPanel5 = new JPanel(); |
260 |
jPanel5.add(getTailSlider(), null);
|
261 |
} |
262 |
return jPanel5;
|
263 |
} |
264 |
/**
|
265 |
* This method initializes jSlider
|
266 |
*
|
267 |
* @return javax.swing.JSlider
|
268 |
*/
|
269 |
public JSlider getTailSlider() { |
270 |
if (jSlider == null) { |
271 |
jSlider = new JSlider(); |
272 |
jSlider.setPreferredSize(new java.awt.Dimension(240,16)); |
273 |
} |
274 |
return jSlider;
|
275 |
} |
276 |
/**
|
277 |
* This method initializes jTextField
|
278 |
*
|
279 |
* @return javax.swing.JTextField
|
280 |
*/
|
281 |
public JTextField getTailText() { |
282 |
if (jTextField == null) { |
283 |
jTextField = new JTextField(); |
284 |
jTextField.setPreferredSize(new java.awt.Dimension(40,19)); |
285 |
jTextField.setText("0.0");
|
286 |
} |
287 |
return jTextField;
|
288 |
} |
289 |
|
290 |
/**
|
291 |
* Activa/Desactiva los controles de Recorte de colas
|
292 |
* @param active
|
293 |
*/
|
294 |
public void setActiveTailControl(boolean active){ |
295 |
this.getTailSlider().setEnabled(active);
|
296 |
this.getTailText().setEnabled(active);
|
297 |
this.jLabel1.setEnabled(active);
|
298 |
this.jLabel4.setEnabled(active);
|
299 |
} |
300 |
|
301 |
/**
|
302 |
*
|
303 |
* @param active
|
304 |
*/
|
305 |
public void setActiveRemoveCheck(boolean active){ |
306 |
this.getRemoveCheck().setEnabled(active);
|
307 |
this.jLabel5.setEnabled(active);
|
308 |
} |
309 |
|
310 |
/**
|
311 |
* Asigna el procentaje de recorte de colas aplicado
|
312 |
* @param tail
|
313 |
*/
|
314 |
public void setPercentTail(int tail){ |
315 |
jTextField.setText(String.valueOf(tail));
|
316 |
jSlider.setValue(tail); |
317 |
} |
318 |
|
319 |
/**
|
320 |
* Asigna el filtro seleccionado cuando se abre el dialogo
|
321 |
* @param filter
|
322 |
*/
|
323 |
public void setSelectedFilter(int filter){ |
324 |
switch(filter){
|
325 |
case 0: jRadioButton1.setSelected(true); //Sin realce |
326 |
jCheckBox.setEnabled(false);
|
327 |
setActiveTailControl(false);
|
328 |
this.setActiveRemoveCheck(false); |
329 |
break;
|
330 |
|
331 |
case 1: this.getRemoveCheck().setSelected(true); |
332 |
|
333 |
case 2: jRadioButton.setSelected(true); //Realce lineal |
334 |
this.getTailCheck().setEnabled(true); |
335 |
this.setActiveRemoveCheck(true); |
336 |
if(!this.getTailText().getText().equals("") && !this.getTailText().getText().equals("0.0")){ |
337 |
this.getTailCheck().setSelected(true); |
338 |
this.setActiveTailControl(true); |
339 |
} |
340 |
break;
|
341 |
} |
342 |
} |
343 |
|
344 |
/**
|
345 |
* This method initializes jPanel6
|
346 |
*
|
347 |
* @return javax.swing.JPanel
|
348 |
*/
|
349 |
private JPanel getJPanel6() { |
350 |
if (jPanel6 == null) { |
351 |
FlowLayout flowLayout3 = new FlowLayout(); |
352 |
jLabel4 = new JLabel(); |
353 |
jPanel6 = new JPanel(); |
354 |
jPanel6.setLayout(flowLayout3); |
355 |
jLabel4.setText("% recorte");
|
356 |
flowLayout3.setAlignment(java.awt.FlowLayout.LEFT); |
357 |
jPanel6.add(getTailText(), null);
|
358 |
jPanel6.add(jLabel4, null);
|
359 |
} |
360 |
return jPanel6;
|
361 |
} |
362 |
/**
|
363 |
* This method initializes jCheckBox1
|
364 |
*
|
365 |
* @return javax.swing.JCheckBox
|
366 |
*/
|
367 |
public JCheckBox getRemoveCheck() { |
368 |
if (jCheckBox1 == null) { |
369 |
jCheckBox1 = new JCheckBox(); |
370 |
} |
371 |
return jCheckBox1;
|
372 |
} |
373 |
/**
|
374 |
* This method initializes jPanel7
|
375 |
*
|
376 |
* @return javax.swing.JPanel
|
377 |
*/
|
378 |
private JPanel getJPanel7() { |
379 |
if (jPanel7 == null) { |
380 |
jLabel1 = new JLabel(); |
381 |
FlowLayout flowLayout1 = new FlowLayout(); |
382 |
jPanel7 = new JPanel(); |
383 |
jPanel7.setLayout(flowLayout1); |
384 |
jLabel1.setText("Recorte de colas");
|
385 |
flowLayout1.setAlignment(java.awt.FlowLayout.LEFT); |
386 |
jPanel7.add(getTailCheck(), null);
|
387 |
jPanel7.add(jLabel1, null);
|
388 |
} |
389 |
return jPanel7;
|
390 |
} |
391 |
/**
|
392 |
* This method initializes jPanel8
|
393 |
*
|
394 |
* @return javax.swing.JPanel
|
395 |
*/
|
396 |
private JPanel getJPanel8() { |
397 |
if (jPanel8 == null) { |
398 |
jPanel8 = new JPanel(); |
399 |
jPanel8.setLayout(new BorderLayout()); |
400 |
jPanel8.setPreferredSize(new java.awt.Dimension(250,130)); |
401 |
jPanel8.add(getJPanel2(), java.awt.BorderLayout.SOUTH); |
402 |
jPanel8.add(getJPanel9(), java.awt.BorderLayout.NORTH); |
403 |
} |
404 |
return jPanel8;
|
405 |
} |
406 |
/**
|
407 |
* This method initializes jPanel9
|
408 |
*
|
409 |
* @return javax.swing.JPanel
|
410 |
*/
|
411 |
private JPanel getJPanel9() { |
412 |
if (jPanel9 == null) { |
413 |
jLabel5 = new JLabel(); |
414 |
FlowLayout flowLayout11 = new FlowLayout(); |
415 |
jPanel9 = new JPanel(); |
416 |
jPanel9.setLayout(flowLayout11); |
417 |
jLabel5.setText("Eliminar Extremos");
|
418 |
flowLayout11.setAlignment(java.awt.FlowLayout.LEFT); |
419 |
jPanel9.add(getRemoveCheck(), null);
|
420 |
jPanel9.add(jLabel5, null);
|
421 |
} |
422 |
return jPanel9;
|
423 |
} |
424 |
} // @jve:decl-index=0:visual-constraint="36,15"
|