Revision 8188
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/TestExtension.java | ||
---|---|---|
43 | 43 |
import java.awt.BasicStroke; |
44 | 44 |
import java.awt.Color; |
45 | 45 |
import java.awt.Frame; |
46 |
import java.awt.geom.Point2D; |
|
47 | 46 |
import java.io.File; |
48 | 47 |
import java.util.Collection; |
49 | 48 |
import java.util.Iterator; |
... | ... | |
69 | 68 |
import com.iver.cit.gvsig.graph.core.FEdge; |
70 | 69 |
import com.iver.cit.gvsig.graph.core.FNode; |
71 | 70 |
import com.iver.cit.gvsig.graph.core.IGraph; |
72 |
import com.iver.cit.gvsig.graph.core.JungConverter; |
|
73 | 71 |
import com.iver.cit.gvsig.graph.core.JungGraph; |
74 | 72 |
import com.iver.cit.gvsig.graph.core.Network; |
75 | 73 |
import com.iver.cit.gvsig.graph.core.NetworkRedLoader; |
74 |
import com.iver.cit.gvsig.graph.gui.DlgDirections; |
|
76 | 75 |
import com.iver.cit.gvsig.graph.solvers.Route; |
77 | 76 |
import com.iver.cit.gvsig.graph.solvers.ShortestPathSolver; |
78 |
import com.iver.cit.gvsig.graph.ui.DlgDirections; |
|
79 | 77 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
80 | 78 |
|
81 | 79 |
import edu.uci.ics.jung.algorithms.shortestpath.DijkstraShortestPath; |
82 |
import edu.uci.ics.jung.graph.ArchetypeGraph; |
|
83 |
import edu.uci.ics.jung.graph.Vertex; |
|
84 |
import edu.uci.ics.jung.graph.decorators.Indexer; |
|
85 | 80 |
|
86 | 81 |
public class TestExtension extends Extension { |
87 | 82 |
|
88 | 83 |
public static ShortestPathSolver solver = new ShortestPathSolver(); |
89 | 84 |
private int idSymbolLine = -1; |
90 |
|
|
85 |
|
|
91 | 86 |
public void initialize() { |
92 | 87 |
} |
93 | 88 |
|
... | ... | |
103 | 98 |
Network net = new Network(); |
104 | 99 |
net.setLayer((FLyrVect) aux); |
105 | 100 |
NetworkRedLoader netLoader = new NetworkRedLoader(); |
106 |
|
|
101 |
|
|
107 | 102 |
netLoader.setNetFile(new File("c:/ejes.red")); |
108 |
|
|
103 |
|
|
109 | 104 |
IGraph g = netLoader.loadNetwork(); |
110 | 105 |
|
111 | 106 |
net.setGraph(g); |
112 | 107 |
|
113 | 108 |
// Primer punto |
114 | 109 |
net.addFlag(433647.09375, 4488029, 10); |
115 |
|
|
110 |
|
|
116 | 111 |
// Segundo punto |
117 | 112 |
net.addFlag(437290.96875, 4481547, 10); |
118 |
|
|
119 |
|
|
120 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
121 | 116 |
Route route; |
122 |
try {
|
|
117 |
try { |
|
123 | 118 |
solver.setNetwork(net); |
124 | 119 |
solver.setFielStreetName("Nombre"); |
125 | 120 |
route = solver.calculateRoute(); |
... | ... | |
127 | 122 |
dlg.setModel(route.getFeatureList()); |
128 | 123 |
|
129 | 124 |
createGraphicsFrom(route.getFeatureList(), v.getMapControl()); |
130 |
|
|
125 |
|
|
131 | 126 |
dlg.setVisible(true); |
132 | 127 |
System.out.println("distancia fjp:" + route.getCost()); |
133 |
|
|
128 |
|
|
134 | 129 |
// PROBAMOS JUNG |
135 | 130 |
JungGraph jG = new JungGraph(net.getGraph()); |
136 |
|
|
131 |
|
|
137 | 132 |
// Probamos la algoritmia: distancia entre nodo 1 y nodo 1000 |
138 | 133 |
DijkstraShortestPath distCalculator = new DijkstraShortestPath(jG, new EdgeWeightLabeller()); |
139 | 134 |
FNode vOrig = jG.getVertexByID(1); |
... | ... | |
141 | 136 |
long t1 = System.currentTimeMillis(); |
142 | 137 |
Number dist = distCalculator.getDistance(vOrig, vEnd); |
143 | 138 |
long t2 = System.currentTimeMillis(); |
144 |
|
|
139 |
|
|
145 | 140 |
// assertEquals(dist.doubleValue(), 8887, 0); |
146 |
|
|
141 |
|
|
147 | 142 |
System.out.println("dist =" + dist + " meters. msecs: " + (t2-t1)); |
148 | 143 |
|
149 | 144 |
List path = distCalculator.getPath(vOrig, vEnd); |
... | ... | |
153 | 148 |
System.out.println(vOrig.getX() + ", " + vOrig.getY() |
154 | 149 |
+ " - " + vEnd.getX() + ", " + vEnd.getY()); |
155 | 150 |
|
156 |
|
|
151 |
|
|
157 | 152 |
} catch (GraphException e) { |
158 | 153 |
// TODO Auto-generated catch block |
159 | 154 |
e.printStackTrace(); |
... | ... | |
162 | 157 |
e.printStackTrace(); |
163 | 158 |
} |
164 | 159 |
} |
165 |
|
|
166 |
|
|
167 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
168 | 163 |
} |
169 | 164 |
|
170 | 165 |
private void createGraphicsFrom(Collection featureList, MapControl mapControl) { |
... | ... | |
184 | 179 |
graphicLayer.addGraphic(graphic); |
185 | 180 |
} |
186 | 181 |
mapControl.drawGraphics(); |
187 |
|
|
182 |
|
|
188 | 183 |
} |
189 |
|
|
184 |
|
|
190 | 185 |
private void createGraphicsFrom(ListIterator it, MapControl mapControl) throws DriverException { |
191 | 186 |
GraphicLayer graphicLayer = mapControl.getMapContext().getGraphicsLayer(); |
192 | 187 |
Color color = new Color(0.5f, 0.8f, 0.0f, 0.5f); |
... | ... | |
202 | 197 |
graphicLayer.addGraphic(graphic); |
203 | 198 |
} |
204 | 199 |
mapControl.drawGraphics(); |
205 |
|
|
200 |
|
|
206 | 201 |
} |
207 |
|
|
208 | 202 |
|
203 |
|
|
209 | 204 |
public boolean isEnabled() { |
210 | 205 |
// TODO Auto-generated method stub |
211 | 206 |
return true; |
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/gui/wizard/NetPage4.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2006-10-19 15:12:10 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
package com.iver.cit.gvsig.graph.gui.wizard; |
|
52 |
|
|
53 |
import java.awt.event.ActionEvent; |
|
54 |
import java.awt.event.ActionListener; |
|
55 |
|
|
56 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
|
57 |
|
|
58 |
import com.iver.andami.PluginServices; |
|
59 |
import com.iver.utiles.swing.JComboBox; |
|
60 |
|
|
61 |
import jwizardcomponent.JWizardPanel; |
|
62 |
|
|
63 |
/** |
|
64 |
* Configuring sense |
|
65 |
* |
|
66 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
67 |
* |
|
68 |
*/ |
|
69 |
class NetPage4 extends JWizardPanel implements ActionListener { |
|
70 |
private NetWizard owner; |
|
71 |
private JComboBox cmbSenseField; |
|
72 |
private Object nullValue = "- "+PluginServices.getText(this, "none")+" -"; |
|
73 |
|
|
74 |
NetPage4(NetWizard wizard) { |
|
75 |
super(wizard.getWizardComponents()); |
|
76 |
this.owner = wizard; |
|
77 |
initialize(); |
|
78 |
} |
|
79 |
|
|
80 |
private void initialize() { |
|
81 |
GridBagLayoutPanel contentPane = new GridBagLayoutPanel(); |
|
82 |
|
|
83 |
cmbSenseField = new JComboBox(); |
|
84 |
cmbSenseField.addItem(nullValue); |
|
85 |
String[] fieldNames = owner.getLayerFieldNames(); |
|
86 |
for (int i = 0; i < fieldNames.length; i++) { |
|
87 |
cmbSenseField.addItem(fieldNames[i]); |
|
88 |
} |
|
89 |
cmbSenseField.addActionListener(this); |
|
90 |
contentPane.addComponent(PluginServices.getText(this, "select_sense_field"),cmbSenseField); |
|
91 |
add(contentPane); |
|
92 |
actionPerformed(null); |
|
93 |
} |
|
94 |
|
|
95 |
public void actionPerformed(ActionEvent e) { |
|
96 |
// refresh table |
|
97 |
owner.setFieldSense(cmbSenseField.getSelectedItem().equals(nullValue)? |
|
98 |
"" : (String) cmbSenseField.getSelectedItem()); |
|
99 |
} |
|
100 |
|
|
101 |
|
|
102 |
} |
|
0 | 103 |
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/gui/wizard/NetWizard.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2006-10-19 15:12:10 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
package com.iver.cit.gvsig.graph.gui.wizard; |
|
52 |
|
|
53 |
import java.sql.Types; |
|
54 |
import java.util.ArrayList; |
|
55 |
|
|
56 |
import javax.swing.ImageIcon; |
|
57 |
|
|
58 |
import org.gvsig.gui.beans.wizard.WizardAndami; |
|
59 |
|
|
60 |
import com.iver.andami.PluginServices; |
|
61 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
62 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
63 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
64 |
|
|
65 |
public class NetWizard extends WizardAndami implements IWindow{ |
|
66 |
public final static String[] COST_UNITS = { |
|
67 |
PluginServices.getText(NetWizard.class, "seconds" ), |
|
68 |
PluginServices.getText(NetWizard.class, "hours" ), |
|
69 |
PluginServices.getText(NetWizard.class, "minutes" ), |
|
70 |
"hh:mm:ss" , |
|
71 |
PluginServices.getText(NetWizard.class, "millimeters" ), |
|
72 |
PluginServices.getText(NetWizard.class, "meters" ), |
|
73 |
PluginServices.getText(NetWizard.class, "inches" ), |
|
74 |
PluginServices.getText(NetWizard.class, "feet" ), |
|
75 |
PluginServices.getText(NetWizard.class, "yards" ), |
|
76 |
PluginServices.getText(NetWizard.class, "miles" ), |
|
77 |
PluginServices.getText(NetWizard.class, "nautic_miles" ), |
|
78 |
PluginServices.getText(NetWizard.class, "monetary" ), // unidades monetarias |
|
79 |
PluginServices.getText(NetWizard.class, "unknown_longitude_units" ), |
|
80 |
PluginServices.getText(NetWizard.class, "unknown_time_units" ), |
|
81 |
PluginServices.getText(NetWizard.class, "unknown_units" ), |
|
82 |
}; // TODO push it to the corresponding geoprocess class |
|
83 |
private FLyrVect lyr; |
|
84 |
private WindowInfo wi; |
|
85 |
private String[] numericLayerFieldNames; |
|
86 |
private String fieldLength; |
|
87 |
private Boolean usingCosts; |
|
88 |
private String costUnit; |
|
89 |
private String[] layerFieldNames; |
|
90 |
private String fieldType; |
|
91 |
private String fieldSense; |
|
92 |
private String fieldCost; |
|
93 |
|
|
94 |
public NetWizard(ImageIcon logo, FLyrVect lyr) { |
|
95 |
super(logo); |
|
96 |
this.lyr = lyr; |
|
97 |
getWizardComponents().addWizardPanel(new NetPage1(this)); |
|
98 |
// getWizardComponents().addWizardPanel(new NetPage2(this)); |
|
99 |
// getWizardComponents().addWizardPanel(new NetPage3(this)); |
|
100 |
// getWizardComponents().addWizardPanel(new NetPage4(this)); |
|
101 |
getWizardComponents().setFinishAction(new NetFinishAction(this)); |
|
102 |
} |
|
103 |
|
|
104 |
public WindowInfo getWindowInfo() { |
|
105 |
if (wi==null) { |
|
106 |
wi = new WindowInfo(WindowInfo.RESIZABLE | WindowInfo.MODALDIALOG); |
|
107 |
wi.setWidth(650); |
|
108 |
wi.setHeight(370); |
|
109 |
wi.setTitle(PluginServices.getText(this, "create_network") + "..."); |
|
110 |
} |
|
111 |
return wi; |
|
112 |
} |
|
113 |
|
|
114 |
public String[] getNumericLayerFieldNames() { |
|
115 |
if (numericLayerFieldNames == null) { |
|
116 |
try { |
|
117 |
String[] aux = lyr.getRecordset().getFieldNames(); |
|
118 |
ArrayList temp = new ArrayList(); |
|
119 |
for (int i = 0; i < aux.length; i++) { |
|
120 |
switch (lyr.getRecordset().getFieldType(i)) { |
|
121 |
case Types.BIGINT: |
|
122 |
case Types.DECIMAL: |
|
123 |
case Types.DOUBLE: |
|
124 |
case Types.FLOAT: |
|
125 |
case Types.INTEGER: |
|
126 |
case Types.NUMERIC: |
|
127 |
case Types.REAL: |
|
128 |
case Types.SMALLINT: |
|
129 |
case Types.TINYINT: |
|
130 |
temp.add(aux[i]); |
|
131 |
} |
|
132 |
} |
|
133 |
numericLayerFieldNames = (String[]) temp.toArray(new String[0]); |
|
134 |
} catch (Exception e) { |
|
135 |
return new String[] {PluginServices.getText(this, "invalid_layer")+"!"}; |
|
136 |
} |
|
137 |
} |
|
138 |
return numericLayerFieldNames; |
|
139 |
} |
|
140 |
|
|
141 |
public String[] getLayerFieldNames() { |
|
142 |
if (layerFieldNames == null) { |
|
143 |
try { |
|
144 |
layerFieldNames = lyr.getRecordset().getFieldNames(); |
|
145 |
} catch (Exception e) { |
|
146 |
return new String[] {PluginServices.getText(this, "invalid_layer")+"!"}; |
|
147 |
} |
|
148 |
} |
|
149 |
return layerFieldNames; |
|
150 |
} |
|
151 |
|
|
152 |
public void setFieldLength(String lengthField) { |
|
153 |
this.fieldLength = lengthField; |
|
154 |
} |
|
155 |
|
|
156 |
public void setFieldType(String fieldType) { |
|
157 |
this.fieldType = fieldType; |
|
158 |
} |
|
159 |
|
|
160 |
public void setFieldCost(String fieldCost) { |
|
161 |
this.fieldCost = fieldCost; |
|
162 |
} |
|
163 |
|
|
164 |
public void setFieldSense(String fieldSense) { |
|
165 |
this.fieldSense = fieldSense; |
|
166 |
} |
|
167 |
|
|
168 |
public void setCostsUnit(String costUnit) { |
|
169 |
this.costUnit = costUnit; |
|
170 |
} |
|
171 |
|
|
172 |
public void setUsingCosts(Boolean costs) { |
|
173 |
this.usingCosts = costs; |
|
174 |
} |
|
175 |
|
|
176 |
|
|
177 |
public Boolean isUsingCosts() { |
|
178 |
return usingCosts; |
|
179 |
} |
|
180 |
|
|
181 |
public String getFieldType() { |
|
182 |
return this.fieldType; |
|
183 |
} |
|
184 |
|
|
185 |
public String getFieldLength() { |
|
186 |
return this.fieldLength; |
|
187 |
} |
|
188 |
|
|
189 |
public String getFieldSense() { |
|
190 |
return this.fieldSense; |
|
191 |
} |
|
192 |
|
|
193 |
public String getFieldCost() { |
|
194 |
return this.fieldCost; |
|
195 |
} |
|
196 |
|
|
197 |
|
|
198 |
} |
|
0 | 199 |
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/gui/wizard/NetPage1.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2006-10-19 15:12:10 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
package com.iver.cit.gvsig.graph.gui.wizard; |
|
52 |
|
|
53 |
import java.awt.FlowLayout; |
|
54 |
import java.awt.event.ActionEvent; |
|
55 |
import java.awt.event.ActionListener; |
|
56 |
import java.util.Hashtable; |
|
57 |
|
|
58 |
import javax.swing.JComboBox; |
|
59 |
import javax.swing.JLabel; |
|
60 |
import javax.swing.JPanel; |
|
61 |
|
|
62 |
import jwizardcomponent.JWizardPanel; |
|
63 |
|
|
64 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
|
65 |
|
|
66 |
import com.iver.andami.PluginServices; |
|
67 |
/** |
|
68 |
* Configures the length |
|
69 |
* |
|
70 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
71 |
*/ |
|
72 |
class NetPage1 extends JWizardPanel implements ActionListener { |
|
73 |
private NetWizard owner; |
|
74 |
private JComboBox cmbLengthField; |
|
75 |
// TODO comprobar si es necesario |
|
76 |
private Hashtable exceptions; |
|
77 |
private JComboBox cmbTypeField; |
|
78 |
private JComboBox cmbSenseField; |
|
79 |
private JComboBox cmbCostUnits; |
|
80 |
private JComboBox cmbCostField; |
|
81 |
|
|
82 |
private Object useLineLengthItem = "< "+PluginServices.getText(this, "use_line_length")+" >"; |
|
83 |
|
|
84 |
private Object nullValue = "- "+PluginServices.getText(this, "none")+" -"; |
|
85 |
|
|
86 |
NetPage1(NetWizard wizard) { |
|
87 |
super(wizard.getWizardComponents()); |
|
88 |
this.owner = wizard; |
|
89 |
initialize(); |
|
90 |
} |
|
91 |
|
|
92 |
private void initialize() { |
|
93 |
GridBagLayoutPanel contentPane = new GridBagLayoutPanel(); |
|
94 |
contentPane.setBorder(javax.swing.BorderFactory.createTitledBorder(null, |
|
95 |
PluginServices.getText(this, "length (esto ho llevare)"), |
|
96 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
|
97 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
98 |
|
|
99 |
// Way type |
|
100 |
cmbTypeField = new JComboBox(); |
|
101 |
cmbTypeField.addItem(nullValue); |
|
102 |
cmbTypeField.setToolTipText(PluginServices.getText(this, "type_field_text")); |
|
103 |
String[] ss = owner.getLayerFieldNames(); |
|
104 |
for (int i = 0; i < ss.length; i++) { |
|
105 |
cmbTypeField.addItem(ss[i]); |
|
106 |
} |
|
107 |
contentPane.addComponent(PluginServices.getText(this, "selet_type_field")+":", cmbTypeField); |
|
108 |
|
|
109 |
// Length |
|
110 |
cmbLengthField = new JComboBox(); |
|
111 |
cmbLengthField.addItem(nullValue); |
|
112 |
cmbLengthField.setToolTipText(PluginServices.getText(this, "length_field_text")); |
|
113 |
ss = owner.getNumericLayerFieldNames(); |
|
114 |
for (int i = 0; i < ss.length; i++) { |
|
115 |
cmbLengthField.addItem(ss[i]); |
|
116 |
} |
|
117 |
contentPane.addComponent(PluginServices.getText(this, "selet_length_field")+":", cmbLengthField); |
|
118 |
|
|
119 |
// Cost |
|
120 |
contentPane.addComponent( |
|
121 |
PluginServices.getText(this, "cost_field"), |
|
122 |
cmbCostField = new JComboBox()); |
|
123 |
|
|
124 |
cmbCostField.addItem(useLineLengthItem ); |
|
125 |
cmbCostField.setToolTipText(PluginServices.getText(this, "cost_field_text")); |
|
126 |
cmbCostField.addActionListener(this); |
|
127 |
String[] numericFields = owner.getNumericLayerFieldNames(); |
|
128 |
|
|
129 |
for (int i = 0; i < numericFields.length; i++) |
|
130 |
cmbCostField.addItem(numericFields[i]); |
|
131 |
|
|
132 |
// Costs units |
|
133 |
cmbCostUnits = new JComboBox(NetWizard.COST_UNITS); |
|
134 |
contentPane.addComponent( |
|
135 |
PluginServices.getText(this, "cost_units"), cmbCostUnits); |
|
136 |
cmbCostUnits.setToolTipText(PluginServices.getText(this, "cost_units_text")); |
|
137 |
|
|
138 |
// Sense |
|
139 |
cmbSenseField = new JComboBox(); |
|
140 |
cmbSenseField.addItem(nullValue); |
|
141 |
String[] fieldNames = owner.getLayerFieldNames(); |
|
142 |
for (int i = 0; i < fieldNames.length; i++) { |
|
143 |
cmbSenseField.addItem(fieldNames[i]); |
|
144 |
} |
|
145 |
cmbSenseField.addActionListener(this); |
|
146 |
cmbSenseField.setToolTipText(PluginServices.getText(this, "sense_field_text")); |
|
147 |
contentPane.addComponent(PluginServices.getText(this, "select_sense_field"),cmbSenseField); |
|
148 |
actionPerformed(null); |
|
149 |
this.add(contentPane); |
|
150 |
} |
|
151 |
|
|
152 |
public void actionPerformed(ActionEvent e) { |
|
153 |
|
|
154 |
cmbCostUnits.setEnabled( |
|
155 |
!cmbCostField.getSelectedItem().equals(useLineLengthItem)); |
|
156 |
|
|
157 |
owner.setFieldType(cmbTypeField.getSelectedItem().equals(nullValue)? |
|
158 |
null : (String) cmbTypeField.getSelectedItem()); |
|
159 |
owner.setFieldLength(cmbLengthField.getSelectedItem().equals(nullValue)? |
|
160 |
null : (String) cmbLengthField.getSelectedItem()); |
|
161 |
owner.setFieldSense(cmbSenseField.getSelectedItem().equals(nullValue)? |
|
162 |
null : (String) cmbSenseField.getSelectedItem()); |
|
163 |
owner.setFieldCost(cmbCostField.getSelectedItem().equals(useLineLengthItem)? |
|
164 |
null : (String) cmbCostField.getSelectedItem()); |
|
165 |
owner.setCostsUnit((String) cmbCostUnits.getSelectedItem()); |
|
166 |
} |
|
167 |
} |
|
0 | 168 |
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/gui/wizard/NetFinishAction.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2006-10-19 15:12:10 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
package com.iver.cit.gvsig.graph.gui.wizard; |
|
52 |
|
|
53 |
import com.iver.andami.PluginServices; |
|
54 |
|
|
55 |
import jwizardcomponent.FinishAction; |
|
56 |
|
|
57 |
class NetFinishAction extends FinishAction { |
|
58 |
private NetWizard owner; |
|
59 |
|
|
60 |
NetFinishAction(NetWizard wizard) { |
|
61 |
super(wizard.getWizardComponents()); |
|
62 |
this.owner = wizard; |
|
63 |
} |
|
64 |
public void performAction() { |
|
65 |
PluginServices.getMDIManager().closeWindow(owner); |
|
66 |
} |
|
67 |
|
|
68 |
} |
|
0 | 69 |
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/gui/wizard/NetPage2.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2006-10-19 15:12:10 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
package com.iver.cit.gvsig.graph.gui.wizard; |
|
52 |
|
|
53 |
import javax.swing.ButtonGroup; |
|
54 |
import javax.swing.JRadioButton; |
|
55 |
|
|
56 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
|
57 |
|
|
58 |
import com.iver.andami.PluginServices; |
|
59 |
import com.iver.utiles.swing.JComboBox; |
|
60 |
|
|
61 |
import jwizardcomponent.JWizardPanel; |
|
62 |
/** |
|
63 |
* Select costs or way type. |
|
64 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
65 |
* |
|
66 |
*/ |
|
67 |
public class NetPage2 extends JWizardPanel { |
|
68 |
|
|
69 |
private NetWizard owner; |
|
70 |
private JRadioButton rdBtnCosts; |
|
71 |
private JRadioButton rdBtnWayType; |
|
72 |
|
|
73 |
NetPage2(NetWizard wizard) { |
|
74 |
super(wizard.getWizardComponents()); |
|
75 |
this.owner = wizard; |
|
76 |
initialize(); |
|
77 |
} |
|
78 |
|
|
79 |
private void initialize() { |
|
80 |
GridBagLayoutPanel contentPane = new GridBagLayoutPanel(); |
|
81 |
contentPane.setBorder(javax.swing.BorderFactory.createTitledBorder(null, |
|
82 |
PluginServices.getText(this, "criterium (esto ho llevare)"), |
|
83 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
|
84 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
85 |
|
|
86 |
contentPane.addComponent( |
|
87 |
rdBtnCosts = new JRadioButton( |
|
88 |
PluginServices.getText(this, "cost_from_a_table_field"))); |
|
89 |
contentPane.addComponent( |
|
90 |
rdBtnWayType = new JRadioButton( |
|
91 |
PluginServices.getText(this, "based_upon_the_road_type"))); |
|
92 |
|
|
93 |
ButtonGroup group = new ButtonGroup(); |
|
94 |
group.add(rdBtnCosts); |
|
95 |
group.add(rdBtnWayType); |
|
96 |
this.add(contentPane); |
|
97 |
} |
|
98 |
|
|
99 |
public void next() { |
|
100 |
Boolean costs = null; |
|
101 |
if (rdBtnCosts.isSelected()) |
|
102 |
costs = new Boolean(true); |
|
103 |
if (rdBtnWayType.isSelected()) |
|
104 |
costs = new Boolean(false); |
|
105 |
|
|
106 |
if (costs!=null) { |
|
107 |
owner.setUsingCosts(costs); |
|
108 |
((NetPage3) owner.getWizardComponents().getWizardPanel(2)) |
|
109 |
.refresh(); |
|
110 |
goNext(); |
|
111 |
} |
|
112 |
|
|
113 |
} |
|
114 |
|
|
115 |
|
|
116 |
} |
|
0 | 117 |
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/gui/wizard/NetPage3.java | ||
---|---|---|
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$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2006-10-19 15:12:10 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
package com.iver.cit.gvsig.graph.gui.wizard; |
|
52 |
|
|
53 |
import java.awt.event.ActionEvent; |
|
54 |
import java.awt.event.ActionListener; |
|
55 |
|
|
56 |
import jwizardcomponent.JWizardPanel; |
|
57 |
|
|
58 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
|
59 |
|
|
60 |
import com.iver.andami.PluginServices; |
|
61 |
import com.iver.utiles.swing.JComboBox; |
|
62 |
/** |
|
63 |
* Configure costs or way types |
|
64 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
65 |
* |
|
66 |
*/ |
|
67 |
class NetPage3 extends JWizardPanel implements ActionListener { |
|
68 |
|
|
69 |
private NetWizard owner; |
|
70 |
private JComboBox cmbCostField; |
|
71 |
private JComboBox cmbCostUnits; |
|
72 |
private Boolean usingCosts; |
|
73 |
private Object useLineLengthItem = "< "+PluginServices.getText(this, "use_line_length")+" >"; |
|
74 |
|
|
75 |
NetPage3(NetWizard wizard) { |
|
76 |
super(wizard.getWizardComponents()); |
|
77 |
this.owner = wizard; |
|
78 |
} |
|
79 |
|
|
80 |
public void refresh() { |
|
81 |
removeAll(); |
|
82 |
GridBagLayoutPanel contentPane = new GridBagLayoutPanel(); |
|
83 |
usingCosts = owner.isUsingCosts(); |
|
84 |
if (usingCosts == null) { |
|
85 |
goBack(); |
|
86 |
} else if (usingCosts.booleanValue() == true) { |
|
87 |
contentPane.addComponent( |
|
88 |
PluginServices.getText(this, "cost_field"), |
|
89 |
cmbCostField = new JComboBox()); |
|
90 |
|
|
91 |
cmbCostField.addItem(useLineLengthItem ); |
|
92 |
cmbCostField.addActionListener(this); |
|
93 |
String[] numericFields = owner.getNumericLayerFieldNames(); |
|
94 |
|
|
95 |
for (int i = 0; i < numericFields.length; i++) |
|
96 |
cmbCostField.addItem(numericFields[i]); |
|
97 |
|
|
98 |
contentPane.addComponent( |
|
99 |
PluginServices.getText(this, "cost_units"), |
|
100 |
cmbCostUnits = new JComboBox(NetWizard.COST_UNITS)); |
|
101 |
} else { |
|
102 |
// TODO missing configure tipo de via |
|
103 |
} |
|
104 |
this.add(contentPane); |
|
105 |
actionPerformed(null); |
|
106 |
} |
|
107 |
|
|
108 |
public void next() { |
|
109 |
if (usingCosts==null) return; |
|
110 |
|
|
111 |
if (usingCosts.equals(Boolean.TRUE)) { |
|
112 |
owner.setFieldCost( |
|
113 |
cmbCostField.getSelectedIndex() == 0 ? |
|
114 |
"" : (String)cmbCostField.getSelectedItem()); |
|
115 |
owner.setCostsUnit( |
|
116 |
(String) NetWizard.COST_UNITS[cmbCostUnits.getSelectedIndex()]); |
|
117 |
} else { |
|
118 |
|
|
119 |
} |
|
120 |
goNext(); |
|
121 |
} |
|
122 |
|
|
123 |
public void actionPerformed(ActionEvent e) { |
|
124 |
cmbCostUnits.setEnabled( |
|
125 |
!cmbCostField.getSelectedItem().equals(useLineLengthItem)); |
|
126 |
} |
|
127 |
|
|
128 |
} |
|
0 | 129 |
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/gui/DlgDirections.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 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 |
package com.iver.cit.gvsig.graph.gui; |
|
42 |
|
|
43 |
import java.awt.Frame; |
|
44 |
import java.text.NumberFormat; |
|
45 |
import java.util.ArrayList; |
|
46 |
|
|
47 |
import javax.swing.JDialog; |
|
48 |
import javax.swing.JScrollPane; |
|
49 |
import javax.swing.JTextPane; |
|
50 |
import com.hardcode.gdbms.engine.values.DoubleValue; |
|
51 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
52 |
|
|
53 |
public class DlgDirections extends JDialog { |
|
54 |
|
|
55 |
private JScrollPane jScrollPane = null; |
|
56 |
|
|
57 |
private JTextPane jTextPane = null; |
|
58 |
|
|
59 |
/** |
|
60 |
* This method initializes |
|
61 |
* |
|
62 |
* @param b |
|
63 |
* @param frame |
|
64 |
* |
|
65 |
*/ |
|
66 |
public DlgDirections(Frame frame, boolean b) { |
|
67 |
super(frame, b); |
|
68 |
initialize(); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* Es responsabilidad del interfaz de usuario presentar el modelo a su |
|
73 |
* manera. |
|
74 |
* |
|
75 |
* @param features |
|
76 |
*/ |
|
77 |
public void setModel(ArrayList featureList) { |
|
78 |
String cad = "Pasa por:"; |
|
79 |
int cont = 0; |
|
80 |
double longitud = 0, sumaLong = 0, longAnt = 0; |
|
81 |
String cadAnt = ""; |
|
82 |
NumberFormat nf = NumberFormat.getInstance(); |
|
83 |
nf.setMaximumFractionDigits(2); |
|
84 |
for (int i = featureList.size() - 1; i >= 0; i--) { |
|
85 |
// INSTRUCCIONES |
|
86 |
IFeature feat = (IFeature) featureList.get(i); |
|
87 |
DoubleValue length = (DoubleValue) feat.getAttribute(2); |
|
88 |
double dist = length.doubleValue(); |
|
89 |
longitud = longitud + dist; |
|
90 |
sumaLong = sumaLong + dist; |
|
91 |
|
|
92 |
String cadProv = feat.getAttribute(3).toString(); |
|
93 |
if ((cadAnt.compareTo(cadProv) != 0) && (cont > 0)) { |
|
94 |
longitud = dist; |
|
95 |
cad = cad + "\n" + cadAnt + " " + nf.format(longAnt) |
|
96 |
+ " metros"; |
|
97 |
|
|
98 |
} |
|
99 |
longAnt = longitud; |
|
100 |
cadAnt = cadProv; |
|
101 |
|
|
102 |
cont = cont + 1; |
|
103 |
} |
|
104 |
cad = cad + "\n" + cadAnt + " " + nf.format(longAnt) + " metros"; |
|
105 |
cad = cad + "\n" + "=================" + "\n" |
|
106 |
+ "Distancia total recorrida: " + nf.format(sumaLong) |
|
107 |
+ " metros"; |
|
108 |
getJTextPane().setText(cad); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* This method initializes this |
|
113 |
* |
|
114 |
*/ |
|
115 |
private void initialize() { |
|
116 |
this.setSize(new java.awt.Dimension(363, 254)); |
|
117 |
this.setContentPane(getJScrollPane()); |
|
118 |
|
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* This method initializes jScrollPane |
|
123 |
* |
|
124 |
* @return javax.swing.JScrollPane |
|
125 |
*/ |
|
126 |
private JScrollPane getJScrollPane() { |
|
127 |
if (jScrollPane == null) { |
|
128 |
jScrollPane = new JScrollPane(); |
|
129 |
jScrollPane.setViewportView(getJTextPane()); |
|
130 |
} |
|
131 |
return jScrollPane; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* This method initializes jTextPane |
|
136 |
* |
|
137 |
* @return javax.swing.JTextPane |
|
138 |
*/ |
|
139 |
private JTextPane getJTextPane() { |
|
140 |
if (jTextPane == null) { |
|
141 |
jTextPane = new JTextPane(); |
|
142 |
} |
|
143 |
return jTextPane; |
|
144 |
} |
|
145 |
|
|
146 |
} // @jve:decl-index=0:visual-constraint="10,10" |
|
147 |
|
|
0 | 148 |
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/ShortestPathExtension.java | ||
---|---|---|
46 | 46 |
import java.util.Collection; |
47 | 47 |
import java.util.Iterator; |
48 | 48 |
|
49 |
import javax.swing.JOptionPane; |
|
50 |
|
|
51 | 49 |
import com.iver.andami.PluginServices; |
52 | 50 |
import com.iver.andami.plugins.Extension; |
53 | 51 |
import com.iver.cit.gvsig.fmap.MapContext; |
... | ... | |
61 | 59 |
import com.iver.cit.gvsig.fmap.layers.SingleLayerIterator; |
62 | 60 |
import com.iver.cit.gvsig.fmap.rendering.FGraphic; |
63 | 61 |
import com.iver.cit.gvsig.graph.core.Network; |
62 |
import com.iver.cit.gvsig.graph.gui.DlgDirections; |
|
64 | 63 |
import com.iver.cit.gvsig.graph.solvers.Route; |
65 | 64 |
import com.iver.cit.gvsig.graph.solvers.ShortestPathSolver; |
66 |
import com.iver.cit.gvsig.graph.ui.DlgDirections; |
|
67 | 65 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
68 | 66 |
|
69 | 67 |
public class ShortestPathExtension extends Extension { |
70 | 68 |
|
71 | 69 |
public static ShortestPathSolver solver = new ShortestPathSolver(); |
72 | 70 |
private int idSymbolLine = -1; |
73 |
|
|
71 |
|
|
74 | 72 |
public void initialize() { |
75 | 73 |
} |
76 | 74 |
|
... | ... | |
84 | 82 |
if (!aux.isActive()) |
85 | 83 |
continue; |
86 | 84 |
Network net = (Network) aux.getProperty("network"); |
87 |
|
|
85 |
|
|
88 | 86 |
if ( net != null) |
89 | 87 |
{ |
90 | 88 |
Route route; |
91 |
try {
|
|
89 |
try { |
|
92 | 90 |
solver.setNetwork(net); |
93 | 91 |
// solver.setFielStreetName("STREET_NAM"); |
94 | 92 |
route = solver.calculateRoute(); |
95 |
|
|
93 |
|
|
96 | 94 |
DlgDirections dlg = new DlgDirections((Frame) PluginServices.getMainFrame(), false); |
97 | 95 |
dlg.setModel(route.getFeatureList()); |
98 | 96 |
// JOptionPane.showMessageDialog(null, route.getInstructions()); |
99 | 97 |
createGraphicsFrom(route.getFeatureList(), v.getMapControl()); |
100 | 98 |
dlg.setVisible(true); |
101 |
|
|
99 |
|
|
102 | 100 |
} catch (GraphException e) { |
103 | 101 |
// TODO Auto-generated catch block |
104 | 102 |
e.printStackTrace(); |
105 | 103 |
} |
106 | 104 |
} |
107 | 105 |
} |
108 |
|
|
109 |
|
|
110 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
111 | 109 |
} |
112 | 110 |
|
113 | 111 |
private void createGraphicsFrom(Collection featureList, MapControl mapControl) { |
... | ... | |
126 | 124 |
graphicLayer.addGraphic(graphic); |
127 | 125 |
} |
128 | 126 |
mapControl.drawGraphics(); |
129 |
|
|
127 |
|
|
130 | 128 |
} |
131 | 129 |
|
132 | 130 |
public boolean isEnabled() { |
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/graph/NetworkExtension.java | ||
---|---|---|
43 | 43 |
import java.awt.Component; |
44 | 44 |
import java.io.File; |
45 | 45 |
|
46 |
import javax.swing.ImageIcon; |
|
46 | 47 |
import javax.swing.JOptionPane; |
47 | 48 |
|
48 | 49 |
import com.iver.andami.PluginServices; |
... | ... | |
64 | 65 |
import com.iver.cit.gvsig.graph.core.NetworkLoader; |
65 | 66 |
import com.iver.cit.gvsig.graph.core.NetworkRedLoader; |
66 | 67 |
import com.iver.cit.gvsig.graph.core.NetworkWriter; |
67 |
import com.iver.cit.gvsig.project.Project;
|
|
68 |
import com.iver.cit.gvsig.graph.gui.wizard.NetWizard;
|
|
68 | 69 |
import com.iver.cit.gvsig.project.documents.table.ProjectTable; |
69 | 70 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
70 | 71 |
import com.iver.cit.gvsig.project.documents.view.gui.IView; |
71 | 72 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
72 | 73 |
|
73 |
import edu.uci.ics.jung.graph.Graph; |
|
74 |
|
|
75 | 74 |
public class NetworkExtension extends Extension { |
76 | 75 |
|
77 | 76 |
// private String fieldType; |
... | ... | |
88 | 87 |
SingleLayerIterator lyrIterator = new SingleLayerIterator(map |
89 | 88 |
.getLayers()); |
90 | 89 |
while (lyrIterator.hasNext()) { |
91 |
FLayer lyr = lyrIterator.next();
|
|
90 |
FLayer lyr = lyrIterator.next(); |
|
92 | 91 |
if ((lyr.isActive()) && (lyr instanceof FLyrVect)) |
93 | 92 |
{ |
94 | 93 |
FLyrVect lyrVect = (FLyrVect) lyr; |
... | ... | |
109 | 108 |
} |
110 | 109 |
if (actionCommand.equalsIgnoreCase("LOAD_RED")) { |
111 | 110 |
loadNetwork(lyrVect); |
112 |
}
|
|
111 |
} |
|
113 | 112 |
} |
114 | 113 |
} catch (DriverException e) { |
115 | 114 |
// TODO Auto-generated catch block |
116 | 115 |
e.printStackTrace(); |
117 | 116 |
} |
118 |
|
|
117 |
|
|
119 | 118 |
} |
120 | 119 |
} |
121 | 120 |
|
... | ... | |
125 | 124 |
/** |
126 | 125 |
* Suponemos que en el proyecto hay 2 tablas, una con los nodos |
127 | 126 |
* y otro con los edges. |
128 |
* Cargamos la red a partir de esas tablas y se la
|
|
127 |
* Cargamos la red a partir de esas tablas y se la |
|
129 | 128 |
* asociamos a la capa. A partir de ah?, nuestras |
130 | 129 |
* herramientas pueden ver si la capa activa tiene |
131 | 130 |
* asociada o no una red y ponerse visibles / invisibles |
... | ... | |
136 | 135 |
* que todas las herramientas iteren por la colecci?n de |
137 | 136 |
* capas para habilitarse/deshabilitarse: |
138 | 137 |
* 100 herramientas * 100 capas = 10.000 comprobaciones |
139 |
* Si comprobar algo cuesta 1 mseg => 10 segundos!!!
|
|
138 |
* Si comprobar algo cuesta 1 mseg => 10 segundos!!! |
|
140 | 139 |
* @param lyrVect |
141 | 140 |
*/ |
142 | 141 |
private void loadNetworkFromTables(FLyrVect lyrVect) { |
143 | 142 |
// Aqu? mostrar un di?lgo para seleccionar las tablas |
144 | 143 |
// de nodos y edges |
145 |
// y hacer un mapping (si es necesario) entre los
|
|
144 |
// y hacer un mapping (si es necesario) entre los |
|
146 | 145 |
// nombres de campos |
147 | 146 |
String tableNodes = "Nodes"; |
148 | 147 |
String tableEdges = "Edges"; |
149 |
|
|
148 |
|
|
150 | 149 |
ProjectExtension projectExt = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
151 |
|
|
150 |
|
|
152 | 151 |
ProjectTable ptNodes = projectExt.getProject().getTable(tableNodes); |
153 | 152 |
ProjectTable ptEdges = projectExt.getProject().getTable(tableEdges); |
154 |
|
|
153 |
|
|
155 | 154 |
SelectableDataSource sdsNodes = ptNodes.getModelo().getRecordset(); |
156 |
SelectableDataSource sdsEdges = ptEdges.getModelo().getRecordset(); |
|
157 |
|
|
155 |
|
|
156 |
|
|
157 |
SelectableDataSource sdsEdges = ptEdges.getModelo().getRecordset(); |
|
158 |
|
|
158 | 159 |
NetworkLoader netLoader = new NetworkLoader(true); |
159 |
|
|
160 |
|
|
160 | 161 |
netLoader.setNodeReader(sdsNodes); |
161 | 162 |
netLoader.setEdgeReader(sdsEdges); |
162 |
|
|
163 |
|
|
163 | 164 |
IGraph g = netLoader.loadNetwork(); |
164 |
|
|
165 |
|
|
165 | 166 |
System.out.println("Num nodos=" + g.numVertices() + " numEdges = " + g.numEdges()); |
166 |
|
|
167 |
|
|
167 | 168 |
lyrVect.setProperty("network", g); |
168 |
|
|
169 |
|
|
169 | 170 |
} |
170 | 171 |
private void loadNetwork(FLyrVect lyrVect) { |
171 | 172 |
// Aqu? mostrar un di?lgo para seleccionar las tablas |
172 | 173 |
// de nodos y edges |
173 |
// y hacer un mapping (si es necesario) entre los
|
|
174 |
// y hacer un mapping (si es necesario) entre los |
|
174 | 175 |
// nombres de campos |
175 |
|
|
176 |
|
|
176 | 177 |
NetworkRedLoader netLoader = new NetworkRedLoader(); |
177 | 178 |
File redFile = new File("c:/" + lyrVect.getName().replaceAll("\\Q.shp\\E", ".red")); |
178 | 179 |
netLoader.setNetFile(redFile); |
179 |
|
|
180 |
|
|
180 | 181 |
IGraph g = netLoader.loadNetwork(); |
181 |
|
|
182 |
|
|
182 | 183 |
System.out.println("Num nodos=" + g.numVertices() + " numEdges = " + g.numEdges()); |
183 |
|
|
184 |
|
|
184 | 185 |
// TODO: MOSTRAR UN CUADRO DE DI?LOGO CON UN COMBOBOX PARA QUE ESCOJA EL CAMPO DE NOMBRE DE CALLE. |
185 | 186 |
String fieldStreetName = JOptionPane.showInputDialog((Component) PluginServices.getMainFrame(), |
186 | 187 |
"Street-Route field name?", "STREET_NAM"); |
187 |
|
|
188 |
|
|
188 | 189 |
Network net = new Network(); |
189 | 190 |
// lyrVect.createSpatialIndex(); |
190 | 191 |
net.setGraph(g); |
... | ... | |
193 | 194 |
ShortestPathExtension.solver.setFielStreetName(fieldStreetName); |
194 | 195 |
|
195 | 196 |
lyrVect.setProperty("network", net); |
196 |
|
|
197 |
|
|
197 | 198 |
} |
198 | 199 |
|
199 |
|
|
200 |
|
|
200 | 201 |
private void generateNetwork(FLyrVect lyr) { |
201 | 202 |
NetworkWriter netBuilder = new NetworkWriter(); |
202 | 203 |
// Por ahora, a pelo, pero hay que sacar un cuadro |
... | ... | |
207 | 208 |
String fieldType = "tipored"; String fieldDist = "length"; String fieldSense = "sen"; |
208 | 209 |
String fieldCost = "cost"; |
209 | 210 |
try { |
210 |
netBuilder.setLayer(lyr); // , fieldType, fieldDist, fieldSense); |
|
211 |
netBuilder.setLayer(lyr); |
|
212 |
netBuilder.setFieldType(fieldType); |
|
213 |
netBuilder.setFieldDist(fieldDist); |
|
214 |
netBuilder.setFieldSense(fieldSense); |
|
211 | 215 |
DbfWriter nodeWriter = new DbfWriter(); |
212 | 216 |
nodeWriter.setFile(new File("c:/nodes.dbf")); |
213 |
|
|
217 |
|
|
214 | 218 |
DbfWriter edgeWriter = new DbfWriter(); |
215 | 219 |
edgeWriter.setFile(new File("c:/edges.dbf")); |
216 |
|
|
220 |
|
|
217 | 221 |
netBuilder.setEdgeWriter(edgeWriter); |
218 | 222 |
netBuilder.setNodeWriter(nodeWriter); |
219 |
|
|
223 |
|
|
220 | 224 |
netBuilder.writeNetwork(true); |
221 | 225 |
} catch (DriverException e1) { |
222 | 226 |
// TODO Auto-generated catch block |
... | ... | |
225 | 229 |
// TODO Auto-generated catch block |
226 | 230 |
e1.printStackTrace(); |
227 | 231 |
} |
228 |
JOptionPane.showMessageDialog(null, "Hecho. ");
|
|
229 |
|
|
230 |
|
|
232 |
JOptionPane.showMessageDialog(null, PluginServices.getText(this, "done"));
|
|
233 |
|
|
234 |
|
|
231 | 235 |
} |
232 | 236 |
|
233 | 237 |
private void generateRedNetwork(FLyrVect lyr) { |
... | ... | |
237 | 241 |
// Tambi?n un cuadro de di?logo para seleccionar |
238 | 242 |
// en qu? tablas quiere escribir, y su formato |
239 | 243 |
// (dbf, postgres, etc) |
240 |
|
|
241 |
String fieldType = JOptionPane.showInputDialog(null, "fieldType:", "LPOLY_"); |
|
242 |
if (fieldType == null) |
|
243 |
return; |
|
244 |
String fieldDist = JOptionPane.showInputDialog(null, "fieldLength:", "length"); |
|
245 |
if (fieldDist == null) |
|
246 |
return; |
|
247 |
|
|
248 |
String fieldSense = JOptionPane.showInputDialog(null, "fieldSense:", ""); |
|
249 |
if (fieldSense == null) |
|
250 |
return; |
|
251 | 244 |
|
252 |
|
|
245 |
ImageIcon icon = new ImageIcon(this. |
|
246 |
getClass(). |
|
247 |
getClassLoader(). |
|
248 |
getResource("images/net-wizard-logo.jpg")); |
|
249 |
|
|
250 |
NetWizard wiz = new NetWizard(icon, lyr); |
|
251 |
PluginServices.getMDIManager().addWindow(wiz); |
|
252 |
|
|
253 | 253 |
try { |
254 |
netBuilder.setLayer(lyr); //, fieldType, fieldDist, fieldSense); |
|
254 |
String fieldType = wiz.getFieldType(); |
|
255 |
String fieldLength = wiz.getFieldLength(); |
|
256 |
String fieldCost = wiz.getFieldCost(); |
|
257 |
String fieldSense = wiz.getFieldSense(); |
|
258 |
netBuilder.setLayer(lyr); |
|
255 | 259 |
netBuilder.setFieldType(fieldType); |
256 |
netBuilder.setFieldDist(fieldDist);
|
|
260 |
netBuilder.setFieldDist(fieldLength);
|
|
257 | 261 |
netBuilder.setFieldSense(fieldSense); |
258 |
|
|
259 |
|
|
262 |
netBuilder.setFieldCost(fieldCost); |
|
260 | 263 |
File redFile = new File("c:/" + lyr.getName().replaceAll("\\Q.shp\\E", ".red")); |
261 | 264 |
netBuilder.createRedFile(lyr, redFile); |
262 | 265 |
} catch (DriverException e1) { |
263 | 266 |
// TODO Auto-generated catch block |
264 | 267 |
e1.printStackTrace(); |
268 |
|
|
265 | 269 |
} |
266 |
JOptionPane.showMessageDialog(null, "Hecho. "); |
|
267 |
|
|
268 |
|
|
270 |
JOptionPane.showMessageDialog(null, PluginServices.getText(this, "done")); |
|
271 |
|
|
269 | 272 |
} |
270 | 273 |
|
271 |
|
|
274 |
|
|
272 | 275 |
public boolean isEnabled() { |
273 | 276 |
return true; |
274 | 277 |
} |
Also available in: Unified diff