Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / core / gui / SumarizeFunctionsDialog.java @ 10626

History | View | Annotate | Download (9.16 KB)

1
/*
2
 * Created on 24-feb-2006
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
/* CVS MESSAGES:
45
 *
46
 * $Id: SumarizeFunctionsDialog.java 10626 2007-03-06 16:55:54Z caballero $
47
 * $Log$
48
 * Revision 1.2  2007-03-06 16:47:58  caballero
49
 * Exceptions
50
 *
51
 * Revision 1.1  2006/05/24 21:13:09  azabala
52
 * primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
53
 *
54
 * Revision 1.5  2006/04/11 18:02:42  azabala
55
 * Intento de que el Panel salga bien en todas las resoluciones (y de dejarlos mas bonitos)
56
 *
57
 * Revision 1.4  2006/04/07 19:00:58  azabala
58
 * *** empty log message ***
59
 *
60
 * Revision 1.3  2006/03/26 20:02:08  azabala
61
 * *** empty log message ***
62
 *
63
 * Revision 1.2  2006/03/05 19:53:25  azabala
64
 * *** empty log message ***
65
 *
66
 * Revision 1.1  2006/02/26 20:52:13  azabala
67
 * *** empty log message ***
68
 *
69
 *
70
 */
71
package com.iver.cit.gvsig.geoprocess.core.gui;
72

    
73
import java.awt.GridBagConstraints;
74
import java.awt.GridBagLayout;
75
import java.awt.event.ActionEvent;
76
import java.awt.event.ActionListener;
77
import java.util.ArrayList;
78
import java.util.List;
79

    
80
import javax.swing.JButton;
81
import javax.swing.JCheckBox;
82
import javax.swing.JDialog;
83
import javax.swing.JFrame;
84
import javax.swing.JLabel;
85
import javax.swing.JPanel;
86

    
87
import com.iver.andami.PluginServices;
88
import com.iver.cit.gvsig.geoprocess.core.fmap.AverageFunction;
89
import com.iver.cit.gvsig.geoprocess.core.fmap.MaxFunction;
90
import com.iver.cit.gvsig.geoprocess.core.fmap.MinFunction;
91
import com.iver.cit.gvsig.geoprocess.core.fmap.SumFunction;
92
import com.iver.cit.gvsig.geoprocess.core.fmap.SummarizationFunction;
93
/**
94
 * Component to select sumarization functions
95
 * to numeric fields.
96
 * @author azabala
97
 * 
98
 * FIXME Internationalize texts
99
 *
100
 */
101
public class SumarizeFunctionsDialog extends JDialog implements SumarizeFuntDialogIF{
102
        private static final long serialVersionUID = 6085468284091604644L;
103
        private JPanel jContentPane = null;
104
        private JPanel maxJPanel = null;
105
        private JLabel maxLabel = null;
106
        private JCheckBox maxCheckBox = null;
107
        private JPanel jPanel = null;
108
        private JLabel minLabel = null;
109
        private JCheckBox minCheckBox = null;
110
        private JPanel jPanel1 = null;
111
        private JLabel avgLabel = null;
112
        private JCheckBox avgCheckBox = null;
113
        private JPanel jPanel2 = null;
114
        private JLabel sumLabel = null;
115
        private JCheckBox sumCheckBox = null;
116
        private JButton okButton = null;
117

    
118
        private List selectedFunctions;
119
        /**
120
         * This is the default constructor
121
         */
122
        public SumarizeFunctionsDialog() {
123
                super((JFrame)PluginServices.getMainFrame(), true);
124
                initialize();
125
        }
126

    
127
        /**
128
         * This method initializes this
129
         * 
130
         * @return void
131
         */
132
        private void initialize() {
133
                this.setSize(241, 161);
134
                String title = PluginServices.getText(this, "Funciones_Sumarizacion");
135
                this.setTitle(title);
136
                this.setContentPane(getJContentPane());
137
                selectedFunctions = new ArrayList();
138
        }
139

    
140
        /**
141
         * This method initializes jContentPane
142
         * 
143
         * @return javax.swing.JPanel
144
         */
145
        private JPanel getJContentPane() {
146
                if (jContentPane == null) {
147
                        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
148
                        gridBagConstraints5.insets = new java.awt.Insets(7,79,21,73);
149
                        gridBagConstraints5.gridx = 0;
150
                        gridBagConstraints5.gridy = 2;
151
                        gridBagConstraints5.ipadx = 2;
152
                        gridBagConstraints5.gridwidth = 2;
153
                        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
154
                        gridBagConstraints4.insets = new java.awt.Insets(7,14,7,27);
155
                        gridBagConstraints4.gridy = 1;
156
                        gridBagConstraints4.ipadx = 8;
157
                        gridBagConstraints4.gridx = 1;
158
                        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
159
                        gridBagConstraints3.insets = new java.awt.Insets(18,13,6,29);
160
                        gridBagConstraints3.gridy = 0;
161
                        gridBagConstraints3.ipadx = -1;
162
                        gridBagConstraints3.gridx = 1;
163
                        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
164
                        gridBagConstraints2.insets = new java.awt.Insets(6,31,8,12);
165
                        gridBagConstraints2.gridy = 1;
166
                        gridBagConstraints2.ipadx = 2;
167
                        gridBagConstraints2.gridx = 0;
168
                        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
169
                        gridBagConstraints1.insets = new java.awt.Insets(18,29,6,12);
170
                        gridBagConstraints1.gridy = 0;
171
                        gridBagConstraints1.gridx = 0;
172
                        jContentPane = new JPanel();
173
                        jContentPane.setLayout(new GridBagLayout());
174
                        jContentPane.add(getMaxJPanel(), gridBagConstraints1);
175
                        jContentPane.add(getJPanel(), gridBagConstraints2);
176
                        jContentPane.add(getJPanel1(), gridBagConstraints3);
177
                        jContentPane.add(getJPanel2(), gridBagConstraints4);
178
                        jContentPane.add(getOkButton(), gridBagConstraints5);
179
                }
180
                return jContentPane;
181
        }
182

    
183
        /**
184
         * This method initializes maxJPanel        
185
         *         
186
         * @return javax.swing.JPanel        
187
         */
188
        private JPanel getMaxJPanel() {
189
                if (maxJPanel == null) {
190
                        maxLabel = new JLabel();
191
                        String max = PluginServices.getText(this, "Maximo");
192
                        maxLabel.setText(max);
193
                        maxJPanel = new JPanel();
194
                        maxJPanel.add(maxLabel, null);
195
                        maxJPanel.add(getMaxCheckBox(), null);
196
                }
197
                return maxJPanel;
198
        }
199

    
200
        /**
201
         * This method initializes maxCheckBox        
202
         *         
203
         * @return javax.swing.JCheckBox        
204
         */
205
        private JCheckBox getMaxCheckBox() {
206
                if (maxCheckBox == null) {
207
                        maxCheckBox = new JCheckBox();
208
                }
209
                return maxCheckBox;
210
        }
211

    
212
        /**
213
         * This method initializes jPanel        
214
         *         
215
         * @return javax.swing.JPanel        
216
         */
217
        private JPanel getJPanel() {
218
                if (jPanel == null) {
219
                        minLabel = new JLabel();
220
                        String min = PluginServices.getText(this, "Minimo");
221
                        minLabel.setText(min);
222
                        jPanel = new JPanel();
223
                        jPanel.add(minLabel, null);
224
                        jPanel.add(getMinCheckBox(), null);
225
                }
226
                return jPanel;
227
        }
228

    
229
        /**
230
         * This method initializes minCheckBox        
231
         *         
232
         * @return javax.swing.JCheckBox        
233
         */
234
        private JCheckBox getMinCheckBox() {
235
                if (minCheckBox == null) {
236
                        minCheckBox = new JCheckBox();
237
                }
238
                return minCheckBox;
239
        }
240

    
241
        /**
242
         * This method initializes jPanel1        
243
         *         
244
         * @return javax.swing.JPanel        
245
         */
246
        private JPanel getJPanel1() {
247
                if (jPanel1 == null) {
248
                        avgLabel = new JLabel();
249
                        String media = 
250
                                PluginServices.getText(this, "Media");
251
                        avgLabel.setText(media);
252
                        jPanel1 = new JPanel();
253
                        jPanel1.add(avgLabel, null);
254
                        jPanel1.add(getJCheckBox(), null);
255
                }
256
                return jPanel1;
257
        }
258

    
259
        /**
260
         * This method initializes jCheckBox        
261
         *         
262
         * @return javax.swing.JCheckBox        
263
         */
264
        private JCheckBox getJCheckBox() {
265
                if (avgCheckBox == null) {
266
                        avgCheckBox = new JCheckBox();
267
                }
268
                return avgCheckBox;
269
        }
270

    
271
        /**
272
         * This method initializes jPanel2        
273
         *         
274
         * @return javax.swing.JPanel        
275
         */
276
        private JPanel getJPanel2() {
277
                if (jPanel2 == null) {
278
                        sumLabel = new JLabel();
279
                        String sum = PluginServices.getText(this, "Sum");
280
                        sumLabel.setText(sum);
281
                        jPanel2 = new JPanel();
282
                        jPanel2.add(sumLabel, null);
283
                        jPanel2.add(getJCheckBox2(), null);
284
                }
285
                return jPanel2;
286
        }
287

    
288
        /**
289
         * This method initializes jCheckBox        
290
         *         
291
         * @return javax.swing.JCheckBox        
292
         */
293
        private JCheckBox getJCheckBox2() {
294
                if (sumCheckBox == null) {
295
                        sumCheckBox = new JCheckBox();
296
                }
297
                return sumCheckBox;
298
        }
299

    
300
        /**
301
         * This method initializes okButton        
302
         *         
303
         * @return javax.swing.JButton        
304
         */
305
        private JButton getOkButton() {
306
                if (okButton == null) {
307
                        okButton = new JButton();
308
                        String ok = PluginServices.getText(this, "Aceptar");
309
                        okButton.setText(ok);
310
                        okButton.addActionListener(new ActionListener(){
311
                                public void actionPerformed(ActionEvent arg0) {
312
                                        ok();
313
                                }});
314
                }
315
                return okButton;
316
        }
317

    
318
        public void ok() {
319
                
320
                if(minCheckBox.isSelected()){
321
                        selectedFunctions.add(new MinFunction());
322
                }
323
                if(maxCheckBox.isSelected()){
324
                        selectedFunctions.add(new MaxFunction());
325
                }
326
                if(avgCheckBox.isSelected()){
327
                        selectedFunctions.add(new AverageFunction());
328
                }
329
                if(sumCheckBox.isSelected()){
330
                        selectedFunctions.add(new SumFunction());
331
                }
332
                this.dispose();
333
                
334
        }
335

    
336
        public SummarizationFunction[] getFunctions() {
337
                SummarizationFunction[] solution =
338
                        new SummarizationFunction[selectedFunctions.size()];
339
                selectedFunctions.toArray(solution);
340
                return solution;
341
                
342
        }
343

    
344
        public void resetCheckbox() {
345
                minCheckBox.setSelected(false);
346
                maxCheckBox.setSelected(false);
347
                avgCheckBox.setSelected(false);
348
                sumCheckBox.setSelected(false);
349
                selectedFunctions.clear();
350
                
351
        }
352

    
353
}  //  @jve:decl-index=0:visual-constraint="76,15"