Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_905 / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / wizard / GeoProcessingOperationSelectorPanel.java @ 10767

History | View | Annotate | Download (12.1 KB)

1 5412 azabala
/*
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 6143 jaume
import java.net.URL;
47
48
import javax.swing.BoxLayout;
49 5412 azabala
import javax.swing.ButtonGroup;
50
import javax.swing.ImageIcon;
51
import javax.swing.JLabel;
52
import javax.swing.JPanel;
53
import javax.swing.JRadioButton;
54
import javax.swing.event.ChangeEvent;
55
import javax.swing.event.ChangeListener;
56
57
import com.iver.andami.PluginServices;
58
59
/**
60 6137 jaume
 *
61 5412 azabala
 * This component is the first step of GeoProcessing Wizard. It allows user to
62
 * select which geoprocessing operation want to do.
63 6137 jaume
 *
64 5412 azabala
 * @author jmorell, azabala
65
 */
66
public class GeoProcessingOperationSelectorPanel extends JPanel {
67
        private static final long serialVersionUID = 1L;
68 6137 jaume
69 5412 azabala
        private JLabel jLabel = null;
70
71
        private JRadioButton bufferRadioButton = null;
72
73
        private JRadioButton dissolveRadioButton = null;
74
75
        private JRadioButton mergeRadioButton = null;
76
77
        private JRadioButton intersectRadioButton = null;
78
79
        private JRadioButton unionRadioButton = null;
80
81
        private JRadioButton spatialJoinRadioButton = null;
82
83
        private JRadioButton clipRadioButton = null;
84
85
        private ButtonGroup buttonGroup = null;
86
87
        private JRadioButton convexHullRadioButton = null;
88
89
        private JRadioButton differenceRadioButton = null;
90
91
        private JPanel mainPanel = null;
92
93
        private JLabel imageLabel = null;
94
95
        private ImageIcon bufferDescIcon;
96
97
        private ImageIcon dissolveDescIcon;
98
99
        private ImageIcon mergeDescIcon;
100
101
        private ImageIcon intersectDescIcon;
102
103
        private ImageIcon unionDescIcon;
104
105
        private ImageIcon spatialJoinDescIcon;
106
107
        private ImageIcon clipDescIcon;
108
109
        private ImageIcon convexHullDescIcon;
110
111
        private ImageIcon differenceDescIcon;
112
113
        /**
114
         * This is the default constructor
115
         */
116
        public GeoProcessingOperationSelectorPanel() {
117
                super();
118
                initialize();
119
        }
120 6137 jaume
121 5412 azabala
        public void changeSelection(){
122
                if(isBufferSelected()){
123
                        imageLabel.setIcon(bufferDescIcon);
124
                }else if(isDissolveSelected()){
125
                        imageLabel.setIcon(dissolveDescIcon);
126
                }else if(isMergeSelected()){
127
                        imageLabel.setIcon(mergeDescIcon);
128
                }else if(isIntersectSelected()){
129
                        imageLabel.setIcon(intersectDescIcon);
130
                }else if(isUnionSelected()){
131
                        imageLabel.setIcon(unionDescIcon);
132
                }else if(isClipSelected()){
133
                        imageLabel.setIcon(clipDescIcon);
134
                }else if(isSpatialJoinSelected()){
135
                        imageLabel.setIcon(spatialJoinDescIcon);
136
                }else if(isDifferenceSelected()){
137
                        imageLabel.setIcon(differenceDescIcon);
138
                }else if(isConvexHullSelected()){
139
                        imageLabel.setIcon(convexHullDescIcon);
140
                }
141
        }
142 6137 jaume
143 5412 azabala
        public boolean isBufferSelected(){
144
                return bufferRadioButton.isSelected();
145
        }
146 6137 jaume
147 5412 azabala
        public boolean isDissolveSelected(){
148
                return dissolveRadioButton.isSelected();
149
        }
150 6137 jaume
151 5412 azabala
        public boolean isMergeSelected(){
152
                return mergeRadioButton.isSelected();
153
        }
154 6137 jaume
155 5412 azabala
        public boolean isIntersectSelected(){
156
                return intersectRadioButton.isSelected();
157
        }
158 6137 jaume
159 5412 azabala
        public boolean isUnionSelected(){
160
                return unionRadioButton.isSelected();
161
        }
162 6137 jaume
163 5412 azabala
        public boolean isClipSelected(){
164
                return clipRadioButton.isSelected();
165
        }
166 6137 jaume
167 5412 azabala
        public boolean isSpatialJoinSelected(){
168
                return spatialJoinRadioButton.isSelected();
169
        }
170 6137 jaume
171 5412 azabala
        public boolean isDifferenceSelected(){
172
                return differenceRadioButton.isSelected();
173
        }
174 6137 jaume
175 5412 azabala
        public boolean isConvexHullSelected(){
176
                return convexHullRadioButton.isSelected();
177
        }
178
179
        private void initializeImages(){
180
                URL url =         GeoProcessingExtension.class.
181
                                                        getClassLoader().
182
                                                        getResource("images/bufferdesc.png");
183 6137 jaume
                bufferDescIcon =
184 5412 azabala
                        new ImageIcon(url);
185
                url =         GeoProcessingExtension.class.
186
                                getClassLoader().
187
                                getResource("images/dissolvedesc.png");
188 6137 jaume
                dissolveDescIcon =
189 5412 azabala
                        new ImageIcon(url);
190
                url =         GeoProcessingExtension.class.
191
                        getClassLoader().
192
                        getResource("images/mergedesc.png");
193 6137 jaume
                mergeDescIcon =
194 5412 azabala
                        new ImageIcon(url);
195
                url =         GeoProcessingExtension.class.
196
                                getClassLoader().
197
                                getResource("images/intersectdesc.png");
198 6137 jaume
                intersectDescIcon =
199 5412 azabala
                        new ImageIcon(url);
200
                url =         GeoProcessingExtension.class.
201
                                getClassLoader().
202
                                getResource("images/uniondesc.png");
203 6137 jaume
                unionDescIcon =
204 5412 azabala
                        new ImageIcon(url);
205
                url =         GeoProcessingExtension.class.
206
                                getClassLoader().
207
                                getResource("images/spatialjoindesc.png");
208 6137 jaume
                spatialJoinDescIcon =
209 5412 azabala
                        new ImageIcon(url);
210
                url =         GeoProcessingExtension.class.
211
                                getClassLoader().
212
                                getResource("images/clipdesc.png");
213 6137 jaume
                clipDescIcon =
214 5412 azabala
                        new ImageIcon(url);
215
                url =         GeoProcessingExtension.class.
216
                                getClassLoader().
217
                                getResource("images/convexhulldesc.png");
218 6137 jaume
                convexHullDescIcon =
219 5412 azabala
                        new ImageIcon(url);
220
                url =         GeoProcessingExtension.class.
221
                                getClassLoader().
222
                                getResource("images/differencedesc.png");
223 6137 jaume
                differenceDescIcon =
224 5412 azabala
                        new ImageIcon(url);
225 6137 jaume
226 5412 azabala
        }
227 6137 jaume
228 5412 azabala
        /**
229
         * This method initializes this
230 6137 jaume
         *
231 5412 azabala
         * @return void
232
         */
233
        private void initialize() {
234 6137 jaume
235 5412 azabala
                initializeImages();
236
                imageLabel = new JLabel();
237
                imageLabel.setText("");
238 6137 jaume
                imageLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);
239
                imageLabel.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
240 5412 azabala
                imageLabel.setIcon(bufferDescIcon);
241 6139 jaume
                imageLabel.setBounds(new java.awt.Rectangle(5,44,271,328));
242 5412 azabala
                jLabel = new JLabel();
243
                this.setLayout(null);
244
                this.setBounds(new java.awt.Rectangle(0,0,486,377));
245
                this.add(jLabel, null);
246
                this.add(imageLabel, null);
247
                jLabel.setText(PluginServices.getText(this,
248
                                "Elija_una_herramienta_de_analisis")
249
                                + ":");
250 6139 jaume
                this.add(getMainPanel(), null);
251
252 6143 jaume
                jLabel.setBounds(new java.awt.Rectangle(4,5,471,32));
253 5412 azabala
                confButtonGroup();
254
                getBufferRadioButton().setSelected(true);
255
        }
256
257
        private void confButtonGroup() {
258
                if (buttonGroup == null) {
259
                        buttonGroup = new ButtonGroup();
260
                        buttonGroup.add(getBufferRadioButton());
261
                        buttonGroup.add(getDissolveRadioButton());
262
                        buttonGroup.add(getMergeRadioButton());
263
                        buttonGroup.add(getIntersectRadioButton());
264
                        buttonGroup.add(getUnionRadioButton());
265
                        buttonGroup.add(getSpatialJoinRadioButton());
266
                        buttonGroup.add(getClipRadioButton());
267
                        buttonGroup.add(getConvexHullRadioButton());
268
                        buttonGroup.add(getDifferenceRadioButton());
269
270
                }
271
        }
272
273
        /**
274
         * This method initializes bufferRadioButton
275 6137 jaume
         *
276 5412 azabala
         * @return javax.swing.JRadioButton
277
         */
278
        private JRadioButton getBufferRadioButton() {
279
                if (bufferRadioButton == null) {
280
                        bufferRadioButton = new JRadioButton();
281
                        bufferRadioButton.setText(PluginServices.getText(this,
282
                                        "Area_de_influencia"));
283
                        bufferRadioButton.addChangeListener(new ChangeListener(){
284
                                public void stateChanged(ChangeEvent arg0) {
285
                                        changeSelection();
286
                                }
287 6137 jaume
288 5412 azabala
                        });
289
                }
290
                return bufferRadioButton;
291
        }
292
293
        /**
294
         * This method initializes clipRadioButton
295 6137 jaume
         *
296 5412 azabala
         * @return javax.swing.JRadioButton
297
         */
298
        private JRadioButton getClipRadioButton() {
299
                if (clipRadioButton == null) {
300
                        clipRadioButton = new JRadioButton();
301
                        clipRadioButton.setText(PluginServices.getText(this, "Recortar"));
302
                        clipRadioButton.addChangeListener(new ChangeListener(){
303
                                public void stateChanged(ChangeEvent arg0) {
304
                                        changeSelection();
305
                                }
306
                        });
307
                }
308
                return clipRadioButton;
309
        }
310
311
        /**
312
         * This method initializes dissolveRadioButton
313 6137 jaume
         *
314 5412 azabala
         * @return javax.swing.JRadioButton
315
         */
316
        private JRadioButton getDissolveRadioButton() {
317
                if (dissolveRadioButton == null) {
318
                        dissolveRadioButton = new JRadioButton();
319
                        dissolveRadioButton.setText(PluginServices
320
                                        .getText(this, "Disolver"));
321
                        dissolveRadioButton.addChangeListener(new ChangeListener(){
322
                                public void stateChanged(ChangeEvent arg0) {
323
                                        changeSelection();
324
                                }
325 6137 jaume
326 5412 azabala
                        });
327
                }
328
                return dissolveRadioButton;
329
        }
330
331
        /**
332
         * This method initializes mergeRadioButton
333 6137 jaume
         *
334 5412 azabala
         * @return javax.swing.JRadioButton
335
         */
336
        private JRadioButton getMergeRadioButton() {
337
                if (mergeRadioButton == null) {
338
                        mergeRadioButton = new JRadioButton();
339
                        mergeRadioButton.setText(PluginServices.getText(this, "Juntar"));
340
                        mergeRadioButton.addChangeListener(new ChangeListener(){
341
                                public void stateChanged(ChangeEvent arg0) {
342
                                        changeSelection();
343
                                }
344 6137 jaume
345 5412 azabala
                        });
346
                }
347
                return mergeRadioButton;
348
        }
349
350
        /**
351
         * This method initializes intersectRadioButton
352 6137 jaume
         *
353 5412 azabala
         * @return javax.swing.JRadioButton
354
         */
355
        private JRadioButton getIntersectRadioButton() {
356
                if (intersectRadioButton == null) {
357
                        intersectRadioButton = new JRadioButton();
358
                        intersectRadioButton.setText(PluginServices.getText(this,
359
                                        "Interseccion"));
360
                        intersectRadioButton.addChangeListener(new ChangeListener(){
361
                                public void stateChanged(ChangeEvent arg0) {
362
                                        changeSelection();
363
                                }
364 6137 jaume
365 5412 azabala
                        });
366
                }
367
                return intersectRadioButton;
368
        }
369
370
        /**
371
         * This method initializes unionRadioButton
372 6137 jaume
         *
373 5412 azabala
         * @return javax.swing.JRadioButton
374
         */
375
        private JRadioButton getUnionRadioButton() {
376
                if (unionRadioButton == null) {
377
                        unionRadioButton = new JRadioButton();
378
                        unionRadioButton.setText(PluginServices.getText(this, "Union"));
379
                        unionRadioButton.addChangeListener(new ChangeListener(){
380
                                public void stateChanged(ChangeEvent arg0) {
381
                                        changeSelection();
382
                                }
383 6137 jaume
384 5412 azabala
                        });
385
                }
386
                return unionRadioButton;
387
        }
388
389
        /**
390
         * This method initializes spatialJoinRadioButton
391 6137 jaume
         *
392 5412 azabala
         * @return javax.swing.JRadioButton
393
         */
394
        private JRadioButton getSpatialJoinRadioButton() {
395
                if (spatialJoinRadioButton == null) {
396
                        spatialJoinRadioButton = new JRadioButton();
397
                        spatialJoinRadioButton.setText(PluginServices.getText(this,
398
                                        "Enlace_espacial"));
399
                        spatialJoinRadioButton.addChangeListener(new ChangeListener(){
400
                                public void stateChanged(ChangeEvent arg0) {
401
                                        changeSelection();
402
                                }
403 6137 jaume
404 5412 azabala
                        });
405
                }
406
                return spatialJoinRadioButton;
407
        }
408
409
        /**
410 6137 jaume
         * This method initializes convexHullRadioButton
411
         *
412
         * @return javax.swing.JRadioButton
413 5412 azabala
         */
414
        private JRadioButton getConvexHullRadioButton() {
415
                if (convexHullRadioButton == null) {
416
                        convexHullRadioButton = new JRadioButton();
417
                        convexHullRadioButton.setText(PluginServices.getText(this,
418
                                        "Convex_Hull"));
419
                        convexHullRadioButton.addChangeListener(new ChangeListener(){
420
                                public void stateChanged(ChangeEvent arg0) {
421
                                        changeSelection();
422
                                }
423 6137 jaume
424 5412 azabala
                        });
425
                }
426
                return convexHullRadioButton;
427
        }
428
429
        /**
430 6137 jaume
         * This method initializes differenceRadioButton
431
         *
432
         * @return javax.swing.JRadioButton
433 5412 azabala
         */
434
        private JRadioButton getDifferenceRadioButton() {
435
                if (differenceRadioButton == null) {
436
                        differenceRadioButton = new JRadioButton();
437
                        differenceRadioButton.setText(PluginServices.getText(this,
438
                        "Diferencia"));
439
                        differenceRadioButton.addChangeListener(new ChangeListener(){
440
                                public void stateChanged(ChangeEvent arg0) {
441
                                        changeSelection();
442
                                }
443 6137 jaume
444 5412 azabala
                        });
445
                }
446
                return differenceRadioButton;
447
        }
448
449
        /**
450 6137 jaume
         * This method initializes mainPanel
451
         *
452
         * @return javax.swing.JPanel
453 5412 azabala
         */
454
        private JPanel getMainPanel() {
455
                if (mainPanel == null) {
456
                        mainPanel = new JPanel();
457
                        mainPanel.setLayout(new BoxLayout(getMainPanel(), BoxLayout.Y_AXIS));
458 6139 jaume
                        mainPanel.setBounds(new java.awt.Rectangle(283,44,192,328));
459 5412 azabala
                        mainPanel.add(getBufferRadioButton(), null);
460
                        mainPanel.add(getDissolveRadioButton(), null);
461
                        mainPanel.add(getClipRadioButton(), null);
462
                        mainPanel.add(getIntersectRadioButton(), null);
463
                        mainPanel.add(getMergeRadioButton(), null);
464
                        mainPanel.add(getUnionRadioButton(), null);
465
                        mainPanel.add(getSpatialJoinRadioButton(), null);
466
                        mainPanel.add(getConvexHullRadioButton(), null);
467
                        mainPanel.add(getDifferenceRadioButton(), null);
468
                }
469
                return mainPanel;
470
        }
471
}  //  @jve:decl-index=0:visual-constraint="24,7"