I' trying to build an application using javafx and mvvmfx framework to compute and display CVRP Problem but when I add an event listener on a Circle, it is never triggered.
scope.subscribe("STOP_LOADED", (key, payload) -> {
stepList.clear();
stopList.clear();
Stop depot = CVRPGraph.getDepot();
stopList.add(new Circle(toUiUnit(depot.getX()), toUiUnit(depot.getY()), 3, Color.BLACK));
stopList.addAll(CVRPGraph.getClientList().stream()
.map(stop -> {
Circle circle = new Circle(toUiUnit(stop.getX()), toUiUnit(stop.getY()), 3, Color.RED);
circle.setOnMouseClicked(mouseEvent -> System.out.println(mouseEvent.getEventType().getName()));
return circle;
})
.collect(Collectors.toList()));
});
stopList is initialize like this
private final ObservableList<Circle> stopList = FXCollections.observableArrayList();
which I fullfill in the viewmodel and in the view I observe an change like this
graphViewModel.stopList().addListener((ListChangeListener<? super Circle>) change -> {
stopGroup.getChildren().clear();
stopGroup.getChildren().addAll(change.getList());
});
where stopGroup is javafx.scene.Group
@FXML
private Group stopGroup;
Circle are displayed but when I click on it nothing is print
Program screenshot What I am doing wrong ?
P.S. You can find the entire code here https://github.com/ptourneur/CapacitatedVehicleRoutingProblem but do not hesitate if you need more information thanks