g.drawImage(europaBackground.getImage(), 0, 0, translator.getImageWidth(), translator.getImageHeight(), this);
}
g.setFont(g.getFont().deriveFont((float) TEXT_SIZE));
g.setColor(TangoColors.PLUM_2);
for (Visit visit : travelingSalesmanTour.getVisitList()) {
City city = visit.getCity();
int x = translator.translateLongitudeToX(city.getLongitude());
int y = translator.translateLatitudeToY(city.getLatitude());
g.fillRect(x - 1, y - 1, 3, 3);
if (city.getName() != null) {
g.drawString(city.getName(), x + 3, y - 3);
}
}
g.setColor(TangoColors.ALUMINIUM_4);
for (Domicile domicile : travelingSalesmanTour.getDomicileList()) {
City city = domicile.getCity();
int x = translator.translateLongitudeToX(city.getLongitude());
int y = translator.translateLatitudeToY(city.getLatitude());
g.fillRect(x - 2, y - 2, 5, 5);
if (city.getName() != null) {
g.drawString(city.getName(), x + 3, y - 3);
}
}
g.setColor(TangoColors.CHOCOLATE_1);
for (Visit visit : travelingSalesmanTour.getVisitList()) {
if (visit.getPreviousAppearance() != null) {
City previousCity = visit.getPreviousAppearance().getCity();
int previousX = translator.translateLongitudeToX(previousCity.getLongitude());
int previousY = translator.translateLatitudeToY(previousCity.getLatitude());
City city = visit.getCity();
int x = translator.translateLongitudeToX(city.getLongitude());
int y = translator.translateLatitudeToY(city.getLatitude());
g.drawLine(previousX, previousY, x, y);
// Back to domicile line
boolean needsBackToDomicileLineDraw = true;
for (Visit trailingVisit : travelingSalesmanTour.getVisitList()) {
if (trailingVisit.getPreviousAppearance() == visit) {
needsBackToDomicileLineDraw = false;
break;
}
}
if (needsBackToDomicileLineDraw) {
// TODO support more than 1 domicile
Domicile domicile = travelingSalesmanTour.getDomicileList().get(0);
City domicileCity = domicile.getCity();
int domicileX = translator.translateLongitudeToX(domicileCity.getLongitude());
int domicileY = translator.translateLatitudeToY(domicileCity.getLatitude());
g.drawLine(x, y,domicileX, domicileY);
}
}
}
// Legend