I am making a GUI in Java where I am getting the data I need through SPARQL-queries. The program is about exercises, and I would like to make a container (hbox/vbox) for each exercise with relevant information. The problem is that right now, the program looks really ugly, because I am generating the hbox with pure javafx with the code below:
ResultSet result = Querying.ontologyQuery(Strings.getFeatured());
List<Resource> exerciseList = new ArrayList<>();
List<Resource> mainMuscleList = new ArrayList<>();
List<Literal> equipmentList = new ArrayList<>();
while (result.hasNext()) {
QuerySolution qs = result.next();
Resource exercise = qs.getResource("Exercise");
Resource mainMuscle = qs.getResource("mainMuscle");
Literal equipment = qs.getLiteral("Equipment");
exerciseList.add(exercise);
mainMuscleList.add(mainMuscle);
equipmentList.add(equipment);
}
for (int i = 0; i < 4; i++) {
HBox hbox = addHbox();
vbox.getChildren().add(hbox);
Label exercise = new Label();
Label mainMuscle = new Label();
Label equipment = new Label();
mainMuscle.setText(mainMuscleList.get(i).getLocalName());
equipment.setText(equipmentList.get(i).getString());
exercise.setText(exerciseList.get(i).getLocalName());
hbox.getChildren().add(exercise);
hbox.getChildren().add(mainMuscle);
hbox.getChildren().add(equipment);
I guess what I am asking, is it if it's possible to make a template sort of in fxml, and just deploy the information from the SPARQL-queries into the placeholders in the "template". Any help is appriciated on how to go about this