svn-gvsig-desktop / trunk / extensions / extGraph / src / org / gvsig / graph / gui / RouteReportPanel.java @ 39203
History | View | Annotate | Download (18.9 KB)
1 |
/*
|
---|---|
2 |
* Created on 19-oct-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: RouteReportPanel.java 39203 2012-11-08 12:02:06Z fpenarrubia $
|
47 |
* $Log$
|
48 |
* Revision 1.15 2007-09-07 11:29:47 fjp
|
49 |
* Casi compila. Falta arreglar lo de FArrowSymbol y retocar el graphiclist de FMap.
|
50 |
*
|
51 |
* Revision 1.14 2006/11/20 08:44:55 fjp
|
52 |
* borrar tramos amarillos, seleccionar solo campos num?ricos y situar las barreras encima del tramo invalidado
|
53 |
*
|
54 |
* Revision 1.13 2006/11/14 16:12:01 fjp
|
55 |
* *** empty log message ***
|
56 |
*
|
57 |
* Revision 1.12 2006/11/08 16:48:20 fjp
|
58 |
* *** empty log message ***
|
59 |
*
|
60 |
* Revision 1.11 2006/11/06 17:19:02 fjp
|
61 |
* Depurando el aspecto
|
62 |
*
|
63 |
* Revision 1.10 2006/11/06 13:21:38 fjp
|
64 |
* detalles
|
65 |
*
|
66 |
* Revision 1.9 2006/10/27 10:17:27 fjp
|
67 |
* Correcto. Falta ponerlo bonito.
|
68 |
*
|
69 |
* Revision 1.8 2006/10/26 17:47:14 fjp
|
70 |
* previo a formato
|
71 |
*
|
72 |
* Revision 1.7 2006/10/26 11:42:42 fjp
|
73 |
* Ya pita, ya.
|
74 |
*
|
75 |
* Revision 1.6 2006/10/25 15:51:20 fjp
|
76 |
* por terminar lo de los giros
|
77 |
*
|
78 |
* Revision 1.5 2006/10/25 14:47:34 fjp
|
79 |
* *** empty log message ***
|
80 |
*
|
81 |
* Revision 1.4 2006/10/24 18:42:05 azabala
|
82 |
* *** empty log message ***
|
83 |
*
|
84 |
* Revision 1.3 2006/10/23 18:51:42 azabala
|
85 |
* *** empty log message ***
|
86 |
*
|
87 |
* Revision 1.2 2006/10/20 19:54:01 azabala
|
88 |
* *** empty log message ***
|
89 |
*
|
90 |
* Revision 1.1 2006/10/19 19:09:43 azabala
|
91 |
* *** empty log message ***
|
92 |
*
|
93 |
*
|
94 |
*/
|
95 |
package org.gvsig.graph.gui; |
96 |
|
97 |
import java.awt.BorderLayout; |
98 |
import java.awt.Color; |
99 |
import java.awt.Component; |
100 |
import java.awt.event.ActionEvent; |
101 |
import java.awt.event.ActionListener; |
102 |
import java.awt.geom.Rectangle2D; |
103 |
import java.text.NumberFormat; |
104 |
import java.util.ArrayList; |
105 |
import java.util.StringTokenizer; |
106 |
|
107 |
import javax.swing.JEditorPane; |
108 |
import javax.swing.JOptionPane; |
109 |
import javax.swing.JPanel; |
110 |
import javax.swing.JScrollPane; |
111 |
import javax.swing.event.HyperlinkEvent; |
112 |
import javax.swing.event.HyperlinkListener; |
113 |
|
114 |
import org.cresques.cts.IProjection; |
115 |
import org.gvsig.graph.core.DocumentRenderer; |
116 |
import org.gvsig.graph.core.TurnUtil; |
117 |
import org.gvsig.graph.solvers.Route; |
118 |
import org.gvsig.graph.solvers.RouteMemoryDriver; |
119 |
import org.gvsig.gui.beans.swing.JButton; |
120 |
|
121 |
import com.hardcode.gdbms.engine.values.DoubleValue; |
122 |
import com.iver.andami.PluginServices; |
123 |
import com.iver.andami.ui.mdiManager.IWindow; |
124 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
125 |
import com.iver.cit.gvsig.addlayer.AddLayerDialog; |
126 |
import com.iver.cit.gvsig.fmap.MapContext; |
127 |
import com.iver.cit.gvsig.fmap.MapControl; |
128 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
129 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
130 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
131 |
import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol; |
132 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
133 |
import com.iver.cit.gvsig.fmap.layers.GraphicLayer; |
134 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
135 |
import com.iver.cit.gvsig.fmap.rendering.FGraphic; |
136 |
|
137 |
public class RouteReportPanel extends JPanel implements IWindow { |
138 |
|
139 |
private final String START_IMAGE = "<img src=\"images/drapeau_depart.gif\">"; |
140 |
private final String STOP_IMAGE = "<img src=\"images/drapeau_arrivee.gif\">"; |
141 |
private final String LEFT_IMAGE = "<img src=\"images/turn-left.png\">"; |
142 |
private final String RIGHT_IMAGE = "<img src=\"images/turn-right.png\">"; |
143 |
private final String STRAIGHT_IMAGE = "<img src=\"images/gtk-go-up.png\">"; |
144 |
|
145 |
private final String LINE_SEPARATOR = "<hr width =\"70%\">"; |
146 |
|
147 |
private Route route;
|
148 |
|
149 |
private JScrollPane scrollPanel; |
150 |
private JEditorPane htmlPanel; |
151 |
private WindowInfo viewInfo;
|
152 |
|
153 |
private StringBuilder htmlText; |
154 |
private MapControl mapControl;
|
155 |
|
156 |
// Para poder poner duraci?n, etc.
|
157 |
private String weightText = "Longitud:"; |
158 |
|
159 |
// Distancias y costes acumulados (entre dos cambios de calles)
|
160 |
private double acumuledLenght = 0d; |
161 |
private double acumuledWeight = 0d; |
162 |
|
163 |
private double totalLenght = 0d; |
164 |
private double totalWeight = 0d; |
165 |
|
166 |
private int numberOfStreets = 1;// partimos de 1 porque consideramos la |
167 |
// salida
|
168 |
private ArrayList tramesOfSameStreet = new ArrayList(); |
169 |
|
170 |
NumberFormat nf = NumberFormat.getInstance(); |
171 |
|
172 |
public RouteReportPanel(Route route, MapControl mapControl) {
|
173 |
super();
|
174 |
setLayout(new BorderLayout()); |
175 |
this.route = route;
|
176 |
this.mapControl = mapControl;
|
177 |
scrollPanel = new JScrollPane(); |
178 |
htmlPanel = new JEditorPane(); |
179 |
htmlPanel.setEditable(false);
|
180 |
HTMLEditorKit kit = new HTMLEditorKit(); |
181 |
// {
|
182 |
// public ViewFactory getViewFactory()
|
183 |
// {
|
184 |
// return new HTMLFactory()
|
185 |
// {
|
186 |
// public View create(Element elem)
|
187 |
// {
|
188 |
// View view = super.create(elem);
|
189 |
//
|
190 |
// if (view instanceof ImageView)
|
191 |
// {
|
192 |
// ((javax.swing.text.html.ImageView) view).setLoadsSynchronously(true);
|
193 |
// }
|
194 |
// return view;
|
195 |
// }
|
196 |
// };
|
197 |
// }
|
198 |
// };
|
199 |
htmlPanel.setEditorKit(kit); |
200 |
|
201 |
nf.setMaximumFractionDigits(2);
|
202 |
|
203 |
final MapControl map = mapControl;
|
204 |
final Route routeTemp = route;
|
205 |
final MapControl mapControlTemp = mapControl;
|
206 |
htmlPanel.addHyperlinkListener(new HyperlinkListener() { |
207 |
ArrayList previousSelection;
|
208 |
|
209 |
public void hyperlinkUpdate(HyperlinkEvent e) { |
210 |
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { |
211 |
Rectangle2D bounds = null; |
212 |
StringTokenizer st = new StringTokenizer( |
213 |
e.getDescription(), ",");
|
214 |
System.err.println("E.GETDESCRIPTION():" |
215 |
+ e.getDescription()); |
216 |
ArrayList features = new ArrayList(); |
217 |
while (st.hasMoreTokens()) {
|
218 |
int indexOfFeature = Integer.parseInt(st.nextToken()); |
219 |
IFeature feature = (IFeature) routeTemp |
220 |
.getFeatureList().get(indexOfFeature); |
221 |
if (bounds == null) |
222 |
bounds = feature.getGeometry().getBounds2D(); |
223 |
else
|
224 |
bounds.add(feature.getGeometry().getBounds2D()); |
225 |
features.add(feature); |
226 |
} |
227 |
if (bounds != null) { |
228 |
bounds = expand(bounds); |
229 |
GraphicLayer graphicLayer = mapControlTemp |
230 |
.getMapContext().getGraphicsLayer(); |
231 |
if (previousSelection != null) { |
232 |
for (int i = 0; i < previousSelection.size(); i++) { |
233 |
graphicLayer |
234 |
.removeGraphic((FGraphic) previousSelection |
235 |
.get(i)); |
236 |
} |
237 |
} |
238 |
previousSelection = new ArrayList(); |
239 |
|
240 |
ILineSymbol lineSymbol = SymbologyFactory |
241 |
.createDefaultLineSymbol(); |
242 |
lineSymbol.setLineColor(Color.YELLOW);
|
243 |
lineSymbol.setLineWidth(3.0f);
|
244 |
int idSymbolLine = graphicLayer.addSymbol(lineSymbol);
|
245 |
for (int i = 0; i < features.size(); i++) { |
246 |
IGeometry gAux = ((IFeature) features.get(i)) |
247 |
.getGeometry(); |
248 |
FGraphic graphic = new FGraphic(gAux, idSymbolLine);
|
249 |
graphic.setTag("ROUTE");
|
250 |
graphicLayer.addGraphic(graphic); |
251 |
previousSelection.add(graphic); |
252 |
} |
253 |
mapControlTemp.drawGraphics(); |
254 |
map.getMapContext().getViewPort().setExtent(bounds); |
255 |
} |
256 |
} |
257 |
} |
258 |
}); |
259 |
initialize(); |
260 |
scrollPanel.setViewportView(htmlPanel); |
261 |
add(scrollPanel, BorderLayout.CENTER);
|
262 |
JPanel south = new JPanel(); |
263 |
JButton btnPrint = new JButton(_T("Print")); |
264 |
btnPrint.addActionListener(new ActionListener() { |
265 |
|
266 |
public void actionPerformed(ActionEvent e) { |
267 |
printReport(); |
268 |
} |
269 |
|
270 |
}); |
271 |
JButton btnExport = new JButton(_T("Export")); |
272 |
btnExport.addActionListener(new ActionListener() { |
273 |
|
274 |
public void actionPerformed(ActionEvent e) { |
275 |
exportRoute(); |
276 |
} |
277 |
|
278 |
}); |
279 |
|
280 |
south.add(btnPrint); |
281 |
south.add(btnExport); |
282 |
add(south, BorderLayout.SOUTH);
|
283 |
} |
284 |
|
285 |
protected void exportRoute() { |
286 |
RouteMemoryDriver driver = new RouteMemoryDriver(route.getFeatureList());
|
287 |
IProjection projection = AddLayerDialog.getLastProjection(); |
288 |
FLyrVect routeLayer = (FLyrVect) LayerFactory.createLayer("Route",
|
289 |
driver, projection); |
290 |
|
291 |
FormatSelectionPanel selectionPanel = new FormatSelectionPanel(PluginServices.getText(null, |
292 |
"Seleccione_un_formato_para_guardar_la_ruta"));
|
293 |
PluginServices.getMDIManager().addWindow(selectionPanel); |
294 |
|
295 |
String format = selectionPanel.getSelectedFormat();
|
296 |
com.iver.cit.gvsig.ExportTo export = new com.iver.cit.gvsig.ExportTo(); |
297 |
MapContext context = mapControl.getMapContext(); |
298 |
if (format.equalsIgnoreCase("SHP")) { |
299 |
export.saveToShp(context, routeLayer);
|
300 |
} else if (format.equalsIgnoreCase("DXF")) { |
301 |
export.saveToDxf(context, routeLayer);
|
302 |
// } else if (format.equalsIgnoreCase("GML")) {
|
303 |
// export.saveToGml(context, routeLayer);
|
304 |
} else if (format.equalsIgnoreCase("POSTGIS")) { |
305 |
export.saveToPostGIS(context, routeLayer);
|
306 |
} |
307 |
|
308 |
|
309 |
} |
310 |
|
311 |
/**
|
312 |
* Prints report (html)
|
313 |
*/
|
314 |
protected void printReport() { |
315 |
try {
|
316 |
// FJP: Esto ser?a lo ideal, pero solo funciona con el jre 1.6
|
317 |
// htmlPanel.print();
|
318 |
|
319 |
// Usamos una clase externa por compatibilidad con jre1.5, pero tiene menos calidad la salida.
|
320 |
DocumentRenderer docRenderer = new DocumentRenderer();
|
321 |
docRenderer.print(htmlPanel); |
322 |
} catch (Exception e) { |
323 |
e.printStackTrace(); |
324 |
JOptionPane.showMessageDialog((Component) PluginServices.getMDIManager().getActiveWindow(), |
325 |
e.getLocalizedMessage()); |
326 |
} |
327 |
} |
328 |
|
329 |
private Rectangle2D expand(Rectangle2D rect) { |
330 |
double xmin = rect.getMinX();
|
331 |
double ymin = rect.getMinY();
|
332 |
double width = rect.getWidth();
|
333 |
double height = rect.getHeight();
|
334 |
|
335 |
xmin -= width; |
336 |
ymin -= height; |
337 |
double newWidth = width * 2; |
338 |
double newHeight = height * 2; |
339 |
return new Rectangle2D.Double(xmin, ymin, newWidth, newHeight); |
340 |
} |
341 |
|
342 |
public void setRoute(Route route) { |
343 |
this.route = route;
|
344 |
initialize(); |
345 |
} |
346 |
|
347 |
private void initialize() { |
348 |
htmlText = new StringBuilder("<head>"); |
349 |
htmlText.append("<style type='text/css'>");
|
350 |
htmlText.append("<!-- ");
|
351 |
htmlText.append(" .normal { ");
|
352 |
htmlText |
353 |
.append(" font-family: Arial, Helvetica, sans-serif; font-size: 9px; font-style: normal; color: #333333;");
|
354 |
htmlText.append("}");
|
355 |
htmlText.append(" a { ");
|
356 |
htmlText |
357 |
.append(" font-family: Arial, Helvetica, sans-serif; font-size: 9px; font-style: italic; font-weight: bold;");
|
358 |
htmlText.append("}");
|
359 |
htmlText.append(" h1 { ");
|
360 |
htmlText |
361 |
.append(" font-family: Arial, Helvetica, sans-serif; font-size: 12px;");
|
362 |
htmlText.append("}");
|
363 |
htmlText.append(" .distancia { ");
|
364 |
htmlText |
365 |
.append(" font-family: Arial, Helvetica, sans-serif; font-size: 9px; color: #666666;");
|
366 |
htmlText.append("}");
|
367 |
htmlText.append(" .resumen { ");
|
368 |
htmlText |
369 |
.append(" font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #333333;");
|
370 |
htmlText.append("}");
|
371 |
htmlText.append(" .left { ");
|
372 |
htmlText.append(" font-weight: bold; color: #990000;");
|
373 |
htmlText.append("}");
|
374 |
htmlText.append(" .right { ");
|
375 |
htmlText.append(" font-weight: bold; color: #0033FF;");
|
376 |
htmlText.append("}");
|
377 |
|
378 |
htmlText.append(" -->");
|
379 |
htmlText.append("</style>");
|
380 |
htmlText.append("</head>");
|
381 |
htmlText.append("<body>");
|
382 |
ArrayList features = route.getFeatureList();
|
383 |
|
384 |
// Route is ordered from the the start to the end
|
385 |
IFeature firstFeature = (IFeature) features.get(0);
|
386 |
IFeature lastFeature = (IFeature) features.get(features.size() - 1);
|
387 |
|
388 |
renderHeader(firstFeature, lastFeature); |
389 |
renderFirstStrech(firstFeature); |
390 |
|
391 |
IFeature previousFeature = firstFeature; |
392 |
for (int i = 1; i < features.size(); i++) { |
393 |
IFeature feature = (IFeature) features.get(i); |
394 |
renderStrech(feature, previousFeature, i); |
395 |
previousFeature = feature; |
396 |
} |
397 |
|
398 |
// TODO
|
399 |
// Invertir el FIRST y el LAST
|
400 |
// Borrar el graphics resaltado cuando se resalte otro
|
401 |
renderLastStretch((IFeature) features.get(features.size() - 1),
|
402 |
previousFeature); |
403 |
htmlText.append("</body>");
|
404 |
// System.out.println(htmlText);
|
405 |
htmlPanel.setText(htmlText.toString()); |
406 |
|
407 |
} |
408 |
|
409 |
private void renderHeader(IFeature firstFeature, IFeature lastFeature) { |
410 |
String startName = firstFeature.getAttribute(Route.TEXT_INDEX)
|
411 |
.toString(); |
412 |
String stopName = lastFeature.getAttribute(Route.TEXT_INDEX).toString();
|
413 |
htmlText.append("<h1>");
|
414 |
htmlText.append(_T("Route_report") + ":" + startName + "-" + stopName); |
415 |
htmlText.append("</h1><br>");
|
416 |
htmlText.append("<span class='resumen'>" + _T("Start_from") + ": <b>"); |
417 |
htmlText.append(startName); |
418 |
htmlText.append("</b><br>");
|
419 |
htmlText.append(_T("Arrival_to") + ":<b> "); |
420 |
htmlText.append(stopName + "</b><br>");
|
421 |
|
422 |
htmlText.append(_T("Total_length") + ": <b>" |
423 |
+ nf.format(getLengthOfRoute()) + "</b></span>");
|
424 |
htmlText.append(LINE_SEPARATOR); |
425 |
} |
426 |
|
427 |
private double getLengthOfRoute() { |
428 |
double solution = 0d; |
429 |
ArrayList featureList = route.getFeatureList();
|
430 |
for (int i = 0; i < featureList.size(); i++) { |
431 |
IFeature feature = (IFeature) featureList.get(i); |
432 |
solution += ((DoubleValue) feature.getAttribute(Route.LENGTH_INDEX)) |
433 |
.getValue(); |
434 |
} |
435 |
return solution;
|
436 |
} |
437 |
|
438 |
private void renderFirstStrech(IFeature feature) { |
439 |
htmlText.append("<table>");
|
440 |
htmlText.append("<tr>");
|
441 |
htmlText.append("<td width='40'>");
|
442 |
htmlText.append(START_IMAGE); |
443 |
htmlText.append("</td>");
|
444 |
htmlText.append("<td class='normal'>");
|
445 |
htmlText.append("1. " + _T("Start_from") + ":<b> "); |
446 |
htmlText.append(feature.getAttribute(Route.TEXT_INDEX)); |
447 |
htmlText.append("</b></td></tr>");
|
448 |
htmlText.append("<tr>");
|
449 |
htmlText.append("<td width='40'></td><td><a href=\"" + 0 + "\">" |
450 |
+ _T("Show_in_map") + "</a><td></tr>"); |
451 |
htmlText.append("</table>");
|
452 |
htmlText.append(LINE_SEPARATOR); |
453 |
|
454 |
double length = ((DoubleValue) feature.getAttribute(Route.LENGTH_INDEX))
|
455 |
.getValue(); |
456 |
double weight = ((DoubleValue) feature.getAttribute(Route.WEIGHT_INDEX))
|
457 |
.getValue(); |
458 |
acumuledLenght += length; |
459 |
acumuledWeight += weight; |
460 |
|
461 |
totalLenght += length; |
462 |
totalWeight += weight; |
463 |
|
464 |
tramesOfSameStreet.add(new Integer(0)); |
465 |
} |
466 |
|
467 |
private String _T(String str) { |
468 |
return PluginServices.getText(this, str); |
469 |
} |
470 |
|
471 |
private void renderStrech(IFeature feature, IFeature previousFeature, |
472 |
int index) {
|
473 |
String street1 = previousFeature.getAttribute(Route.TEXT_INDEX)
|
474 |
.toString(); |
475 |
String street2 = feature.getAttribute(Route.TEXT_INDEX).toString();
|
476 |
boolean changeStreet = !street1.equalsIgnoreCase(street2);
|
477 |
double length = ((DoubleValue) feature.getAttribute(Route.LENGTH_INDEX))
|
478 |
.getValue(); |
479 |
double weight = ((DoubleValue) feature.getAttribute(Route.WEIGHT_INDEX))
|
480 |
.getValue(); |
481 |
|
482 |
String textoTramo = null; |
483 |
String imageTurn = null; |
484 |
|
485 |
if (changeStreet) {
|
486 |
numberOfStreets++; |
487 |
String prefix = _T("follow") + " <b>" + street1 + "</b> " |
488 |
+ _T("during") + " " + nf.format(acumuledLenght) + " " |
489 |
+ _T("and");
|
490 |
int direction = TurnUtil.getDirection(previousFeature, feature);
|
491 |
|
492 |
if (direction == TurnUtil.GO_STRAIGH_ON) {
|
493 |
textoTramo = prefix + " " + _T("continue_by") + " <b> " |
494 |
+ street2 + "</b>";
|
495 |
imageTurn = STRAIGHT_IMAGE; |
496 |
|
497 |
} else if (direction == TurnUtil.TURN_LEFT) { |
498 |
textoTramo = prefix + " " + _T("turn") + " " |
499 |
+ "<span class='left'><b> " + _T("left") |
500 |
+ "</b></span> " + _T("by_turn") + " <b>" + street2 |
501 |
+ "</b> ";
|
502 |
imageTurn = LEFT_IMAGE; |
503 |
|
504 |
} else if (direction == TurnUtil.TURN_RIGHT) { |
505 |
textoTramo = prefix + " " + _T("turn") |
506 |
+ " <span class='right'><b> " + _T("right") |
507 |
+ " </b></span> " + _T("by_turn") + " <b>" + street2 |
508 |
+ "</b>";
|
509 |
imageTurn = RIGHT_IMAGE; |
510 |
} |
511 |
htmlText.append("<table>");
|
512 |
htmlText.append("<tr>");
|
513 |
htmlText.append("<td width='40'>");
|
514 |
htmlText.append(imageTurn); |
515 |
htmlText.append("</td>");
|
516 |
htmlText.append("<td class='normal'>");
|
517 |
htmlText.append(numberOfStreets + " " + textoTramo);// TODO INTERNAC |
518 |
htmlText.append("</td></tr>");
|
519 |
htmlText.append("<tr>");
|
520 |
htmlText.append("<td with='40'></td><td class='distancia'>"
|
521 |
+ _T("Accumulated_distance") + ":" + nf.format(totalLenght) |
522 |
+ "</td></tr>");
|
523 |
|
524 |
if (!weightText.equalsIgnoreCase("Longitud:")) { |
525 |
htmlText.append("<tr>");
|
526 |
htmlText.append("<td with='40'></td><td class='distancia'>"
|
527 |
+ _T("cost") + ":" + nf.format(totalWeight) |
528 |
+ "</td></tr>");
|
529 |
} |
530 |
|
531 |
String features = ""; |
532 |
for (int i = 0; i < tramesOfSameStreet.size() - 1; i++) { |
533 |
int featureIndex = ((Integer) tramesOfSameStreet.get(i)) |
534 |
.intValue(); |
535 |
features += featureIndex + ",";
|
536 |
} |
537 |
|
538 |
features += ((Integer) tramesOfSameStreet.get(tramesOfSameStreet
|
539 |
.size() - 1)).intValue();
|
540 |
// System.out.println("features = " + features);
|
541 |
htmlText.append("<tr><td with='40'></td><td><a href=\"" + features
|
542 |
+ "\">" + _T("Show_in_map") + "</a><td></tr>"); |
543 |
htmlText.append("</table>");
|
544 |
htmlText.append(LINE_SEPARATOR); |
545 |
|
546 |
acumuledLenght = length; |
547 |
acumuledWeight = weight; |
548 |
tramesOfSameStreet.clear(); |
549 |
|
550 |
} else {
|
551 |
acumuledLenght += length; |
552 |
acumuledWeight += weight; |
553 |
} |
554 |
|
555 |
tramesOfSameStreet.add(new Integer(index)); |
556 |
totalLenght += length; |
557 |
totalWeight += weight; |
558 |
|
559 |
} |
560 |
|
561 |
private void renderLastStretch(IFeature feature, IFeature previousFeature) { |
562 |
|
563 |
// double length =
|
564 |
// ((DoubleValue)feature.getAttribute(Route.LENGTH_INDEX)).getValue();
|
565 |
// double weight =
|
566 |
// ((DoubleValue)feature.getAttribute(Route.WEIGHT_INDEX)).getValue();
|
567 |
//
|
568 |
//
|
569 |
// totalLenght += length;
|
570 |
// totalWeight += weight;
|
571 |
|
572 |
htmlText.append("<table>");
|
573 |
htmlText.append("<tr>");
|
574 |
htmlText.append("<td width='40'>");
|
575 |
htmlText.append(STOP_IMAGE); |
576 |
htmlText.append("</td>");
|
577 |
htmlText.append("<td class='resumen'>");
|
578 |
htmlText.append(numberOfStreets + ". " + _T("Arrival_to") + ": "); |
579 |
htmlText.append(feature.getAttribute(Route.TEXT_INDEX)); |
580 |
htmlText.append("</td></tr>");
|
581 |
htmlText.append("<tr><td with='40'></td><td class='resumen'>"
|
582 |
+ _T("Accumulated_distance") + ":" + nf.format(totalLenght) |
583 |
+ "</td></tr>");
|
584 |
|
585 |
if (!weightText.equalsIgnoreCase("Longitud:")) |
586 |
htmlText.append("<tr><td with='40'></td><td class='resumen'>Coste:"
|
587 |
+ totalWeight + "</td></tr>");
|
588 |
htmlText.append("<tr><td with='40'></td><td><a href=\""
|
589 |
+ (route.getFeatureList().size() - 1) + "\">" |
590 |
+ _T("Show_in_map") + "</a><td></tr>"); |
591 |
htmlText.append("</table>");
|
592 |
} |
593 |
|
594 |
public WindowInfo getWindowInfo() {
|
595 |
if (viewInfo == null) { |
596 |
viewInfo = new WindowInfo(WindowInfo.MODELESSDIALOG
|
597 |
| WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE |
598 |
| WindowInfo.ICONIFIABLE | WindowInfo.PALETTE); |
599 |
viewInfo.setTitle(_T("route_report_title"));// Internacionalizar |
600 |
// esto
|
601 |
viewInfo.setWidth(400);
|
602 |
viewInfo.setHeight(350);
|
603 |
} |
604 |
return viewInfo;
|
605 |
} |
606 |
|
607 |
public Object getWindowProfile() { |
608 |
return WindowInfo.TOOL_PROFILE;
|
609 |
} |
610 |
|
611 |
} |