diff --git a/src/main/java/mi/hdm/components/IngredientLabel.java b/src/main/java/mi/hdm/components/IngredientLabel.java index 6ecf4e866f2aee32e0e3c2269b3287b037dd8ade..7cbf7da435e4f0fda13c737bab70d40587edc7c2 100644 --- a/src/main/java/mi/hdm/components/IngredientLabel.java +++ b/src/main/java/mi/hdm/components/IngredientLabel.java @@ -1,30 +1,33 @@ package mi.hdm.components; -import javafx.scene.control.Label; import javafx.scene.layout.HBox; -import mi.hdm.recipes.Measurement; +import javafx.scene.text.Text; +import mi.hdm.recipes.RecipeComponent; public class IngredientLabel extends HBox { - - private final String name; private final int amount; - private final Measurement measurement; + private final RecipeComponent component; - public IngredientLabel(String name, int amount, Measurement measurement) { + public IngredientLabel(int amount, RecipeComponent component) { super(); - this.name = name; this.amount = amount; - this.measurement = measurement; + this.component = component; - Label labelAmount = new Label(amount + " " + measurement); - labelAmount.prefWidth(100); - Label labelName = new Label(name); - labelName.prefWidth(300); + Text labelAmount = new Text(amount + " " + component.getMeasurement()); + Text labelName = new Text(component.getName()); getChildren().addAll(labelAmount, labelName); - //setAlignment(Pos.BASELINE_LEFT); - setSpacing(5.0); - //setStyle("-fx-padding: 5px"); + setSpacing(16.0); + setStyle("-fx-padding: 5px;"); + } + + public int getAmount() { + return amount; + } + + public RecipeComponent getComponent() { + //TODO: create a copy + return component; } } diff --git a/src/main/java/mi/hdm/controllers/RecipeViewController.java b/src/main/java/mi/hdm/controllers/RecipeViewController.java index 3e161f77a2e475c34717fce8c2705158436801b7..3dbb2cfd8818bb43b8635b183fc79d83527acd2f 100644 --- a/src/main/java/mi/hdm/controllers/RecipeViewController.java +++ b/src/main/java/mi/hdm/controllers/RecipeViewController.java @@ -7,7 +7,10 @@ import javafx.scene.image.ImageView; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.VBox; import mi.hdm.components.IngredientLabel; -import mi.hdm.recipes.*; +import mi.hdm.recipes.Ingredient; +import mi.hdm.recipes.IngredientManager; +import mi.hdm.recipes.Recipe; +import mi.hdm.recipes.RecipeManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -60,11 +63,9 @@ public class RecipeViewController extends BaseController { //TODO: amount and measurement are not displayed, but without the name they are recipe.getIngredients().forEach((code, amount) -> { Ingredient i = ingredientManager.getIngredient(code).orElseThrow(); - String name = i.getName(); - Measurement measurement = i.getMeasurement(); - IngredientLabel ingredientLabel = new IngredientLabel(name, amount, measurement); - log.debug("Added ingredient label with the following values: {}, {}, {}", name, amount, measurement); + IngredientLabel ingredientLabel = new IngredientLabel(amount, i); ingredientVBox.getChildren().add(ingredientLabel); + log.debug("Added ingredient label with the following values: {}, {}, {}", i.getName(), amount, i.getMeasurement()); }); diff --git a/src/main/java/mi/hdm/recipes/CategoryManager.java b/src/main/java/mi/hdm/recipes/CategoryManager.java index 9510b86235226505b981e784137c828f85115990..2e6d1cdac24f5eb4c0200787b6d92d4f9bb29c67 100644 --- a/src/main/java/mi/hdm/recipes/CategoryManager.java +++ b/src/main/java/mi/hdm/recipes/CategoryManager.java @@ -102,6 +102,7 @@ public class CategoryManager { } public static String numberToColorCodeString(int colourCode) { + //TODO: move method into Category class, remove the # String intToHex = Integer.toHexString(colourCode); intToHex = intToHex .indent(6 - intToHex.length())