Class CookBookFrame

java.lang.Object
edu.ntnu.stud.controller.framecontroller.CookBookFrame

public class CookBookFrame extends Object
Frame used to display the cook book. This is the controller class for the cookBookFrame.fxml file. The frame displays the recipes from a JSON file in a scrollable view. Each recipe is displayed with an image and a name. The user can click on the "More" button to view more information about a specific recipe.
  • Constructor Details

  • Method Details

    • setImageFromJson

      public void setImageFromJson(String filepath)
      Sets the image of a recipe with the given filepath. The method reads the JSON file to get this filepath. If the file is not found, a FileNotFoundException is thrown. The message of the exception is then logged.
      Parameters:
      filepath - The path to the JSON file containing the recipes.
      See Also:
    • readImageFromJson

      public String readImageFromJson(int i, org.json.JSONArray jsonArray)
      Nested method to read the image of a recipe from the JSON file.
      Parameters:
      i - The index of the recipe in the JSON file.
      jsonArray - The JSON array containing the recipes.
      Returns:
      The image of the recipe at the given index.
      See Also:
    • readNameOfRecipe

      public String readNameOfRecipe(int i, org.json.JSONArray jsonArray)
      Nested method to read the name of a recipe from the JSON file.
      Parameters:
      i - The index of the recipe in the JSON file.
      jsonArray - The JSON array containing the recipes.
      Returns:
      The name of the recipe at the given index.
      See Also:
    • setAddMoreButtons

      public javafx.scene.layout.HBox setAddMoreButtons(int index, org.json.JSONArray jsonArray, int rowCounter)
      Nested method to set the "Add" and "More" buttons for a recipe.
      Parameters:
      index - The index of the recipe in the JSON file.
      jsonArray - The JSON array containing the recipes.
      rowCounter - The row number of the recipe in the frame.
      Returns:
      The HBox containing the "Add" and "More" buttons for the recipe.
      See Also:
    • getCookBookFrame

      public javafx.scene.control.ScrollPane getCookBookFrame()
      Returns the CookBook frame.
      Returns:
      The CookBook frame.