Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / wizard / GeoProcessingOperationSelectorPanel.java @ 5919

History | View | Annotate | Download (12.3 KB)

1
/*
2
 * Created on 04-jul-2005
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
package com.iver.cit.gvsig.geoprocess.wizard;
45

    
46
import javax.swing.ButtonGroup;
47
import javax.swing.ImageIcon;
48
import javax.swing.JLabel;
49
import javax.swing.JPanel;
50
import javax.swing.JRadioButton;
51
import javax.swing.event.ChangeEvent;
52
import javax.swing.event.ChangeListener;
53

    
54
import com.iver.andami.PluginServices;
55
import com.iver.andami.plugins.PluginClassLoader;
56
import com.iver.cit.gvsig.AddLayer;
57

    
58
import java.awt.GridBagLayout;
59
import java.awt.GridBagConstraints;
60
import java.awt.GridLayout;
61
import java.awt.FlowLayout;
62
import java.io.IOException;
63
import java.net.URL;
64
import java.util.Enumeration;
65

    
66
import javax.swing.BoxLayout;
67

    
68
/**
69
 * 
70
 * This component is the first step of GeoProcessing Wizard. It allows user to
71
 * select which geoprocessing operation want to do.
72
 * 
73
 * @author jmorell, azabala
74
 */
75
public class GeoProcessingOperationSelectorPanel extends JPanel {
76
        private static final long serialVersionUID = 1L;
77
        
78
        private JLabel jLabel = null;
79

    
80
        private JRadioButton bufferRadioButton = null;
81

    
82
        private JRadioButton dissolveRadioButton = null;
83

    
84
        private JRadioButton mergeRadioButton = null;
85

    
86
        private JRadioButton intersectRadioButton = null;
87

    
88
        private JRadioButton unionRadioButton = null;
89

    
90
        private JRadioButton spatialJoinRadioButton = null;
91

    
92
        private JRadioButton clipRadioButton = null;
93

    
94
        private ButtonGroup buttonGroup = null;
95

    
96
        private JRadioButton convexHullRadioButton = null;
97

    
98
        private JRadioButton differenceRadioButton = null;
99

    
100
        private JPanel mainPanel = null;
101

    
102
        private JLabel imageLabel = null;
103

    
104
        private ImageIcon bufferDescIcon;
105

    
106
        private ImageIcon dissolveDescIcon;
107

    
108
        private ImageIcon mergeDescIcon;
109

    
110
        private ImageIcon intersectDescIcon;
111

    
112
        private ImageIcon unionDescIcon;
113

    
114
        private ImageIcon spatialJoinDescIcon;
115

    
116
        private ImageIcon clipDescIcon;
117

    
118
        private ImageIcon convexHullDescIcon;
119

    
120
        private ImageIcon differenceDescIcon;
121

    
122
        /**
123
         * This is the default constructor
124
         */
125
        public GeoProcessingOperationSelectorPanel() {
126
                super();
127
                initialize();
128
        }
129
        
130
        public void changeSelection(){
131
                if(isBufferSelected()){
132
                        imageLabel.setIcon(bufferDescIcon);
133
                }else if(isDissolveSelected()){
134
                        imageLabel.setIcon(dissolveDescIcon);
135
                }else if(isMergeSelected()){
136
                        imageLabel.setIcon(mergeDescIcon);
137
                }else if(isIntersectSelected()){
138
                        imageLabel.setIcon(intersectDescIcon);
139
                }else if(isUnionSelected()){
140
                        imageLabel.setIcon(unionDescIcon);
141
                }else if(isClipSelected()){
142
                        imageLabel.setIcon(clipDescIcon);
143
                }else if(isSpatialJoinSelected()){
144
                        imageLabel.setIcon(spatialJoinDescIcon);
145
                }else if(isDifferenceSelected()){
146
                        imageLabel.setIcon(differenceDescIcon);
147
                }else if(isConvexHullSelected()){
148
                        imageLabel.setIcon(convexHullDescIcon);
149
                }
150
        }
151
        
152
        public boolean isBufferSelected(){
153
                return bufferRadioButton.isSelected();
154
        }
155
        
156
        public boolean isDissolveSelected(){
157
                return dissolveRadioButton.isSelected();
158
        }
159
        
160
        public boolean isMergeSelected(){
161
                return mergeRadioButton.isSelected();
162
        }
163
        
164
        public boolean isIntersectSelected(){
165
                return intersectRadioButton.isSelected();
166
        }
167
        
168
        public boolean isUnionSelected(){
169
                return unionRadioButton.isSelected();
170
        }
171
        
172
        public boolean isClipSelected(){
173
                return clipRadioButton.isSelected();
174
        }
175
        
176
        public boolean isSpatialJoinSelected(){
177
                return spatialJoinRadioButton.isSelected();
178
        }
179
        
180
        public boolean isDifferenceSelected(){
181
                return differenceRadioButton.isSelected();
182
        }
183
        
184
        public boolean isConvexHullSelected(){
185
                return convexHullRadioButton.isSelected();
186
        }
187

    
188
        private void initializeImages(){
189
                URL url =         GeoProcessingExtension.class.
190
                                                        getClassLoader().
191
                                                        getResource("images/bufferdesc.png");
192
                bufferDescIcon = 
193
                        new ImageIcon(url);
194
                url =         GeoProcessingExtension.class.
195
                                getClassLoader().
196
                                getResource("images/dissolvedesc.png");
197
                dissolveDescIcon = 
198
                        new ImageIcon(url);
199
                url =         GeoProcessingExtension.class.
200
                        getClassLoader().
201
                        getResource("images/mergedesc.png");
202
                mergeDescIcon = 
203
                        new ImageIcon(url);
204
                url =         GeoProcessingExtension.class.
205
                                getClassLoader().
206
                                getResource("images/intersectdesc.png");
207
                intersectDescIcon = 
208
                        new ImageIcon(url);
209
                url =         GeoProcessingExtension.class.
210
                                getClassLoader().
211
                                getResource("images/uniondesc.png");
212
                unionDescIcon = 
213
                        new ImageIcon(url);
214
                url =         GeoProcessingExtension.class.
215
                                getClassLoader().
216
                                getResource("images/spatialjoindesc.png");
217
                spatialJoinDescIcon = 
218
                        new ImageIcon(url);
219
                url =         GeoProcessingExtension.class.
220
                                getClassLoader().
221
                                getResource("images/clipdesc.png");
222
                clipDescIcon = 
223
                        new ImageIcon(url);
224
                url =         GeoProcessingExtension.class.
225
                                getClassLoader().
226
                                getResource("images/convexhulldesc.png");
227
                convexHullDescIcon = 
228
                        new ImageIcon(url);
229
                url =         GeoProcessingExtension.class.
230
                                getClassLoader().
231
                                getResource("images/differencedesc.png");
232
                differenceDescIcon = 
233
                        new ImageIcon(url);
234
                
235
        }
236
        
237
        /**
238
         * This method initializes this
239
         * 
240
         * @return void
241
         */
242
        private void initialize() {
243
                
244
                initializeImages();
245
                imageLabel = new JLabel();
246
                imageLabel.setText("");
247
                imageLabel.setIcon(bufferDescIcon);
248
                imageLabel.setBounds(new java.awt.Rectangle(152,44,322,328));
249
                jLabel = new JLabel();
250
                this.setLayout(null);
251
                this.setBounds(new java.awt.Rectangle(0,0,486,377));
252
                this.add(jLabel, null);
253
                this.add(getMainPanel(), null);
254
                this.add(imageLabel, null);
255
                jLabel.setText(PluginServices.getText(this,
256
                                "Elija_una_herramienta_de_analisis")
257
                                + ":");
258
                jLabel.setBounds(new java.awt.Rectangle(4,5,432,32));
259
                confButtonGroup();
260
                getBufferRadioButton().setSelected(true);
261
        }
262

    
263
        private void confButtonGroup() {
264
                if (buttonGroup == null) {
265
                        buttonGroup = new ButtonGroup();
266
                        buttonGroup.add(getBufferRadioButton());
267
                        buttonGroup.add(getDissolveRadioButton());
268
                        buttonGroup.add(getMergeRadioButton());
269
                        buttonGroup.add(getIntersectRadioButton());
270
                        buttonGroup.add(getUnionRadioButton());
271
                        buttonGroup.add(getSpatialJoinRadioButton());
272
                        buttonGroup.add(getClipRadioButton());
273
                        buttonGroup.add(getConvexHullRadioButton());
274
                        buttonGroup.add(getDifferenceRadioButton());
275

    
276
                }
277
        }
278

    
279
        /**
280
         * This method initializes bufferRadioButton
281
         * 
282
         * @return javax.swing.JRadioButton
283
         */
284
        private JRadioButton getBufferRadioButton() {
285
                if (bufferRadioButton == null) {
286
                        bufferRadioButton = new JRadioButton();
287
                        bufferRadioButton.setText(PluginServices.getText(this,
288
                                        "Area_de_influencia"));
289
                        bufferRadioButton.addChangeListener(new ChangeListener(){
290
                                public void stateChanged(ChangeEvent arg0) {
291
                                        changeSelection();
292
                                }
293
                                
294
                        });
295
                }
296
                return bufferRadioButton;
297
        }
298

    
299
        /**
300
         * This method initializes clipRadioButton
301
         * 
302
         * @return javax.swing.JRadioButton
303
         */
304
        private JRadioButton getClipRadioButton() {
305
                if (clipRadioButton == null) {
306
                        clipRadioButton = new JRadioButton();
307
                        clipRadioButton.setText(PluginServices.getText(this, "Recortar"));
308
                        clipRadioButton.addChangeListener(new ChangeListener(){
309
                                public void stateChanged(ChangeEvent arg0) {
310
                                        changeSelection();
311
                                }
312
                        });
313
                }
314
                return clipRadioButton;
315
        }
316

    
317
        /**
318
         * This method initializes dissolveRadioButton
319
         * 
320
         * @return javax.swing.JRadioButton
321
         */
322
        private JRadioButton getDissolveRadioButton() {
323
                if (dissolveRadioButton == null) {
324
                        dissolveRadioButton = new JRadioButton();
325
                        dissolveRadioButton.setText(PluginServices
326
                                        .getText(this, "Disolver"));
327
                        dissolveRadioButton.addChangeListener(new ChangeListener(){
328
                                public void stateChanged(ChangeEvent arg0) {
329
                                        changeSelection();
330
                                }
331
                                
332
                        });
333
                }
334
                return dissolveRadioButton;
335
        }
336

    
337
        /**
338
         * This method initializes mergeRadioButton
339
         * 
340
         * @return javax.swing.JRadioButton
341
         */
342
        private JRadioButton getMergeRadioButton() {
343
                if (mergeRadioButton == null) {
344
                        mergeRadioButton = new JRadioButton();
345
                        mergeRadioButton.setText(PluginServices.getText(this, "Juntar"));
346
                        mergeRadioButton.addChangeListener(new ChangeListener(){
347
                                public void stateChanged(ChangeEvent arg0) {
348
                                        changeSelection();
349
                                }
350
                                
351
                        });
352
                }
353
                return mergeRadioButton;
354
        }
355

    
356
        /**
357
         * This method initializes intersectRadioButton
358
         * 
359
         * @return javax.swing.JRadioButton
360
         */
361
        private JRadioButton getIntersectRadioButton() {
362
                if (intersectRadioButton == null) {
363
                        intersectRadioButton = new JRadioButton();
364
                        intersectRadioButton.setText(PluginServices.getText(this,
365
                                        "Interseccion"));
366
                        intersectRadioButton.addChangeListener(new ChangeListener(){
367
                                public void stateChanged(ChangeEvent arg0) {
368
                                        changeSelection();
369
                                }
370
                                
371
                        });
372
                }
373
                return intersectRadioButton;
374
        }
375

    
376
        /**
377
         * This method initializes unionRadioButton
378
         * 
379
         * @return javax.swing.JRadioButton
380
         */
381
        private JRadioButton getUnionRadioButton() {
382
                if (unionRadioButton == null) {
383
                        unionRadioButton = new JRadioButton();
384
                        unionRadioButton.setText(PluginServices.getText(this, "Union"));
385
                        unionRadioButton.addChangeListener(new ChangeListener(){
386
                                public void stateChanged(ChangeEvent arg0) {
387
                                        changeSelection();
388
                                }
389
                                
390
                        });
391
                }
392
                return unionRadioButton;
393
        }
394

    
395
        /**
396
         * This method initializes spatialJoinRadioButton
397
         * 
398
         * @return javax.swing.JRadioButton
399
         */
400
        private JRadioButton getSpatialJoinRadioButton() {
401
                if (spatialJoinRadioButton == null) {
402
                        spatialJoinRadioButton = new JRadioButton();
403
                        spatialJoinRadioButton.setText(PluginServices.getText(this,
404
                                        "Enlace_espacial"));
405
                        spatialJoinRadioButton.addChangeListener(new ChangeListener(){
406
                                public void stateChanged(ChangeEvent arg0) {
407
                                        changeSelection();
408
                                }
409
                                
410
                        });
411
                }
412
                return spatialJoinRadioButton;
413
        }
414

    
415
        /**
416
         * This method initializes convexHullRadioButton        
417
         *         
418
         * @return javax.swing.JRadioButton        
419
         */
420
        private JRadioButton getConvexHullRadioButton() {
421
                if (convexHullRadioButton == null) {
422
                        convexHullRadioButton = new JRadioButton();
423
                        convexHullRadioButton.setText(PluginServices.getText(this,
424
                                        "Convex_Hull"));
425
                        convexHullRadioButton.addChangeListener(new ChangeListener(){
426
                                public void stateChanged(ChangeEvent arg0) {
427
                                        changeSelection();
428
                                }
429
                                
430
                        });
431
                }
432
                return convexHullRadioButton;
433
        }
434

    
435
        /**
436
         * This method initializes differenceRadioButton        
437
         *         
438
         * @return javax.swing.JRadioButton        
439
         */
440
        private JRadioButton getDifferenceRadioButton() {
441
                if (differenceRadioButton == null) {
442
                        differenceRadioButton = new JRadioButton();
443
                        differenceRadioButton.setText(PluginServices.getText(this,
444
                        "Diferencia"));
445
                        differenceRadioButton.addChangeListener(new ChangeListener(){
446
                                public void stateChanged(ChangeEvent arg0) {
447
                                        changeSelection();
448
                                }
449
                                
450
                        });
451
                }
452
                return differenceRadioButton;
453
        }
454

    
455
        /**
456
         * This method initializes mainPanel        
457
         *         
458
         * @return javax.swing.JPanel        
459
         */
460
        private JPanel getMainPanel() {
461
                if (mainPanel == null) {
462
                        mainPanel = new JPanel();
463
                        mainPanel.setLayout(new BoxLayout(getMainPanel(), BoxLayout.Y_AXIS));
464
                        mainPanel.setBounds(new java.awt.Rectangle(4,44,143,328));
465
                        mainPanel.add(getBufferRadioButton(), null);
466
                        mainPanel.add(getDissolveRadioButton(), null);
467
                        mainPanel.add(getClipRadioButton(), null);
468
                        mainPanel.add(getIntersectRadioButton(), null);
469
                        mainPanel.add(getMergeRadioButton(), null);
470
                        mainPanel.add(getUnionRadioButton(), null);
471
                        mainPanel.add(getSpatialJoinRadioButton(), null);
472
                        mainPanel.add(getConvexHullRadioButton(), null);
473
                        mainPanel.add(getDifferenceRadioButton(), null);
474
                }
475
                return mainPanel;
476
        }
477
}  //  @jve:decl-index=0:visual-constraint="24,7"