Skip to content
Snippets Groups Projects
Commit 33b5496f authored by HSoreide's avatar HSoreide
Browse files

Remove unused import statements

parent 07b8f7a8
No related branches found
No related tags found
1 merge request!46Hs add javadoc to food controllers
Pipeline #219011 passed
Showing
with 12 additions and 40 deletions
......@@ -109,7 +109,7 @@ public class AddIngredientController implements Initializable {
}
/**
* The searchList method takes in a string of what the user enetered in the search field and an array of
* The searchList method takes in a string of what the user wrote in the search field and an array of
* Strings that represents every label of the FoodItem enum class. The search word from the user is
* trimmed and split by space and matched against all the constants of the FoodItem enums. Any matches are then
* to a List of strings and returned.
......@@ -119,9 +119,7 @@ public class AddIngredientController implements Initializable {
*/
private List<String> searchList(String searchWords, String[] listOfStrings) {
String[] searchWordsArray = searchWords.trim().split(" ");
return Arrays.stream(listOfStrings).filter((in) -> {
return Arrays.stream(searchWordsArray).allMatch((word) ->
in.toLowerCase().contains(word.toLowerCase()));
}).collect(Collectors.toList());
return Arrays.stream(listOfStrings).filter((in) -> Arrays.stream(searchWordsArray).allMatch((word) ->
in.toLowerCase().contains(word.toLowerCase()))).collect(Collectors.toList());
}
}
......@@ -71,25 +71,24 @@ public class AllRecipesController implements Initializable {
ArrayList<Recipe> sortedRecipes = recipeRegister.pickBestFits(numberOfRecipes, ingredientsAtHand);
recipes = FXCollections.observableArrayList(sortedRecipes.stream().map(recipe -> {
return String.format("# %s - %d missing ingredients (%2.0f %%)", recipe.getName(), recipe.getMissingIngredients(), percent(recipe.getIngredientList().size() - recipe.getMissingIngredients(), recipe.getIngredientList().size()));
}).toList());
recipes = FXCollections.observableArrayList(sortedRecipes.stream().map(recipe -> String.format("# %s - %d missing ingredients (%2.0f %%)", recipe.getName(), recipe.getMissingIngredients(), percent(recipe.getIngredientList().size() - recipe.getMissingIngredients(), recipe.getIngredientList().size()))).toList());
}
allList.setItems(recipes);
allList.setOnMouseClicked(new EventHandler<MouseEvent>() {
allList.setOnMouseClicked(new EventHandler<>() {
/**
* The handler method takes a MouseEvent(Mouse Click) and uses the list item that was subjected to the
* mouse click and extracts the recipe name. That name as a String is then passed to the method
* 'showRecipe' that loads the view Recipe.fxml to display this particular recipe in full detail.
*
* @param mouseEvent A mouse event, in this case a MouseClicked event.
*/
@Override
public void handle(MouseEvent mouseEvent) {
selectedRecipeName = allList.getSelectionModel()
.getSelectedItem().split("-|#")[1].strip();
.getSelectedItem().split("[-#]")[1].strip();
try {
showRecipe(selectedRecipeName);
} catch (IOException e) {
......
package no.ntnu.idatt1002.demo.controller;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import no.ntnu.idatt1002.demo.data.Budget.BudgetItem;
import java.net.URL;
import java.util.ResourceBundle;
/**
* The BudgetBarController manages the component view BudgetBar.fxml that may be dynamically loaded to other views.
......
......@@ -13,7 +13,6 @@ import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import no.ntnu.idatt1002.demo.data.Budget.FileHandlingBudget;
import no.ntnu.idatt1002.demo.data.Budget.FileHandlingSelectedBudget;
import no.ntnu.idatt1002.demo.data.Economics.Expense;
......
package no.ntnu.idatt1002.demo.controller;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.time.LocalDate;
import java.util.Optional;
import javafx.collections.ObservableList;
import javafx.scene.chart.PieChart;
import javafx.scene.chart.PieChart.Data;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
......
......@@ -27,8 +27,9 @@ public class IngredientTileController {
public void setData(RecipeIngredient ingredient) {
StringBuilder sb = new StringBuilder();
sb.append("# ").append(ingredient.getFoodType().label.substring(0,1).toUpperCase())
.append(ingredient.getFoodType().label.substring(1));
sb.append(" ").append(ingredient.getAmount()).append(" ").append(ingredient.getUnit().label);
.append(ingredient.getFoodType().label.substring(1)).append(" ")
.append(ingredient.getAmount()).append(" ")
.append(ingredient.getUnit().label);
text.setText(String.valueOf(sb));
}
}
......@@ -3,12 +3,7 @@ package no.ntnu.idatt1002.demo.controller;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
......@@ -32,12 +27,10 @@ import no.ntnu.idatt1002.demo.data.Budget.BudgetItem;
import no.ntnu.idatt1002.demo.data.Budget.FileHandlingBudget;
import no.ntnu.idatt1002.demo.data.Budget.FileHandlingSelectedBudget;
import no.ntnu.idatt1002.demo.data.Budget.GeneralBudget;
import no.ntnu.idatt1002.demo.data.Economics.ExpenseCategory;
import no.ntnu.idatt1002.demo.data.Economics.ExpenseRegister;
import no.ntnu.idatt1002.demo.data.Economics.FileHandling;
import no.ntnu.idatt1002.demo.data.Economics.IncomeRegister;
import no.ntnu.idatt1002.demo.data.Economics.Overview;
import no.ntnu.idatt1002.demo.data.recipes.Recipe;
public class MainMenu {
......
package no.ntnu.idatt1002.demo.controller;
import java.io.IOException;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
......@@ -15,7 +14,6 @@ import javafx.scene.control.Dialog;
import javafx.stage.Modality;
import javafx.stage.Screen;
import javafx.stage.Stage;
import no.ntnu.idatt1002.demo.data.Budget.FileHandlingBudget;
import no.ntnu.idatt1002.demo.data.Budget.FileHandlingSelectedBudget;
import no.ntnu.idatt1002.demo.data.Economics.Income;
......
......@@ -12,7 +12,6 @@ import javafx.scene.control.ListView;
import javafx.scene.input.MouseButton;
import javafx.stage.Stage;
import no.ntnu.idatt1002.demo.data.Budget.BudgetRegister;
import no.ntnu.idatt1002.demo.data.Budget.FileHandlingBudget;
import no.ntnu.idatt1002.demo.data.Budget.FileHandlingBudgetArchive;
import no.ntnu.idatt1002.demo.data.Budget.FileHandlingSelectedBudget;
......
......@@ -2,7 +2,6 @@ package no.ntnu.idatt1002.demo.data.Budget;
import java.util.Arrays;
import no.ntnu.idatt1002.demo.data.Economics.ExpenseCategory;
import java.time.LocalDate;
import java.time.Month;
import java.util.ArrayList;
......
......@@ -5,8 +5,6 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.time.LocalDate;
import no.ntnu.idatt1002.demo.data.Budget.FileHandlingBudget;
import no.ntnu.idatt1002.demo.data.Budget.FileHandlingSelectedBudget;
/**
......
package no.ntnu.idatt1002.demo.data.Economics;
import java.time.Year;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* ItemRegister is a generic class used
......
package no.ntnu.idatt1002.demo.data.Economics;
import no.ntnu.idatt1002.demo.data.Budget.BudgetItem;
import no.ntnu.idatt1002.demo.data.Budget.GeneralBudget;
/**
......
......@@ -2,7 +2,6 @@ package no.ntnu.idatt1002.demo.data.recipes;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
......@@ -14,7 +13,7 @@ import java.util.stream.Collectors;
*/
public class RecipeRegister {
private ArrayList<Recipe> recipes = new ArrayList<>();
private final ArrayList<Recipe> recipes = new ArrayList<>();
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment