Revision 30840 trunk/extensions/extGraph/src/org/gvsig/graph/gui/RouteReportPanel.java
RouteReportPanel.java | ||
---|---|---|
111 | 111 |
import org.gvsig.graph.solvers.Route; |
112 | 112 |
|
113 | 113 |
import com.hardcode.gdbms.engine.values.DoubleValue; |
114 |
import com.iver.andami.PluginServices; |
|
114 | 115 |
import com.iver.andami.ui.mdiManager.IWindow; |
115 | 116 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
116 | 117 |
import com.iver.cit.gvsig.fmap.MapControl; |
... | ... | |
138 | 139 |
private WindowInfo viewInfo; |
139 | 140 |
|
140 | 141 |
|
141 |
private String htmlText; |
|
142 |
private StringBuilder htmlText;
|
|
142 | 143 |
private MapControl mapControl; |
143 | 144 |
|
144 | 145 |
//Para poder poner duraci?n, etc. |
... | ... | |
243 | 244 |
} |
244 | 245 |
|
245 | 246 |
private void initialize(){ |
246 |
htmlText = "<head>";
|
|
247 |
htmlText += "<style type='text/css'>";
|
|
248 |
htmlText += "<!-- ";
|
|
249 |
htmlText += " .normal { ";
|
|
250 |
htmlText += " font-family: Arial, Helvetica, sans-serif; font-size: 10px; font-style: normal; color: #333333;";
|
|
251 |
htmlText += "}";
|
|
252 |
htmlText += " a { ";
|
|
253 |
htmlText += " font-family: Arial, Helvetica, sans-serif; font-size: 10px; font-style: italic; font-weight: bold;";
|
|
254 |
htmlText += "}";
|
|
255 |
htmlText += " h1 { ";
|
|
256 |
htmlText += " font-family: Arial, Helvetica, sans-serif; font-size: 14px;";
|
|
257 |
htmlText += "}";
|
|
258 |
htmlText += " .distancia { ";
|
|
259 |
htmlText += " font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #666666;";
|
|
260 |
htmlText += "}";
|
|
261 |
htmlText += " .resumen { ";
|
|
262 |
htmlText += " font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #333333;";
|
|
263 |
htmlText += "}";
|
|
264 |
htmlText += " .left { ";
|
|
265 |
htmlText += " font-weight: bold; color: #990000;";
|
|
266 |
htmlText += "}";
|
|
267 |
htmlText += " .right { ";
|
|
268 |
htmlText += " font-weight: bold; color: #0033FF;";
|
|
269 |
htmlText += "}";
|
|
247 |
htmlText = new StringBuilder("<head>");
|
|
248 |
htmlText.append("<style type='text/css'>");
|
|
249 |
htmlText.append("<!-- ");
|
|
250 |
htmlText.append(" .normal { ");
|
|
251 |
htmlText.append(" font-family: Arial, Helvetica, sans-serif; font-size: 10px; font-style: normal; color: #333333;");
|
|
252 |
htmlText.append("}");
|
|
253 |
htmlText.append(" a { ");
|
|
254 |
htmlText.append(" font-family: Arial, Helvetica, sans-serif; font-size: 10px; font-style: italic; font-weight: bold;");
|
|
255 |
htmlText.append("}");
|
|
256 |
htmlText.append(" h1 { ");
|
|
257 |
htmlText.append(" font-family: Arial, Helvetica, sans-serif; font-size: 14px;");
|
|
258 |
htmlText.append("}");
|
|
259 |
htmlText.append(" .distancia { ");
|
|
260 |
htmlText.append(" font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #666666;");
|
|
261 |
htmlText.append("}");
|
|
262 |
htmlText.append(" .resumen { ");
|
|
263 |
htmlText.append(" font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #333333;");
|
|
264 |
htmlText.append("}");
|
|
265 |
htmlText.append(" .left { ");
|
|
266 |
htmlText.append(" font-weight: bold; color: #990000;");
|
|
267 |
htmlText.append("}");
|
|
268 |
htmlText.append(" .right { ");
|
|
269 |
htmlText.append(" font-weight: bold; color: #0033FF;");
|
|
270 |
htmlText.append("}");
|
|
270 | 271 |
|
271 |
htmlText += " -->";
|
|
272 |
htmlText += "</style>";
|
|
273 |
htmlText += "</head>";
|
|
274 |
htmlText += "<body>";
|
|
272 |
htmlText.append(" -->");
|
|
273 |
htmlText.append("</style>");
|
|
274 |
htmlText.append("</head>");
|
|
275 |
htmlText.append("<body>");
|
|
275 | 276 |
ArrayList features = route.getFeatureList(); |
276 | 277 |
|
277 | 278 |
//Route is ordered from the the start to the end |
... | ... | |
292 | 293 |
//Invertir el FIRST y el LAST |
293 | 294 |
//Borrar el graphics resaltado cuando se resalte otro |
294 | 295 |
renderLastStretch((IFeature)features.get(features.size() -1), previousFeature); |
295 |
htmlText += "</body>";
|
|
296 |
System.out.println(htmlText); |
|
297 |
htmlPanel.setText(htmlText); |
|
296 |
htmlText.append("</body>");
|
|
297 |
// System.out.println(htmlText);
|
|
298 |
htmlPanel.setText(htmlText.toString());
|
|
298 | 299 |
|
299 | 300 |
} |
300 | 301 |
|
... | ... | |
305 | 306 |
private void renderHeader(IFeature firstFeature, IFeature lastFeature){ |
306 | 307 |
String startName = firstFeature.getAttribute(Route.TEXT_INDEX).toString(); |
307 | 308 |
String stopName = lastFeature.getAttribute(Route.TEXT_INDEX).toString(); |
308 |
htmlText += "<h1>";
|
|
309 |
htmlText += "Informe de Ruta:" + startName + "-" + stopName ;//TODO INTERNACIONALIZAR ESTO
|
|
310 |
htmlText += "</h1><br>";
|
|
311 |
htmlText += "<span class='resumen'>Salida desde: <b>";//TODO INTERNAC
|
|
312 |
htmlText += startName;
|
|
313 |
htmlText += "</b><br>";
|
|
314 |
htmlText += "Llegada a:<b> ";//TODO INTERNAC
|
|
315 |
htmlText += stopName + "</b><br>";
|
|
309 |
htmlText.append("<h1>");
|
|
310 |
htmlText.append(_T("Route_report") + ":" + startName + "-" + stopName);
|
|
311 |
htmlText.append("</h1><br>");
|
|
312 |
htmlText.append("<span class='resumen'>" + _T("Start_from") + ": <b>");
|
|
313 |
htmlText.append(startName);
|
|
314 |
htmlText.append("</b><br>");
|
|
315 |
htmlText.append(_T("Arrival_to") + ":<b> ");
|
|
316 |
htmlText.append(stopName + "</b><br>");
|
|
316 | 317 |
|
317 |
//TODO METER LA LONGITUD TOTAL DEL TRAYECTO AQUI |
|
318 |
htmlText += "Longitud total del trayecto: <b>" + nf.format(getLengthOfRoute()) + "</b></span>"; |
|
319 |
htmlText += LINE_SEPARATOR; |
|
318 |
htmlText.append(_T("Total_length") + ": <b>" + nf.format(getLengthOfRoute()) + "</b></span>"); |
|
319 |
htmlText.append(LINE_SEPARATOR); |
|
320 | 320 |
} |
321 | 321 |
|
322 | 322 |
private double getLengthOfRoute() { |
... | ... | |
331 | 331 |
|
332 | 332 |
|
333 | 333 |
private void renderFirstStrech(IFeature feature){ |
334 |
htmlText += "<table>";
|
|
335 |
htmlText += "<tr>";
|
|
336 |
htmlText += "<td width='40'>";
|
|
337 |
htmlText += START_IMAGE;
|
|
338 |
htmlText += "</td>";
|
|
339 |
htmlText += "<td class='normal'>";
|
|
340 |
htmlText += "1. Salir de:<b> ";//TODO INTERNAC
|
|
341 |
htmlText += feature.getAttribute(Route.TEXT_INDEX);
|
|
342 |
htmlText += "</b></td></tr>";
|
|
343 |
htmlText += "<tr>";
|
|
344 |
htmlText += "<td width='40'></td><td><a href=\""+0+"\">Ver sobre el mapa</a><td></tr>";
|
|
345 |
htmlText += "</table>";
|
|
346 |
htmlText += LINE_SEPARATOR;
|
|
334 |
htmlText.append("<table>");
|
|
335 |
htmlText.append("<tr>");
|
|
336 |
htmlText.append("<td width='40'>");
|
|
337 |
htmlText.append(START_IMAGE);
|
|
338 |
htmlText.append("</td>");
|
|
339 |
htmlText.append("<td class='normal'>");
|
|
340 |
htmlText.append("1. " + _T("Start_from") + ":<b> ");
|
|
341 |
htmlText.append(feature.getAttribute(Route.TEXT_INDEX));
|
|
342 |
htmlText.append("</b></td></tr>");
|
|
343 |
htmlText.append("<tr>");
|
|
344 |
htmlText.append("<td width='40'></td><td><a href=\""+0+"\">" + _T("Show_in_map") + "</a><td></tr>");
|
|
345 |
htmlText.append("</table>");
|
|
346 |
htmlText.append(LINE_SEPARATOR);
|
|
347 | 347 |
|
348 | 348 |
double length = ((DoubleValue)feature.getAttribute(Route.LENGTH_INDEX)).getValue(); |
349 | 349 |
double weight = ((DoubleValue)feature.getAttribute(Route.WEIGHT_INDEX)).getValue(); |
... | ... | |
356 | 356 |
tramesOfSameStreet.add(new Integer(0)); |
357 | 357 |
} |
358 | 358 |
|
359 |
private String _T(String str) { |
|
360 |
return PluginServices.getText(this, str); |
|
361 |
} |
|
362 |
|
|
359 | 363 |
private void renderStrech(IFeature feature, IFeature previousFeature, int index){ |
360 | 364 |
String street1 = previousFeature.getAttribute(Route.TEXT_INDEX).toString(); |
361 | 365 |
String street2 = feature.getAttribute(Route.TEXT_INDEX).toString(); |
... | ... | |
368 | 372 |
|
369 | 373 |
if(changeStreet){ |
370 | 374 |
numberOfStreets++; |
371 |
String prefix = "Contin?e por <b>" + street1 + "</b> durante "+
|
|
372 |
nf.format(acumuledLenght)+" y ";
|
|
375 |
String prefix = _T("follow") + " <b>" + street1 + "</b> " + _T("during") + " " +
|
|
376 |
nf.format(acumuledLenght)+ " " + _T("and");
|
|
373 | 377 |
int direction = TurnUtil.getDirection(previousFeature, feature); |
374 | 378 |
|
375 | 379 |
if(direction == TurnUtil.GO_STRAIGH_ON){ |
376 |
textoTramo = prefix + " prosiga por <b>"+ street2 + "</b>";
|
|
380 |
textoTramo = prefix + " " + _T("continue_by") + " <b> "+ street2 + "</b>";
|
|
377 | 381 |
imageTurn = STRAIGHT_IMAGE; |
378 | 382 |
|
379 | 383 |
}else if(direction == TurnUtil.TURN_LEFT){ |
380 |
textoTramo = prefix += " gire a la <span class='left'><b>izquierda</b></span> por <b>" + street2 + "</b>"; |
|
384 |
textoTramo = prefix + " " + _T("turn") + " " + "<span class='left'><b> " + _T("left") + |
|
385 |
"</b></span> " + _T("by") + " <b>" + street2 + "</b> "; |
|
381 | 386 |
imageTurn = LEFT_IMAGE; |
382 | 387 |
|
383 | 388 |
}else if(direction == TurnUtil.TURN_RIGHT){ |
384 |
textoTramo = prefix += " gire a la <span class='right'><b>derecha</b></span> por <b>" + street2 + "</b>"; |
|
389 |
textoTramo = prefix + " " + _T("turn") + " <span class='right'><b> " + _T("right") + |
|
390 |
" </b></span> " + _T("by") + " <b>" + street2 + "</b>"; |
|
385 | 391 |
imageTurn = RIGHT_IMAGE; |
386 | 392 |
} |
387 |
htmlText += "<table>";
|
|
388 |
htmlText += "<tr>";
|
|
389 |
htmlText += "<td width='40'>";
|
|
390 |
htmlText += imageTurn;
|
|
391 |
htmlText += "</td>";
|
|
392 |
htmlText += "<td class='normal'>";
|
|
393 |
htmlText += numberOfStreets+" "+textoTramo;//TODO INTERNAC
|
|
394 |
htmlText += "</td></tr>";
|
|
395 |
htmlText += "<tr>";
|
|
396 |
htmlText += "<td with='40'></td><td class='distancia'>Distancia acumulada:"+nf.format(totalLenght)+"</td></tr>";
|
|
393 |
htmlText.append("<table>");
|
|
394 |
htmlText.append("<tr>");
|
|
395 |
htmlText.append("<td width='40'>");
|
|
396 |
htmlText.append(imageTurn);
|
|
397 |
htmlText.append("</td>");
|
|
398 |
htmlText.append("<td class='normal'>");
|
|
399 |
htmlText.append(numberOfStreets+" "+textoTramo);//TODO INTERNAC
|
|
400 |
htmlText.append("</td></tr>");
|
|
401 |
htmlText.append("<tr>");
|
|
402 |
htmlText.append("<td with='40'></td><td class='distancia'>" + _T("Accumulated_distance") + ":" +nf.format(totalLenght)+"</td></tr>");
|
|
397 | 403 |
|
398 | 404 |
if(!weightText.equalsIgnoreCase("Longitud:")) |
399 | 405 |
{ |
400 |
htmlText += "<tr>";
|
|
401 |
htmlText += "<td with='40'></td><td class='distancia'>Coste:"+nf.format(totalWeight)+"</td></tr>";
|
|
406 |
htmlText.append("<tr>");
|
|
407 |
htmlText.append("<td with='40'></td><td class='distancia'>" + _T("cost") + ":" +nf.format(totalWeight)+"</td></tr>");
|
|
402 | 408 |
} |
403 | 409 |
|
404 | 410 |
String features = ""; |
... | ... | |
409 | 415 |
|
410 | 416 |
features += ((Integer)tramesOfSameStreet.get(tramesOfSameStreet.size()-1)).intValue(); |
411 | 417 |
// System.out.println("features = " + features); |
412 |
htmlText += "<tr><td with='40'></td><td><a href=\""+features+"\">Ver sobre el mapa</a><td></tr>";
|
|
413 |
htmlText += "</table>";
|
|
414 |
htmlText += LINE_SEPARATOR;
|
|
418 |
htmlText.append("<tr><td with='40'></td><td><a href=\""+features+"\">Ver sobre el mapa</a><td></tr>");
|
|
419 |
htmlText.append("</table>");
|
|
420 |
htmlText.append(LINE_SEPARATOR);
|
|
415 | 421 |
|
416 | 422 |
acumuledLenght = length; |
417 | 423 |
acumuledWeight = weight; |
... | ... | |
440 | 446 |
// totalLenght += length; |
441 | 447 |
// totalWeight += weight; |
442 | 448 |
|
443 |
htmlText += "<table>";
|
|
444 |
htmlText += "<tr>";
|
|
445 |
htmlText += "<td width='40'>";
|
|
446 |
htmlText += STOP_IMAGE;
|
|
447 |
htmlText += "</td>";
|
|
448 |
htmlText += "<td>";
|
|
449 |
htmlText += numberOfStreets+". Llegada: ";//TODO INTERNAC
|
|
450 |
htmlText += feature.getAttribute(Route.TEXT_INDEX);
|
|
451 |
htmlText += "</td></tr>";
|
|
452 |
htmlText += "<tr><td with='40'></td><td>Longitud:"+nf.format(totalLenght)+"</td></tr>";
|
|
449 |
htmlText.append("<table>");
|
|
450 |
htmlText.append("<tr>");
|
|
451 |
htmlText.append("<td width='40'>");
|
|
452 |
htmlText.append(STOP_IMAGE);
|
|
453 |
htmlText.append("</td>");
|
|
454 |
htmlText.append("<td class='resumen'>");
|
|
455 |
htmlText.append(numberOfStreets+". " + _T("Llegada") + ":" );
|
|
456 |
htmlText.append(feature.getAttribute(Route.TEXT_INDEX));
|
|
457 |
htmlText.append("</td></tr>");
|
|
458 |
htmlText.append("<tr><td with='40'></td><td class='resumen'>" + _T("Longitud") + ":" +nf.format(totalLenght)+"</td></tr>");
|
|
453 | 459 |
|
454 | 460 |
if(!weightText.equalsIgnoreCase("Longitud:")) |
455 |
htmlText += "<tr><td with='40'></td><td class='distancia'>Coste:"+totalWeight+"</td></tr>";
|
|
456 |
htmlText += "<tr><td with='40'></td><td><a href=\""+(route.getFeatureList().size()-1)+"\">Ver sobre el mapa</a><td></tr>";
|
|
457 |
htmlText += "</table>";
|
|
461 |
htmlText.append("<tr><td with='40'></td><td class='resumen'>Coste:"+totalWeight+"</td></tr>");
|
|
462 |
htmlText.append("<tr><td with='40'></td><td><a href=\""+(route.getFeatureList().size()-1)+"\">Ver sobre el mapa</a><td></tr>");
|
|
463 |
htmlText.append("</table>");
|
|
458 | 464 |
} |
459 | 465 |
|
460 | 466 |
public WindowInfo getWindowInfo() { |
Also available in: Unified diff