Statistics
| Revision:

svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / ui / raster / EnhancedPanel.java @ 2167

History | View | Annotate | Download (11.5 KB)

1 2098 igbrotru
/*
2
 * Created on 17-feb-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47 1785 igbrotru
package org.cresques.ui.raster;
48
49
import java.awt.BorderLayout;
50
51
import javax.swing.JPanel;
52
53
import org.cresques.ui.raster.FilterRasterDialogPanel;
54
55 1800 igbrotru
import java.awt.Canvas;
56 1789 igbrotru
import java.awt.Dimension;
57 1800 igbrotru
import java.awt.Graphics;
58 1785 igbrotru
import java.awt.GridBagLayout;
59
import java.awt.GridBagConstraints;
60 1800 igbrotru
import java.awt.Image;
61
import java.awt.Toolkit;
62 1785 igbrotru
63
import javax.swing.ButtonGroup;
64 1789 igbrotru
import javax.swing.ImageIcon;
65 1785 igbrotru
import javax.swing.JRadioButton;
66
import javax.swing.JCheckBox;
67
import javax.swing.JLabel;
68 1789 igbrotru
import javax.swing.JButton;
69
import javax.swing.JSlider;
70
import javax.swing.JTextField;
71 2098 igbrotru
import java.awt.FlowLayout;
72 1785 igbrotru
/**
73
 *
74
 * @author Nacho Brodin <brodin_ign@gva.es>
75
 *
76
 */
77
public class EnhancedPanel extends JPanel{
78
79
        String nom = "Realce";
80
        FilterRasterDialogPanel parent = null;
81 1800 igbrotru
82 1785 igbrotru
        private JPanel jPanel = null;
83
        private JPanel jPanel1 = null;
84
        private JPanel jPanel2 = null;
85
        private JPanel jPanel3 = null;
86
        private JRadioButton jRadioButton = null;
87
        private JRadioButton jRadioButton1 = null;
88
        private JCheckBox jCheckBox = null;
89 2167 igbrotru
        public JLabel jLabel = null;
90
        public JLabel jLabel2 = null;
91
        public JPanel jPanel4 = null;
92 1785 igbrotru
        private        ButtonGroup grupo= new ButtonGroup();
93 1800 igbrotru
        private Image iconoLineal = null;
94
        private Image iconoSinRealce = null;
95 1785 igbrotru
96 1789 igbrotru
        private JPanel jPanel5 = null;
97
        private JSlider jSlider = null;
98
        private JTextField jTextField = null;
99
100 1800 igbrotru
101 2098 igbrotru
        private JPanel jPanel6 = null;
102
        private JCheckBox jCheckBox1 = null;
103 2167 igbrotru
        public JLabel jLabel4 = null;
104
        public JPanel jPanel7 = null;
105
        public JLabel jLabel1 = null;
106
        public JPanel jPanel8 = null;
107
        public JPanel jPanel9 = null;
108
        public JLabel jLabel5 = null;
109 1785 igbrotru
        public EnhancedPanel(FilterRasterDialogPanel parent){
110
                this.parent = parent;
111 1800 igbrotru
112 1785 igbrotru
                initialize();
113
        }
114
115
        /**
116
         * This method initializes this
117
         *
118
         * @return void
119
         */
120
        private void initialize() {
121
        this.setLayout(new BorderLayout());
122 2098 igbrotru
        this.setSize(445, 239);
123 2147 igbrotru
        this.setPreferredSize(new java.awt.Dimension(445,239));
124
        this.add(getJPanel(), java.awt.BorderLayout.CENTER);
125 1789 igbrotru
126 1785 igbrotru
               initControls();
127
        }
128
129
        /**
130
         * Inicializa controles a sus valores por defecto
131
         */
132
        public void initControls(){
133 1789 igbrotru
                jRadioButton1.setSelected(true);
134 2147 igbrotru
                this.getTailText().setText("0.0");
135 1789 igbrotru
                this.getTailSlider().setValue(0);
136
                this.setActiveTailControl(false);
137 1799 igbrotru
                this.getTailCheck().setEnabled(false);
138 2147 igbrotru
                this.getRemoveCheck().setEnabled(false);
139 1785 igbrotru
        }
140
141
142
        /**
143
         * This method initializes jPanel
144
         *
145
         * @return javax.swing.JPanel
146
         */
147
        private JPanel getJPanel() {
148
                if (jPanel == null) {
149 2147 igbrotru
                        FlowLayout flowLayout2 = new FlowLayout();
150 1785 igbrotru
                        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
151
                        jPanel = new JPanel();
152 2147 igbrotru
                        jPanel.setLayout(flowLayout2);
153 1785 igbrotru
                        gridBagConstraints4.gridx = 0;
154
                        gridBagConstraints4.gridy = 0;
155 2098 igbrotru
                        jPanel.setPreferredSize(new java.awt.Dimension(445,239));
156 2147 igbrotru
                        flowLayout2.setAlignment(java.awt.FlowLayout.CENTER);
157
                        jPanel.add(getJPanel4(), null);
158
                        jPanel.add(getJPanel8(), null);
159 1785 igbrotru
                }
160
                return jPanel;
161
        }
162
        /**
163
         * This method initializes jPanel1
164
         *
165
         * @return javax.swing.JPanel
166
         */
167
        private JPanel getJPanel1() {
168
                if (jPanel1 == null) {
169 1800 igbrotru
                        jLabel  = new JLabel("Lineal directo",new ImageIcon("images/lineal.gif"), JLabel.CENTER);
170 1785 igbrotru
                        jPanel1 = new JPanel();
171
                        jPanel1.setLayout(new BorderLayout());
172 1799 igbrotru
                        jPanel1.add(getLinealDirectoRadioButton(), java.awt.BorderLayout.WEST);
173 1785 igbrotru
                        jPanel1.add(jLabel, java.awt.BorderLayout.EAST);
174
                }
175
                return jPanel1;
176
        }
177
        /**
178
         * This method initializes jPanel2
179
         *
180
         * @return javax.swing.JPanel
181
         */
182
        private JPanel getJPanel2() {
183
                if (jPanel2 == null) {
184
                        jPanel2 = new JPanel();
185
                        jPanel2.setLayout(new BorderLayout());
186 1789 igbrotru
                        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
187 2147 igbrotru
                        jPanel2.setPreferredSize(new java.awt.Dimension(220,95));
188
                        jPanel2.add(getJPanel5(), java.awt.BorderLayout.CENTER);
189
                        jPanel2.add(getJPanel6(), java.awt.BorderLayout.SOUTH);
190
                        jPanel2.add(getJPanel7(), java.awt.BorderLayout.NORTH);
191 1785 igbrotru
                }
192
                return jPanel2;
193
        }
194
        /**
195
         * This method initializes jPanel3
196
         *
197
         * @return javax.swing.JPanel
198
         */
199
        private JPanel getJPanel3() {
200
                if (jPanel3 == null) {
201 1800 igbrotru
                        jLabel2 = new JLabel("Sin Realce",new ImageIcon("images/sinrealce.gif"), JLabel.CENTER);
202 1785 igbrotru
                        jPanel3 = new JPanel();
203
                        jPanel3.setLayout(new BorderLayout());
204 1799 igbrotru
                        jPanel3.add(getSinRealceRadioButton(), java.awt.BorderLayout.WEST);
205 1785 igbrotru
                        jPanel3.add(jLabel2, java.awt.BorderLayout.EAST);
206
                }
207
                return jPanel3;
208
        }
209
        /**
210
         * This method initializes jRadioButton
211
         *
212
         * @return javax.swing.JRadioButton
213
         */
214 1799 igbrotru
        public JRadioButton getLinealDirectoRadioButton() {
215 1785 igbrotru
                if (jRadioButton == null) {
216
                        jRadioButton = new JRadioButton();
217
                        grupo.add(jRadioButton);
218
                }
219
                return jRadioButton;
220
        }
221
        /**
222
         * This method initializes jRadioButton1
223
         *
224
         * @return javax.swing.JRadioButton
225
         */
226 1799 igbrotru
        public JRadioButton getSinRealceRadioButton() {
227 1785 igbrotru
                if (jRadioButton1 == null) {
228
                        jRadioButton1 = new JRadioButton();
229
                        jRadioButton1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
230
                        grupo.add(jRadioButton1);
231
                }
232
                return jRadioButton1;
233
        }
234
        /**
235
         * This method initializes jCheckBox
236
         *
237
         * @return javax.swing.JCheckBox
238
         */
239 1789 igbrotru
        public JCheckBox getTailCheck() {
240 1785 igbrotru
                if (jCheckBox == null) {
241
                        jCheckBox = new JCheckBox();
242
                }
243
                return jCheckBox;
244
        }
245
        /**
246
         * This method initializes jPanel4
247
         *
248
         * @return javax.swing.JPanel
249
         */
250
        private JPanel getJPanel4() {
251
                if (jPanel4 == null) {
252
                        GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
253
                        GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
254
                        jPanel4 = new JPanel();
255
                        jPanel4.setLayout(new GridBagLayout());
256
                        gridBagConstraints9.gridx = 0;
257
                        gridBagConstraints9.gridy = 0;
258
                        gridBagConstraints9.insets = new java.awt.Insets(5,0,5,2);
259
                        gridBagConstraints9.anchor = java.awt.GridBagConstraints.WEST;
260
                        gridBagConstraints10.gridx = 0;
261
                        gridBagConstraints10.gridy = 1;
262
                        gridBagConstraints10.insets = new java.awt.Insets(5,0,5,5);
263 1789 igbrotru
                        jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0));
264 2147 igbrotru
                        jPanel4.setPreferredSize(new java.awt.Dimension(175,200));
265 1785 igbrotru
                        jPanel4.add(getJPanel3(), gridBagConstraints9);
266
                        jPanel4.add(getJPanel1(), gridBagConstraints10);
267
                }
268
                return jPanel4;
269
        }
270 1800 igbrotru
271
272 1789 igbrotru
        /**
273
         * This method initializes jPanel5
274
         *
275
         * @return javax.swing.JPanel
276
         */
277
        private JPanel getJPanel5() {
278
                if (jPanel5 == null) {
279
                        jPanel5 = new JPanel();
280
                        jPanel5.add(getTailSlider(), null);
281
                }
282
                return jPanel5;
283
        }
284
        /**
285
         * This method initializes jSlider
286
         *
287
         * @return javax.swing.JSlider
288
         */
289
        public JSlider getTailSlider() {
290
                if (jSlider == null) {
291
                        jSlider = new JSlider();
292 2147 igbrotru
                        jSlider.setPreferredSize(new java.awt.Dimension(240,16));
293 1789 igbrotru
                }
294
                return jSlider;
295
        }
296
        /**
297
         * This method initializes jTextField
298
         *
299
         * @return javax.swing.JTextField
300
         */
301
        public JTextField getTailText() {
302
                if (jTextField == null) {
303
                        jTextField = new JTextField();
304 2147 igbrotru
                        jTextField.setPreferredSize(new java.awt.Dimension(40,19));
305
                        jTextField.setText("0.0");
306 1789 igbrotru
                }
307
                return jTextField;
308
        }
309
310
        /**
311
         * Activa/Desactiva los controles de Recorte de colas
312
         * @param active
313
         */
314
        public void setActiveTailControl(boolean active){
315
                this.getTailSlider().setEnabled(active);
316
                this.getTailText().setEnabled(active);
317
        }
318
319 1799 igbrotru
        /**
320
         * Asigna el procentaje de recorte de colas aplicado
321
         * @param tail
322
         */
323
        public void setPercentTail(int tail){
324
                jTextField.setText(String.valueOf(tail));
325
                jSlider.setValue(tail);
326
        }
327 2098 igbrotru
328 1799 igbrotru
        /**
329
         * Asigna el filtro seleccionado cuando se abre el dialogo
330
         * @param filter
331
         */
332
        public void setSelectedFilter(int filter){
333
                switch(filter){
334 1804 igbrotru
                        case 0:        jRadioButton1.setSelected(true);         //Sin realce
335
                                        jCheckBox.setEnabled(false);
336
                                        setActiveTailControl(false);
337 2147 igbrotru
                                        this.getRemoveCheck().setEnabled(false);
338 1799 igbrotru
                                        break;
339 2098 igbrotru
                        case 1:
340
                                        this.getRemoveCheck().setSelected(true);
341
342
                        case 2:        jRadioButton.setSelected(true);                //Realce lineal
343 1804 igbrotru
                                        this.getTailCheck().setEnabled(true);
344 2147 igbrotru
                                        this.getRemoveCheck().setEnabled(true);
345
                                        if(!this.getTailText().getText().equals("") && !this.getTailText().getText().equals("0.0")){
346 1804 igbrotru
                                                this.getTailCheck().setSelected(true);
347
                                                this.setActiveTailControl(true);
348
                                        }
349
                                        break;
350 1799 igbrotru
                }
351
        }
352
353 2098 igbrotru
        /**
354
         * This method initializes jPanel6
355
         *
356
         * @return javax.swing.JPanel
357
         */
358
        private JPanel getJPanel6() {
359
                if (jPanel6 == null) {
360 2147 igbrotru
                        FlowLayout flowLayout3 = new FlowLayout();
361 2098 igbrotru
                        jLabel4 = new JLabel();
362
                        jPanel6 = new JPanel();
363 2147 igbrotru
                        jPanel6.setLayout(flowLayout3);
364
                        jLabel4.setText("% recorte");
365
                        flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
366
                        jPanel6.add(getTailText(), null);
367 2098 igbrotru
                        jPanel6.add(jLabel4, null);
368
                }
369
                return jPanel6;
370
        }
371
        /**
372
         * This method initializes jCheckBox1
373
         *
374
         * @return javax.swing.JCheckBox
375
         */
376
        public JCheckBox getRemoveCheck() {
377
                if (jCheckBox1 == null) {
378
                        jCheckBox1 = new JCheckBox();
379
                }
380
                return jCheckBox1;
381
        }
382
        /**
383
         * This method initializes jPanel7
384
         *
385
         * @return javax.swing.JPanel
386
         */
387
        private JPanel getJPanel7() {
388
                if (jPanel7 == null) {
389
                        jLabel1 = new JLabel();
390
                        FlowLayout flowLayout1 = new FlowLayout();
391
                        jPanel7 = new JPanel();
392
                        jPanel7.setLayout(flowLayout1);
393
                        jLabel1.setText("Recorte de colas");
394
                        flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
395
                        jPanel7.add(getTailCheck(), null);
396
                        jPanel7.add(jLabel1, null);
397
                }
398
                return jPanel7;
399
        }
400 2147 igbrotru
        /**
401
         * This method initializes jPanel8
402
         *
403
         * @return javax.swing.JPanel
404
         */
405
        private JPanel getJPanel8() {
406
                if (jPanel8 == null) {
407
                        jPanel8 = new JPanel();
408
                        jPanel8.setLayout(new BorderLayout());
409
                        jPanel8.setPreferredSize(new java.awt.Dimension(250,130));
410
                        jPanel8.add(getJPanel2(), java.awt.BorderLayout.SOUTH);
411
                        jPanel8.add(getJPanel9(), java.awt.BorderLayout.NORTH);
412
                }
413
                return jPanel8;
414
        }
415
        /**
416
         * This method initializes jPanel9
417
         *
418
         * @return javax.swing.JPanel
419
         */
420
        private JPanel getJPanel9() {
421
                if (jPanel9 == null) {
422
                        jLabel5 = new JLabel();
423
                        FlowLayout flowLayout11 = new FlowLayout();
424
                        jPanel9 = new JPanel();
425
                        jPanel9.setLayout(flowLayout11);
426
                        jLabel5.setText("Eliminar Extremos");
427
                        flowLayout11.setAlignment(java.awt.FlowLayout.LEFT);
428
                        jPanel9.add(getRemoveCheck(), null);
429
                        jPanel9.add(jLabel5, null);
430
                }
431
                return jPanel9;
432
        }
433
     }  //  @jve:decl-index=0:visual-constraint="36,15"