svn-gvsig-desktop / trunk / extensions / extGraph_predes / src / com / iver / cit / gvsig / graph / gui / wizard / NetWizard.java @ 9173
History | View | Annotate | Download (7.76 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 9173 2006-12-04 17:13:39Z fjp $
|
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 com.iver.cit.gvsig.graph.gui.wizard; |
76 |
|
77 |
import java.sql.Types; |
78 |
import java.util.ArrayList; |
79 |
|
80 |
import javax.swing.ImageIcon; |
81 |
|
82 |
import com.iver.andami.PluginServices; |
83 |
import com.iver.andami.ui.mdiManager.IWindow; |
84 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
85 |
import com.iver.andami.ui.wizard.WizardAndami; |
86 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
87 |
|
88 |
public class NetWizard extends WizardAndami implements IWindow{ |
89 |
public final static String[] COST_UNITS = { |
90 |
PluginServices.getText(NetWizard.class, "seconds" ),
|
91 |
PluginServices.getText(NetWizard.class, "hours" ),
|
92 |
PluginServices.getText(NetWizard.class, "minutes" ),
|
93 |
"hh:mm:ss" ,
|
94 |
PluginServices.getText(NetWizard.class, "millimeters" ),
|
95 |
PluginServices.getText(NetWizard.class, "meters" ),
|
96 |
PluginServices.getText(NetWizard.class, "inches" ),
|
97 |
PluginServices.getText(NetWizard.class, "feet" ),
|
98 |
PluginServices.getText(NetWizard.class, "yards" ),
|
99 |
PluginServices.getText(NetWizard.class, "miles" ),
|
100 |
PluginServices.getText(NetWizard.class, "nautic_miles" ),
|
101 |
PluginServices.getText(NetWizard.class, "monetary" ), // unidades monetarias |
102 |
PluginServices.getText(NetWizard.class, "unknown_longitude_units" ),
|
103 |
PluginServices.getText(NetWizard.class, "unknown_time_units" ),
|
104 |
PluginServices.getText(NetWizard.class, "unknown_units" ),
|
105 |
}; // TODO push it to the corresponding geoprocess class
|
106 |
private FLyrVect lyr;
|
107 |
private WindowInfo wi;
|
108 |
private String[] numericLayerFieldNames; |
109 |
private String fieldLength; |
110 |
private Boolean usingCosts; |
111 |
private String costUnit; |
112 |
private String[] layerFieldNames; |
113 |
private String fieldType; |
114 |
private String fieldSense; |
115 |
private String fieldCost; |
116 |
|
117 |
/**
|
118 |
* flag that tells us if user pressed finish button
|
119 |
* or cancel button
|
120 |
* */
|
121 |
private boolean wasFinishPressed = false; |
122 |
|
123 |
|
124 |
private boolean cleanOriginalLayer = false; |
125 |
private boolean applySnapTolerance = false; |
126 |
private double snapTolerance = 0d; |
127 |
|
128 |
|
129 |
public NetWizard(ImageIcon logo, FLyrVect lyr) { |
130 |
super(logo);
|
131 |
this.lyr = lyr;
|
132 |
getWizardComponents().addWizardPanel(new NetPage0(this)); |
133 |
getWizardComponents().addWizardPanel(new NetPage1(this)); |
134 |
// getWizardComponents().addWizardPanel(new NetPage2(this));
|
135 |
// getWizardComponents().addWizardPanel(new NetPage3(this));
|
136 |
// getWizardComponents().addWizardPanel(new NetPage4(this));
|
137 |
getWizardComponents().setFinishAction(new NetFinishAction(this)); |
138 |
getWizardComponents().setCancelAction(new NetCancelAction(this)); |
139 |
} |
140 |
|
141 |
|
142 |
public FLyrVect getLayer(){
|
143 |
return lyr;
|
144 |
} |
145 |
|
146 |
public WindowInfo getWindowInfo() {
|
147 |
if (wi==null) { |
148 |
wi = new WindowInfo(WindowInfo.RESIZABLE | WindowInfo.MODALDIALOG);
|
149 |
wi.setWidth(720);
|
150 |
wi.setHeight(370);
|
151 |
wi.setTitle(PluginServices.getText(this, "create_network") + "..."); |
152 |
} |
153 |
return wi;
|
154 |
} |
155 |
|
156 |
public void setCleanOriginalLayer(boolean value){ |
157 |
this.cleanOriginalLayer = value;
|
158 |
} |
159 |
|
160 |
public boolean getCleanOriginalLayer(){ |
161 |
return cleanOriginalLayer;
|
162 |
} |
163 |
|
164 |
public void setApplySnapTolerance(boolean value){ |
165 |
this.applySnapTolerance = value;
|
166 |
} |
167 |
|
168 |
public boolean getApplySnapTolerance(){ |
169 |
return applySnapTolerance;
|
170 |
} |
171 |
|
172 |
public void setSnapTolerance(double value){ |
173 |
this.snapTolerance = value;
|
174 |
} |
175 |
|
176 |
public double getSnapTolerance(){ |
177 |
return snapTolerance;
|
178 |
} |
179 |
|
180 |
|
181 |
public void setWasFinishPressed(boolean wasFinish){ |
182 |
this.wasFinishPressed = wasFinish;
|
183 |
} |
184 |
|
185 |
public boolean wasFinishPressed(){ |
186 |
return wasFinishPressed;
|
187 |
} |
188 |
|
189 |
public String[] getNumericLayerFieldNames() { |
190 |
if (numericLayerFieldNames == null) { |
191 |
try {
|
192 |
String[] aux = lyr.getRecordset().getFieldNames(); |
193 |
ArrayList temp = new ArrayList(); |
194 |
for (int i = 0; i < aux.length; i++) { |
195 |
switch (lyr.getRecordset().getFieldType(i)) {
|
196 |
case Types.BIGINT: |
197 |
case Types.DECIMAL: |
198 |
case Types.DOUBLE: |
199 |
case Types.FLOAT: |
200 |
case Types.INTEGER: |
201 |
case Types.NUMERIC: |
202 |
case Types.REAL: |
203 |
case Types.SMALLINT: |
204 |
case Types.TINYINT: |
205 |
temp.add(aux[i]); |
206 |
} |
207 |
} |
208 |
numericLayerFieldNames = (String[]) temp.toArray(new String[0]); |
209 |
} catch (Exception e) { |
210 |
return new String[] {PluginServices.getText(this, "invalid_layer")+"!"}; |
211 |
} |
212 |
} |
213 |
return numericLayerFieldNames;
|
214 |
} |
215 |
|
216 |
public String[] getLayerFieldNames() { |
217 |
if (layerFieldNames == null) { |
218 |
try {
|
219 |
layerFieldNames = lyr.getRecordset().getFieldNames(); |
220 |
} catch (Exception e) { |
221 |
return new String[] {PluginServices.getText(this, "invalid_layer")+"!"}; |
222 |
} |
223 |
} |
224 |
return layerFieldNames;
|
225 |
} |
226 |
|
227 |
public void setLengthField(String lengthField) { |
228 |
this.fieldLength = lengthField;
|
229 |
} |
230 |
|
231 |
public void setTypeField(String fieldType) { |
232 |
this.fieldType = fieldType;
|
233 |
} |
234 |
|
235 |
public void setCostField(String fieldCost) { |
236 |
this.fieldCost = fieldCost;
|
237 |
} |
238 |
|
239 |
public void setSenseField(String fieldSense) { |
240 |
this.fieldSense = fieldSense;
|
241 |
} |
242 |
|
243 |
public void setCostsUnit(String costUnit) { |
244 |
this.costUnit = costUnit;
|
245 |
} |
246 |
|
247 |
public void setUsingCosts(Boolean costs) { |
248 |
this.usingCosts = costs;
|
249 |
} |
250 |
|
251 |
public Boolean isUsingCosts() { |
252 |
return usingCosts;
|
253 |
} |
254 |
|
255 |
public String getFieldType() { |
256 |
return this.fieldType; |
257 |
} |
258 |
|
259 |
public String getFieldLength() { |
260 |
return this.fieldLength; |
261 |
} |
262 |
|
263 |
public String getFieldSense() { |
264 |
return this.fieldSense; |
265 |
} |
266 |
|
267 |
public String getFieldCost() { |
268 |
return this.fieldCost; |
269 |
} |
270 |
|
271 |
|
272 |
} |