You have to add the components before the stage is shown and get the values after the stage is shown, i. e.:
public void start(Stage primaryStage) {
BorderPane root = new BorderPane();
graph = new Graph();
addGraphComponents();
root.setCenter(graph.getScrollPane());
Scene scene = new Scene(root, 1024, 768);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
Layout layout = new RandomLayout(graph);
layout.execute();
for( Cell cell: graph.getModel().getAllCells()) {
System.out.println(cell + ": " + cell.getBoundsInParent());
}
}
As an alternative you can invoke whatever happens after the graph creation into a Platform.runLater, i. e.:
Platform.runLater(() -> {
for( Cell cell: graph.getModel().getAllCells()) {
System.out.println(cell + ": " + cell.getBoundsInParent());
}
});