package mi.hdm.controllers; import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.AnchorPane; import mi.hdm.recipes.Recipe; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class RecipeViewController extends BaseController { private static final Logger log = LogManager.getLogger(RecipeViewController.class); private final Recipe recipe; @FXML private AnchorPane parent; // @FXML //private Label recipeDescription; @FXML private Label recipeName; @FXML private ImageView recipeImage; public RecipeViewController(Recipe recipe) { this.recipe = recipe; } @FXML public void changeSceneToMain() { try { changeScene(View.MAIN); } catch (Exception e) { e.printStackTrace(); log.error("Something went wrong when changing the scene."); } } @FXML public void initialize() { loadHeader(parent); recipeName.setText(recipe.getName()); //recipeDescription.setText(recipe.getDescription()); //TODO: display recipe description, preparation and ingredients //idea for solution from: https://stackoverflow.com/questions/22710053/how-can-i-show-an-image-using-the-imageview-component-in-javafx-and-fxml log.debug("Trying to load image for recipe from '{}'", recipe.getImageURL()); Image image = new Image(recipe.getImageURL().toString()); recipeImage.setImage(image); } }