use of il.ac.technion.cs.yp.btw.citysimulation.VehicleDescriptor in project BTW by TechnionYearlyProject.
the class StatisticsComparisonController method initTextFields.
/**
*@author: Orel
* @date: 20/6/18
* Initializing all the data in the table
*/
private void initTextFields() {
defaultFill = avgDrivingTime1.getFill();
simulation1Text.setText(simulationType1);
simulation2Text.setText(simulationType2);
EvaluationComparator comparator = new EvaluationComparator(eval1, eval2);
setTimeText(avgDrivingTime1, eval1.averageTotalDrivingTime().seconds());
setTimeText(avgDrivingTime2, eval2.averageTotalDrivingTime().seconds());
setTimeText(avgRoadDriving1, eval1.averageDrivingTimeOnAllRoads().seconds());
setTimeText(avgRoadDriving2, eval2.averageDrivingTimeOnAllRoads().seconds());
setTimeText(avgWaitingTime1, eval1.averageWaitingTimeOnAllTrafficLights().seconds());
setTimeText(avgWaitingTime2, eval2.averageWaitingTimeOnAllTrafficLights().seconds());
setColoredTimeText(avgDrivingTimeDiff, comparator.compareAverageDrivingTimeOfVehicles());
setColoredTimeText(avgRoadDrivingDiff, comparator.compareAverageDrivingTimeOnRoads());
setColoredTimeText(avgWaitingTimeDiff, comparator.compareAverageWaitingTimeOnTrafficLights());
setColoredTimePercent(avgDrivingTimePercent, comparator.compareAverageDrivingTimeOfVehiclesPercent());
setColoredTimePercent(avgRoadDrivingPercent, comparator.compareAverageDrivingTimeOnRoadsPercent());
setColoredTimePercent(avgWaitingTimePercent, comparator.compareAverageWaitingTimeOnTrafficLightsPercent());
// now for the combo boxes
new Thread(() -> {
for (TrafficLight f : mapDatabase.getAllTrafficLights()) {
Label l = new Label(f.getName());
trafficLightComboBox.getItems().add(l);
}
for (Road r : mapDatabase.getAllRoads()) {
Label l = new Label(r.getName());
roadComboBox.getItems().add(l);
}
for (VehicleEntry v : vehiclesList) {
Optional<VehicleDescriptor> descriptor = v.getDescriptor();
if (descriptor.isPresent()) {
Label l = new Label(Integer.toString(descriptor.get().getID()));
vehicleComboBox.getItems().add(l);
vehiclesMap.put(descriptor.get().getID(), descriptor.get());
}
}
}).start();
vehicleComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
Integer id = Integer.parseInt(newValue.getText());
VehicleDescriptor vec = vehiclesMap.get(id);
try {
setTimeText(drivingTime1, eval1.totalDrivingTime(vec).seconds());
setTimeText(drivingTime2, eval2.totalDrivingTime(vec).seconds());
setColoredTimeText(drivingTimeDiff, comparator.compareDrivingTimeOfVehicle(vec));
setColoredTimePercent(drivingTimePercent, comparator.compareDrivingTimeOfVehiclePercent(vec));
} catch (UnfinishedVehicleException e) {
setTimeText(drivingTime1, (long) 0);
setTimeText(drivingTime2, (long) 0);
setColoredTimeText(drivingTimeDiff, (long) 0);
setColoredTimePercent(drivingTimePercent, (double) 0);
}
}
});
trafficLightComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
String id = newValue.getText();
TrafficLight tl = mapDatabase.getTrafficLight(id);
setTimeText(waitingTime1, eval1.averageWaitingTimeOnTrafficLight(tl).seconds());
setTimeText(waitingTime2, eval2.averageWaitingTimeOnTrafficLight(tl).seconds());
setColoredTimeText(waitingTimeDiff, comparator.compareWaitingTimeOnTrafficLight(tl));
setColoredTimePercent(waitingTimePercent, comparator.compareWaitingTimeOnTrafficLightPercent(tl));
}
});
roadComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
String id = newValue.getText();
Road r = mapDatabase.getRoad(id);
setTimeText(roadDriving1, eval1.averageDrivingTimeOnRoad(r).seconds());
setTimeText(roadDriving2, eval2.averageDrivingTimeOnRoad(r).seconds());
setColoredTimeText(roadDrivingDiff, comparator.compareDrivingTimeOnRoad(r));
setColoredTimePercent(roadDrivingPercent, comparator.compareDrivingTimeOnRoadPercent(r));
}
});
}
Aggregations