else
addedRoadsideUnit.setHidden(false);
}
}
else if (arg instanceof TrafficLight) {
TrafficLight addedTrafficLight = (TrafficLight) arg;
String id = addedTrafficLight.getID();
String type = addedTrafficLight.getPrettyName();
Double latitude = GlobalPosition.from(Point2DUtils.convertPoint(addedTrafficLight.getPosition()))
.getLatitude();
Double longitude = GlobalPosition.from(Point2DUtils.convertPoint(addedTrafficLight.getPosition()))
.getLongitude();
String speed = "N/A";
String direction = "N/A";
String coveredDistance = "N/A";
String communicationCount = addedTrafficLight.getSentCount() + "/" + addedTrafficLight.getReceivedCount();
Object[] addedData = new Object[] { id, type, latitude, longitude, speed, direction, coveredDistance,
communicationCount };
// Add a new model to the table
if (!modelsToRows.containsKey(addedTrafficLight.getID())) {
tableModel.addRow(addedData);
modelsToRows.put(addedTrafficLight.getID(), tableModel.getRowCount() - 1);
tableModel.setValueAt(true, modelsToRows.get(addedTrafficLight.getID()), columns.get("Annotation"));
tableModel.setValueAt(true, modelsToRows.get(addedTrafficLight.getID()), columns.get("Radius"));
tableModel.setValueAt(false, modelsToRows.get(addedTrafficLight.getID()), columns.get("Destination"));
tableModel.setValueAt(false, modelsToRows.get(addedTrafficLight.getID()), columns.get("V2X-Tracing"));
tableModel.setValueAt(false, modelsToRows.get(addedTrafficLight.getID()), columns.get("Hide"));
updateGlobalSettings(modelsToRows.get(addedTrafficLight.getID()),
modelsToRows.get(addedTrafficLight.getID()));
}
// Modify an existing model in the table
else {
tableModel.setValueAt(id, modelsToRows.get(addedTrafficLight.getID()), columns.get("ID"));
tableModel.setValueAt(type, modelsToRows.get(addedTrafficLight.getID()), columns.get("Type"));
tableModel.setValueAt(latitude, modelsToRows.get(addedTrafficLight.getID()), columns.get("Latitude"));
tableModel.setValueAt(longitude, modelsToRows.get(addedTrafficLight.getID()), columns.get("Longitude"));
tableModel.setValueAt(communicationCount, modelsToRows.get(addedTrafficLight.getID()),
columns.get("# Sent/Received"));
Boolean displayAnnotations = (Boolean) tableModel.getValueAt(
modelsToRows.get(addedTrafficLight.getID()), columns.get("Annotation"));
if (displayAnnotations)
addedTrafficLight.setDisplayingAnnotations(true);
else
addedTrafficLight.setDisplayingAnnotations(false);
Boolean displayRadius = (Boolean) tableModel.getValueAt(modelsToRows.get(addedTrafficLight.getID()),
columns.get("Radius"));
if (displayRadius)
addedTrafficLight.setDisplayingRadius(true);
else
addedTrafficLight.setDisplayingRadius(false);
Boolean displayDestination = (Boolean) tableModel.getValueAt(
modelsToRows.get(addedTrafficLight.getID()),
columns.get("Destination"));
if (displayDestination)
addedTrafficLight.setDisplayingDestination(true);
else
addedTrafficLight.setDisplayingDestination(false);
Boolean v2xTracing = (Boolean) tableModel.getValueAt(modelsToRows.get(addedTrafficLight.getID()),
columns.get("V2X-Tracing"));
if (v2xTracing)
addedTrafficLight.setV2XTracing(true);
else
addedTrafficLight.setV2XTracing(false);
Boolean hidden = (Boolean) tableModel.getValueAt(modelsToRows.get(addedTrafficLight.getID()),
columns.get("Hide"));
if (hidden)
addedTrafficLight.setHidden(true);
else
addedTrafficLight.setHidden(false);
}
}
}