Statistics
| Revision:

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

History | View | Annotate | Download (9.45 KB)

1
/*
2
 * Created on 01-mar-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: SpatialJoinNumericFieldSelection.java 5919 2006-06-20 18:21:48Z azabala $
47
 * $Log$
48
 * Revision 1.2  2006-06-20 18:19:43  azabala
49
 * refactorizaci?n para que todos los nuevos geoprocesos cuelguen del paquete impl
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.4  2006/04/07 19:00:58  azabala
55
 * *** empty log message ***
56
 *
57
 * Revision 1.3  2006/03/26 20:02:08  azabala
58
 * *** empty log message ***
59
 *
60
 * Revision 1.2  2006/03/23 21:02:37  azabala
61
 * *** empty log message ***
62
 *
63
 * Revision 1.1  2006/03/05 19:56:06  azabala
64
 * *** empty log message ***
65
 *
66
 *
67
 */
68
package com.iver.cit.gvsig.geoprocess.core.gui;
69

    
70
import java.awt.event.ActionEvent;
71
import java.awt.event.ActionListener;
72
import java.util.HashMap;
73
import java.util.Map;
74

    
75
import javax.swing.JButton;
76
import javax.swing.JDialog;
77
import javax.swing.JFrame;
78
import javax.swing.JLabel;
79
import javax.swing.JList;
80
import javax.swing.JPanel;
81
import javax.swing.JScrollPane;
82

    
83
import com.iver.andami.PluginServices;
84
import com.iver.cit.gvsig.geoprocess.core.fmap.SummarizationFunction;
85

    
86
import java.awt.GridBagLayout;
87
import java.awt.GridBagConstraints;
88
/**
89
 * FIXME: INTERNACIONALIZAR LOS TEXTOS
90
 *                   QUITAR LOS LISTMODEL REPETIDOS DEL DISSOLVE
91
 * @author azabala
92
 *
93
 */
94
public class SpatialJoinNumericFieldSelection 
95
        extends JDialog implements SpatialJoinNumFieldIF {
96

    
97
        private static final long serialVersionUID = -9031708821779458450L;
98
        private JPanel jContentPane = null;
99
        private JScrollPane numericFieldScrollPane = null;
100
        private JList numericFieldJList = null;
101
        private JScrollPane functionScrollPane = null;
102
        private JList functionJList = null;
103
        private JButton linkButton = null;
104
        private JLabel fieldsLabel = null;
105
        private JLabel functionsLabel = null;
106
        private JButton okButton = null;
107
        private SumarizeFunctionsDialog sumarizeFuncDialog;
108
        
109
        private Map nField_sumFuntionList;
110
        private String[] numericFields;
111
        private boolean ok = false;
112
        /**
113
         * This is the default constructor
114
         */
115
        public SpatialJoinNumericFieldSelection() {
116
                super((JFrame)PluginServices.getMainFrame(), true);
117
                initialize();
118
        }
119

    
120
        /**
121
         * This method initializes this
122
         * 
123
         * @return void
124
         */
125
        private void initialize() {
126
                this.setSize(351, 236);
127
                this.setTitle(PluginServices.getText(this,"Funciones_Sumarizacion"));
128
                this.setContentPane(getJContentPane());
129
                this.nField_sumFuntionList = new HashMap();
130
        }
131

    
132
        /**
133
         * This method initializes jContentPane
134
         * 
135
         * @return javax.swing.JPanel
136
         */
137
        private JPanel getJContentPane() {
138
                if (jContentPane == null) {
139
                        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
140
                        gridBagConstraints5.insets = new java.awt.Insets(8,6,28,2);
141
                        gridBagConstraints5.gridy = 2;
142
                        gridBagConstraints5.ipadx = 10;
143
                        gridBagConstraints5.ipady = -10;
144
                        gridBagConstraints5.gridx = 1;
145
                        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
146
                        gridBagConstraints4.insets = new java.awt.Insets(0,66,5,12);
147
                        gridBagConstraints4.gridx = 1;
148
                        gridBagConstraints4.gridy = 0;
149
                        gridBagConstraints4.ipadx = 0;
150
                        gridBagConstraints4.gridwidth = 2;
151
                        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
152
                        gridBagConstraints3.insets = new java.awt.Insets(0,15,5,8);
153
                        gridBagConstraints3.gridy = 0;
154
                        gridBagConstraints3.gridwidth = 1;
155
                        gridBagConstraints3.gridheight = 1;
156
                        gridBagConstraints3.gridx = 0;
157
                        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
158
                        gridBagConstraints2.insets = new java.awt.Insets(54,6,66,2);
159
                        gridBagConstraints2.gridy = 1;
160
                        gridBagConstraints2.ipadx = 16;
161
                        gridBagConstraints2.ipady = -10;
162
                        gridBagConstraints2.fill = java.awt.GridBagConstraints.NONE;
163
                        gridBagConstraints2.gridx = 1;
164
                        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
165
                        gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
166
                        gridBagConstraints1.gridx = 2;
167
                        gridBagConstraints1.gridy = 1;
168
                        gridBagConstraints1.ipadx = -152;
169
                        gridBagConstraints1.ipady = -9;
170
                        gridBagConstraints1.weightx = 1.0;
171
                        gridBagConstraints1.weighty = 1.0;
172
                        gridBagConstraints1.insets = new java.awt.Insets(6,2,8,21);
173
                        GridBagConstraints gridBagConstraints = new GridBagConstraints();
174
                        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
175
                        gridBagConstraints.gridx = 0;
176
                        gridBagConstraints.gridy = 1;
177
                        gridBagConstraints.ipadx = -134;
178
                        gridBagConstraints.ipady = -10;
179
                        gridBagConstraints.weightx = 1.0;
180
                        gridBagConstraints.weighty = 1.0;
181
                        gridBagConstraints.insets = new java.awt.Insets(7,13,8,6);
182
                        functionsLabel = new JLabel();
183
                        functionsLabel.setText(PluginServices.getText(this, "Funciones_Sumarizacion"));
184
                        fieldsLabel = new JLabel();
185
                        fieldsLabel.setText(PluginServices.getText(this, "Atributos_Numericos"));
186
                        jContentPane = new JPanel();
187
                        jContentPane.setLayout(new GridBagLayout());
188
                        jContentPane.add(getNumericFieldScrollPane(), gridBagConstraints);
189
                        jContentPane.add(getFunctionScrollPane(), gridBagConstraints1);
190
                        jContentPane.add(getLinkButton(), gridBagConstraints2);
191
                        jContentPane.add(fieldsLabel, gridBagConstraints3);
192
                        jContentPane.add(functionsLabel, gridBagConstraints4);
193
                        jContentPane.add(getOkButton(), gridBagConstraints5);
194
                }
195
                return jContentPane;
196
        }
197

    
198
        /**
199
         * This method initializes numericFieldScrollPane        
200
         *         
201
         * @return javax.swing.JScrollPane        
202
         */
203
        private JScrollPane getNumericFieldScrollPane() {
204
                if (numericFieldScrollPane == null) {
205
                        numericFieldScrollPane = new JScrollPane();
206
                        numericFieldScrollPane.setViewportView(getNumericFieldJList());
207
                }
208
                return numericFieldScrollPane;
209
        }
210

    
211
        /**
212
         * This method initializes numericFieldJList        
213
         *         
214
         * @return javax.swing.JList        
215
         */
216
        private JList getNumericFieldJList() {
217
                if (numericFieldJList == null) {
218
                        numericFieldJList = new JList();
219
                }
220
                return numericFieldJList;
221
        }
222

    
223
        /**
224
         * This method initializes functionScrollPane        
225
         *         
226
         * @return javax.swing.JScrollPane        
227
         */
228
        private JScrollPane getFunctionScrollPane() {
229
                if (functionScrollPane == null) {
230
                        functionScrollPane = new JScrollPane();
231
                        functionScrollPane.setViewportView(getFunctionJList());
232
                }
233
                return functionScrollPane;
234
        }
235

    
236
        /**
237
         * This method initializes functionJList        
238
         *         
239
         * @return javax.swing.JList        
240
         */
241
        private JList getFunctionJList() {
242
                if (functionJList == null) {
243
                        functionJList = new JList();
244
                }
245
                return functionJList;
246
        }
247

    
248
        /**
249
         * This method initializes linkButton        
250
         *         
251
         * @return javax.swing.JButton        
252
         */
253
        private JButton getLinkButton() {
254
                if (linkButton == null) {
255
                        linkButton = new JButton();
256
                        linkButton.setText("<-");
257
                        linkButton.addActionListener(new ActionListener(){
258
                                public void actionPerformed(ActionEvent arg0) {
259
                                        showFunctionsDialog();
260
                                }});
261
                }
262
                return linkButton;
263
        }
264

    
265
        /**
266
         * This method initializes okButton        
267
         *         
268
         * @return javax.swing.JButton        
269
         */
270
        private JButton getOkButton() {
271
                if (okButton == null) {
272
                        okButton = new JButton();
273
                        String okText = PluginServices.getText(this, "Aceptar");
274
                        okButton.setText(okText);
275
                        okButton.addActionListener(new ActionListener(){
276
                                public void actionPerformed(ActionEvent arg0) {
277
                                        ok();
278
                                        
279
                                }});
280
                }
281
                return okButton;
282
        }
283

    
284
        public void ok() {
285
                ok = true;
286
                setVisible(false);
287
        }
288

    
289
        public Map getSumarizationFunctions() {
290
                return this.nField_sumFuntionList;
291
        }
292

    
293
        public void showFunctionsDialog() {
294
                if (sumarizeFuncDialog == null) {
295
                        sumarizeFuncDialog = new SumarizeFunctionsDialog();
296
                        sumarizeFuncDialog.pack();
297
                }
298
                //sumarizeFuncDialog.setSize(150, 175);
299
                sumarizeFuncDialog.resetCheckbox();
300
                sumarizeFuncDialog.setVisible(true);
301
                SummarizationFunction[] functions = sumarizeFuncDialog.getFunctions();
302
                if(functions.length == 0)
303
                        return;
304
                String fieldName = (String) this.numericFieldJList.getSelectedValue();
305
                this.nField_sumFuntionList.put(fieldName, functions);
306
                SumFuncListModel functionListModel = new SumFuncListModel(
307
                                this.nField_sumFuntionList, numericFields);
308
                this.functionJList.setModel(functionListModel);
309
                //this.functionJList.setSelectedIndex(0);
310
                
311
        }
312

    
313
        public void setNumericFields(String[] numericFields) {
314
                this.numericFields = numericFields;
315
                NumericFieldListModel numericListModel = new NumericFieldListModel(
316
                                numericFields);
317
                this.numericFieldJList.setModel(numericListModel);
318
                
319
        }
320

    
321
        public boolean isOk() {
322
                return ok;
323
        }
324

    
325
}  //  @jve:decl-index=0:visual-constraint="10,10"