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