Class AllRecipesController

java.lang.Object
no.ntnu.idatt1002.demo.controller.AllRecipesController
All Implemented Interfaces:
javafx.fxml.Initializable

public class AllRecipesController extends Object implements javafx.fxml.Initializable
The AllRecipesController manages the view named AllRecipes.fxml that displays a scrollable list of all the recipes that are stored in the recipe register at 'src/main/resources/recipes/Recipes.register'. The controller holds an instance of the IngredientsAtHand class and the RecipeRegister class and combines the two to fill the list with recipes sorted by the number of ingredients that are not currently in the 'fridge' of the user. Each recipe is also lister with a percentage value that shows how many percent of the recipe's ingredients are actually in the fridge. This information is included so that recipes with a lower number of ingredients are not given an unfair advantage over others where the user may have a significant number of the ingredients available. Each listed recipe may be clicked on by the user to open it in a new view in full detail.
Author:
hannesofie
  • Constructor Details

    • AllRecipesController

      public AllRecipesController()
  • Method Details

    • initialize

      public void initialize(URL url, ResourceBundle resourceBundle)
      The initialize method of the controller takes in a URL (location) and ResourceBundle(resources) to initialize the controller once its root element has been processed. The method then reads and creates an object of the IngredientsAtHand class and one of the RecipesRegister class. If the recipe register exists, the list is filled with Strings for each recipe at the format: Recipe name - X missing ingredients (XX%) Finally, a MouseClick event and handler is attached to the list that gets the recipe name of the clicked list item and runs the method showRecipe() with that name as input to show the recipe in detail in the view Recipe.fxml.
      Specified by:
      initialize in interface javafx.fxml.Initializable
      Parameters:
      url - The location to resolve the relative paths to the root object.
      resourceBundle - Resources used to localize the root object.