Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extGraph / src / org / gvsig / graph / gui / wizard / NetWizard.java @ 39203

History | View | Annotate | Download (8.55 KB)

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

    
42
/* CVS MESSAGES:
43
*
44
* $Id: NetWizard.java 39203 2012-11-08 12:02:06Z fpenarrubia $
45
* $Log$
46
* Revision 1.9  2006-12-04 17:13:39  fjp
47
* *** empty log message ***
48
*
49
* Revision 1.8  2006/11/09 13:30:40  azabala
50
* *** empty log message ***
51
*
52
* Revision 1.7  2006/11/09 12:51:12  jaume
53
* *** empty log message ***
54
*
55
* Revision 1.6  2006/11/09 09:01:05  azabala
56
* *** empty log message ***
57
*
58
* Revision 1.5  2006/11/08 20:14:42  azabala
59
* *** empty log message ***
60
*
61
* Revision 1.4  2006/10/25 19:13:55  azabala
62
* *** empty log message ***
63
*
64
* Revision 1.3  2006/10/24 08:04:41  jaume
65
* *** empty log message ***
66
*
67
* Revision 1.2  2006/10/20 12:02:50  jaume
68
* GUI
69
*
70
* Revision 1.1  2006/10/19 15:12:10  jaume
71
* *** empty log message ***
72
*
73
*
74
*/
75
package org.gvsig.graph.gui.wizard;
76

    
77
import java.io.File;
78
import java.sql.Types;
79
import java.util.ArrayList;
80

    
81
import javax.swing.ImageIcon;
82

    
83
import com.iver.andami.PluginServices;
84
import com.iver.andami.ui.mdiManager.IWindow;
85
import com.iver.andami.ui.mdiManager.WindowInfo;
86
import com.iver.andami.ui.wizard.WizardAndami;
87
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
88

    
89
public class NetWizard extends WizardAndami implements IWindow{
90
//    public final static String[] COST_UNITS = {
91
//            PluginServices.getText(NetWizard.class, "seconds" ),
92
//            PluginServices.getText(NetWizard.class, "hours" ),
93
//        PluginServices.getText(NetWizard.class, "minutes" ),
94
//                                                "hh:mm:ss" ,
95
//        PluginServices.getText(NetWizard.class, "millimeters" ),
96
//        PluginServices.getText(NetWizard.class, "meters" ),
97
//        PluginServices.getText(NetWizard.class, "inches" ),
98
//        PluginServices.getText(NetWizard.class, "feet" ),
99
//        PluginServices.getText(NetWizard.class, "yards" ),
100
//        PluginServices.getText(NetWizard.class, "miles" ),
101
//        PluginServices.getText(NetWizard.class, "nautic_miles" ),
102
//        PluginServices.getText(NetWizard.class, "monetary" ), // unidades monetarias
103
//        PluginServices.getText(NetWizard.class, "unknown_longitude_units" ),
104
//        PluginServices.getText(NetWizard.class, "unknown_time_units" ),
105
//        PluginServices.getText(NetWizard.class, "unknown_units" ),
106
//    }; // TODO push it to the corresponding geoprocess class
107
    private FLyrVect lyr;
108
    private WindowInfo wi;
109
    private String[] numericLayerFieldNames;
110
    private String fieldLength;
111
    private Boolean usingCosts;
112
    private double unitFactor;
113
        private String[] layerFieldNames;
114
        private String fieldType;
115
        private String fieldSense;
116
        private String fieldCost;
117
        
118
        /**
119
         * flag that tells us if user pressed finish button
120
         * or cancel button
121
         * */
122
        private boolean wasFinishPressed = false;
123
        
124
        
125
        private boolean cleanOriginalLayer = false;
126
        private boolean applySnapTolerance = false;
127
        private double snapTolerance = 0d;
128
        private NetPage1 netPage1;
129

    
130
    public NetWizard(ImageIcon logo, FLyrVect lyr) {
131
        super(logo);
132
        this.lyr = lyr;
133
        netPage1 = new NetPage1(this);
134
        getWizardComponents().addWizardPanel(new NetPage0(this));
135
        getWizardComponents().addWizardPanel(netPage1);
136
//        getWizardComponents().addWizardPanel(new NetPage2(this));
137
//        getWizardComponents().addWizardPanel(new NetPage3(this));
138
//        getWizardComponents().addWizardPanel(new NetPage4(this));
139
        getWizardComponents().setFinishAction(new NetFinishAction(this));
140
        getWizardComponents().setCancelAction(new NetCancelAction(this));
141
    }
142
    
143
    
144
    public FLyrVect getLayer(){
145
            return lyr;
146
    }
147

    
148
    public WindowInfo getWindowInfo() {
149
        if (wi==null) {
150
            wi = new WindowInfo(WindowInfo.RESIZABLE | WindowInfo.MODALDIALOG);
151
            wi.setWidth(800);
152
            wi.setHeight(370);
153
            wi.setTitle(PluginServices.getText(this, "create_network") + "...");
154
        }
155
        return wi;
156
    }
157
    
158
    public void setCleanOriginalLayer(boolean value){
159
            this.cleanOriginalLayer = value;
160
    }
161
    
162
    public boolean getCleanOriginalLayer(){
163
            return cleanOriginalLayer;
164
    }
165
    
166
    public void setApplySnapTolerance(boolean value){
167
            this.applySnapTolerance = value;
168
    }
169
    
170
    public boolean getApplySnapTolerance(){
171
            return applySnapTolerance;
172
    }
173
    
174
    public void setSnapTolerance(double value){
175
            this.snapTolerance = value;
176
    }
177
    
178
    public double getSnapTolerance(){
179
            return snapTolerance;
180
    }
181
    
182
    
183
    public void setWasFinishPressed(boolean wasFinish){
184
            this.wasFinishPressed = wasFinish;
185
    }
186
    
187
    public boolean wasFinishPressed(){
188
            return wasFinishPressed;
189
    }
190

    
191
    public String[] getNumericLayerFieldNames() {
192
        if (numericLayerFieldNames == null) {
193
            try {
194
                String[] aux = lyr.getRecordset().getFieldNames();
195
                ArrayList temp = new ArrayList();
196
                for (int i = 0; i < aux.length; i++) {
197
                    switch (lyr.getRecordset().getFieldType(i)) {
198
                    case Types.BIGINT:
199
                    case Types.DECIMAL:
200
                    case Types.DOUBLE:
201
                    case Types.FLOAT:
202
                    case Types.INTEGER:
203
                    case Types.NUMERIC:
204
                    case Types.REAL:
205
                    case Types.SMALLINT:
206
                    case Types.TINYINT:
207
                        temp.add(aux[i]);
208
                    }
209
                }
210
                numericLayerFieldNames = (String[]) temp.toArray(new String[0]);
211
            } catch (Exception e) {
212
                return new String[] {PluginServices.getText(this, "invalid_layer")+"!"};
213
            }
214
        }
215
        return numericLayerFieldNames;
216
    }
217

    
218
    public String[] getLayerFieldNames() {
219
            if (layerFieldNames == null) {
220
            try {
221
                    layerFieldNames = lyr.getRecordset().getFieldNames();
222
            } catch (Exception e) {
223
                    return new String[] {PluginServices.getText(this, "invalid_layer")+"!"};
224
            }
225
            }
226
            return layerFieldNames;
227
    }
228

    
229
    public void setLengthField(String lengthField) {
230
        this.fieldLength = lengthField;
231
    }
232

    
233
        public void setTypeField(String fieldType) {
234
                this.fieldType = fieldType;
235
        }
236

    
237
        public void setCostField(String fieldCost) {
238
        this.fieldCost = fieldCost;
239
    }
240

    
241
        public void setSenseField(String fieldSense) {
242
                this.fieldSense = fieldSense;
243
        }
244

    
245
    public void setUnitFactor(double d) {
246
        this.unitFactor = d;
247
    }
248
    public double getUnitFactor() {
249
//            NumberFormat nf = NumberFormat.getNumberInstance(Locale.ENGLISH); // use always . as decimal separator
250
//            Number aux;
251
//                try {
252
//                        aux = nf.parse(unitFactor);
253
//                        return aux.doubleValue();
254
//                } catch (ParseException e) {
255
//                        JOptionPane.showMessageDialog(this, PluginServices.getText(this, "Bad number format in unitFactor"));
256
//                        e.printStackTrace();
257
//                }
258
                return unitFactor;
259
    }
260

    
261
    
262
    public void setUsingCosts(Boolean costs) {
263
        this.usingCosts = costs;
264
    }
265

    
266
    public Boolean isUsingCosts() {
267
        return usingCosts;
268
    }
269

    
270
        public String getFieldType() {
271
                return this.fieldType;
272
        }
273

    
274
        public String getFieldLength() {
275
                return this.fieldLength;
276
        }
277

    
278
        public String getFieldSense() {
279
                return this.fieldSense;
280
        }
281

    
282
        public String getFieldCost() {
283
                return this.fieldCost;
284
        }
285

    
286

    
287
        public String getSenseDigitalization() {
288
                return netPage1.getSenseDigitalization();
289
        }
290

    
291

    
292
        public String getSenseReverseDigitalization() {
293
                return netPage1.getSenseReverseDigitalization();
294
        }
295

    
296

    
297
        public File getNetworkFile() {
298
                return new File(netPage1.getTxtFile());
299
        }
300

    
301

    
302
}