Statistics
| Revision:

root / trunk / extensions / extGeoProcessing / src / com / iver / gvsig / geoprocessing / gui / operationpanels / GeoProcessingOperationSelectorPanel.java @ 4824

History | View | Annotate | Download (12.4 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.gvsig.geoprocessing.gui.operationpanels;
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
import com.iver.gvsig.geoprocessing.GeoProcessingExtension;
58

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

    
67
import javax.swing.BoxLayout;
68

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

    
81
        private JRadioButton bufferRadioButton = null;
82

    
83
        private JRadioButton dissolveRadioButton = null;
84

    
85
        private JRadioButton mergeRadioButton = null;
86

    
87
        private JRadioButton intersectRadioButton = null;
88

    
89
        private JRadioButton unionRadioButton = null;
90

    
91
        private JRadioButton spatialJoinRadioButton = null;
92

    
93
        private JRadioButton clipRadioButton = null;
94

    
95
        private ButtonGroup buttonGroup = null;
96

    
97
        private JRadioButton convexHullRadioButton = null;
98

    
99
        private JRadioButton differenceRadioButton = null;
100

    
101
        private JPanel mainPanel = null;
102

    
103
        private JLabel imageLabel = null;
104

    
105
        private ImageIcon bufferDescIcon;
106

    
107
        private ImageIcon dissolveDescIcon;
108

    
109
        private ImageIcon mergeDescIcon;
110

    
111
        private ImageIcon intersectDescIcon;
112

    
113
        private ImageIcon unionDescIcon;
114

    
115
        private ImageIcon spatialJoinDescIcon;
116

    
117
        private ImageIcon clipDescIcon;
118

    
119
        private ImageIcon convexHullDescIcon;
120

    
121
        private ImageIcon differenceDescIcon;
122

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

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

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

    
277
                }
278
        }
279

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

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

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

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

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

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

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

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

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

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