/** * Adds a "grass" component to the map, aka a null component Useful if the user wants to delete a * map component they placed in the map * * @param x the x coordinate where to add the grass * @param y the y coordinate where to add the grass * @param map the map to add the grass to * @param mapGridGUIDecorator the GUI decorator associated with this map * @param mapGridPane the gridPane that would need to be updated with the new view * @param imgView the associated image to place in the x,y cell */ private void addGrass( int x, int y, Map map, MapGridGUIDecorator mapGridGUIDecorator, GridPane mapGridPane, ImageView imgView) { Coordinate coord = new Coordinate(x, y); map.clearCell(coord); StackPane sp = mapGridGUIDecorator.redrawCell(x, y, mapGridPane); sp.setOnMouseClicked( click -> { ComponentType currentFocused = MapMakerController.getCurrentFocused(); if (currentFocused == ComponentType.INTERSECTION) { addIntersection(x, y, map, mapGridGUIDecorator, mapGridPane, intersectionImgView); } else if (currentFocused == ComponentType.ROADNS) { addRoadNS(x, y, map, mapGridGUIDecorator, mapGridPane, roadNSImgView); } else if (currentFocused == ComponentType.ROADEW) { addRoadEW(x, y, map, mapGridGUIDecorator, mapGridPane, roadEWImgView); } }); // put focus back on Grass MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.GRASS); imgView.requestFocus(); }
/** * Adds a section of road with 2 lanes that travels in the directions east and west * * @param x the x coordinate where to add the road * @param y the y coordinate where to add the road * @param map the map to add the road to * @param mapGridGUIDecorator the GUI decorator associated with this map * @param mapGridPane the gridPane that would need to be updated with the new view * @param imgView the associated image to place in the x,y cell */ private void addRoadEW( int x, int y, Map map, MapGridGUIDecorator mapGridGUIDecorator, GridPane mapGridPane, ImageView imgView) { Coordinate coord = new Coordinate(x, y); Road road = new Road(coord, coord); try { road.addLane(new Lane(coord, coord, MapDirection.EAST)); road.addLane(new Lane(coord, coord, MapDirection.WEST)); map.addRoad(road); StackPane sp = mapGridGUIDecorator.redrawCell(x, y, mapGridPane); sp.setOnMouseClicked( click -> { ComponentType currentFocused = MapMakerController.getCurrentFocused(); if (currentFocused == ComponentType.INTERSECTION) { addIntersection(x, y, map, mapGridGUIDecorator, mapGridPane, intersectionImgView); } else if (currentFocused == ComponentType.ROADNS) { addRoadNS(x, y, map, mapGridGUIDecorator, mapGridPane, roadNSImgView); } else if (currentFocused == ComponentType.GRASS) { addGrass(x, y, map, mapGridGUIDecorator, mapGridPane, grassImgView); } }); // put focus back on RoadEW MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.ROADEW); imgView.requestFocus(); } catch (Exception e) { e.printStackTrace(); } }
public ConfigurationsDialogBuilder create( DependencyDotFileGenerator dependencyDotFileGenerator, GradleScriptPreferences preferences, Os os, String outputFileName) { this.outputFileName = outputFileName; this.dependencyDotFileGenerator = dependencyDotFileGenerator; this.preferences = preferences; this.os = os; dialog = new ConfigurationChoiceDialog(this); dialog.setResizable(true); dialog.initStyle(UTILITY); dialog.initModality(APPLICATION_MODAL); dialog.setIconified(false); dialog.centerOnScreen(); dialog.borderPanel = BorderPaneBuilder.create().styleClass("dialog").build(); dialog.stackPane = new StackPane(); StackPane stackPane = dialog.stackPane; dialog.log = new TextArea(); TextArea log = dialog.log; BorderPane borderPanel = dialog.borderPanel; // message dialog.configurationsBox = new VBox(); VBox configurationsBox = dialog.configurationsBox; dialog.configurationsBox = configurationsBox; dialog.progressIndicator = new ProgressIndicator(); ProgressIndicator progressIndicator = dialog.progressIndicator; stackPane.getChildren().add(log); stackPane.getChildren().add(progressIndicator); progressIndicator.setPrefSize(50, 50); progressIndicator.setMaxSize(50, 50); configurationsBox.setSpacing(15); configurationsBox.setAlignment(CENTER_LEFT); dialog.scrollPane = new ScrollPane(); ScrollPane scrollPane = dialog.scrollPane; scrollPane.setContent(configurationsBox); dialog.borderPanel.setCenter(stackPane); BorderPane.setAlignment(configurationsBox, CENTER_LEFT); BorderPane.setMargin(configurationsBox, new Insets(MARGIN, MARGIN, MARGIN, 2 * MARGIN)); // buttons dialog.buttonsPanel = new HBox(); final HBox buttonsPanel = dialog.buttonsPanel; buttonsPanel.setSpacing(MARGIN); buttonsPanel.setAlignment(BOTTOM_CENTER); BorderPane.setMargin(buttonsPanel, new Insets(0, 0, 1.5 * MARGIN, 0)); borderPanel.setBottom(buttonsPanel); borderPanel .widthProperty() .addListener( new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) { buttonsPanel.layout(); } }); dialog.scene = new Scene(borderPanel); dialog.setScene(dialog.scene); URL resource = ConfigurationsDialogBuilder.class.getResource( "/com/nurflugel/gradle/ui/dialogservice/dialog.css"); String externalForm = resource.toExternalForm(); // dialog.borderPanel.styleClass("dialog"); dialog.getScene().getStylesheets().add(externalForm); return this; }
/** * Draws the MapMaker screen and displays it to the user * * @param primaryStage the stage to show it in * @throws Exception */ public void drawScreen(Stage primaryStage) throws Exception { // Create the base BorderPane for the whole window BorderPane borderPane = new BorderPane(); borderPane.setStyle("-fx-background-color: papayawhip"); // Add some instructions to the user String text = "Instructions:\n" + "1. Click on the map component that you would like to place in the map\n" + "2. Click on the place in the map where you want to place the component\n" + "3. Repeat until you built the map you want!\n" + "4. Hit the 'Save' button when you are done"; Label instructions = new Label(text); instructions.setFont(Font.font("Arial", FontWeight.BOLD, 12)); instructions.setPadding(new Insets(5, 5, 5, 5)); borderPane.setTop(instructions); // Create the blank Map Pane mapPane = new Pane(); Map map = new Map(width, height); MapGridGUIDecorator mapGridGUIDecorator = new MapGridGUIDecorator(map.getGrid()); ResizeFactor rf = ResizeFactor.getSuggestedResizeFactor(width, height); mapGridGUIDecorator.setResizeFactor(rf); GridPane mapGridPane = mapGridGUIDecorator.drawComponents(); mapGridPane.setPadding(new Insets(0, 0, 5, 5)); mapPane.getChildren().add(mapGridPane); borderPane.setCenter(mapPane); MapMakerController.setCurrentFocused(ComponentType.NOTHING); VBox sideComponents = new VBox(); /* Add "Components" label */ Label componentsLabel = new Label("Components"); componentsLabel.setFont(Font.font("Arial", FontWeight.EXTRA_BOLD, 14)); componentsLabel.setPadding(new Insets(15, 5, 0, 20)); sideComponents.getChildren().add(componentsLabel); /* Add Intersection square image */ VBox intersectionPane = new VBox(); Label intersectionLabel = new Label("Intersection"); intersectionLabel.setPadding(new Insets(5, 5, 0, 30)); intersectionLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12)); Image intersectionImg = new Image("IntersectionX.png", 60, 60, true, false); intersectionImgView = new ImageView(intersectionImg); StackPane intersectionStackPane = new StackPane(intersectionImgView); intersectionStackPane.setPadding(new Insets(0, 10, 10, 10)); intersectionPane.getChildren().add(intersectionLabel); intersectionPane.getChildren().add(intersectionStackPane); sideComponents.getChildren().add(intersectionPane); /* Add RoadNS square image */ VBox roadNSPane = new VBox(); Label roadNSLabel = new Label("Road (North-South)"); roadNSLabel.setPadding(new Insets(5, 5, 0, 15)); roadNSLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12)); Image roadNSImg = new Image("RoadBackgroundNS.png", 60, 60, true, false); roadNSImgView = new ImageView(roadNSImg); StackPane roadNSStackPane = new StackPane(roadNSImgView); roadNSStackPane.setPadding(new Insets(0, 10, 10, 10)); roadNSPane.getChildren().add(roadNSLabel); roadNSPane.getChildren().add(roadNSStackPane); sideComponents.getChildren().add(roadNSPane); /* Add RoadEW square image */ VBox roadEWPane = new VBox(); Label roadEWLabel = new Label("Road (East-West)"); roadEWLabel.setPadding(new Insets(5, 5, 0, 15)); roadEWLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12)); Image roadEWImg = new Image("RoadBackgroundEW.png", 60, 60, true, false); roadEWImgView = new ImageView(roadEWImg); StackPane roadEWStackPane = new StackPane(roadEWImgView); roadEWStackPane.setPadding(new Insets(0, 10, 10, 10)); roadEWPane.getChildren().add(roadEWLabel); roadEWPane.getChildren().add(roadEWStackPane); sideComponents.getChildren().add(roadEWPane); /* Add Grass square image to empty out cells */ VBox grassPane = new VBox(); Label grassLabel = new Label("Grass (clear square)"); grassLabel.setPadding(new Insets(5, 5, 0, 15)); grassLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12)); Image grassImg = new Image("Grass.png", 60, 60, true, false); grassImgView = new ImageView(grassImg); StackPane grassStackPane = new StackPane(grassImgView); grassStackPane.setPadding(new Insets(0, 10, 10, 10)); grassPane.getChildren().add(grassLabel); grassPane.getChildren().add(grassStackPane); sideComponents.getChildren().add(grassPane); /* Add Save, Reset buttons */ VBox buttonsPane = new VBox(); buttonsPane.setPadding(new Insets(0, 0, 0, 10)); Label toolsLabel = new Label("Tools"); toolsLabel.setFont(Font.font("Arial", FontWeight.EXTRA_BOLD, 14)); toolsLabel.setPadding(new Insets(15, 5, 5, 35)); buttonsPane.getChildren().add(toolsLabel); Insets padding = new Insets(0, 0, 5, 0); Button saveButton = new Button("Save Map"); StackPane saveButtonPane = new StackPane(saveButton); saveButtonPane.setPadding(padding); saveButton.setStyle("-fx-base:Gold"); saveButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13)); buttonsPane.getChildren().add(saveButtonPane); Button resetButton = new Button("Reset Map"); resetButton.setStyle("-fx-base:Gold"); resetButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13)); StackPane resetButtonPane = new StackPane(resetButton); resetButtonPane.setPadding(padding); buttonsPane.getChildren().add(resetButtonPane); Button backButton = new Button("Go Back"); backButton.setStyle("-fx-base:Gold"); backButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13)); StackPane backButtonPane = new StackPane(backButton); backButtonPane.setPadding(padding); buttonsPane.getChildren().add(backButtonPane); sideComponents.getChildren().add(buttonsPane); Ticker.start(); /* Add click processing for Map grid squares */ for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { Node current = getNodeFromIndex(i, j, mapGridPane); final int x = j; final int y = i; current.setOnMouseClicked( (MouseEvent click) -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.MAP_SQUARE); current.requestFocus(); }); current .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { ComponentType previous = MapMakerController.getPreviousFocused(); if (previous == ComponentType.INTERSECTION) { addIntersection( x, y, map, mapGridGUIDecorator, mapGridPane, intersectionImgView); } else if (previous == ComponentType.ROADNS) { addRoadNS(x, y, map, mapGridGUIDecorator, mapGridPane, roadNSImgView); } else if (previous == ComponentType.ROADEW) { addRoadEW(x, y, map, mapGridGUIDecorator, mapGridPane, roadEWImgView); } else if (previous == ComponentType.GRASS) { addGrass(x, y, map, mapGridGUIDecorator, mapGridPane, grassImgView); } }); } } /* Add intersection icon click processing */ DropShadow ds = new DropShadow(15, Color.BLUE); intersectionImgView.setOnMouseClicked( click -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.INTERSECTION); intersectionImgView.requestFocus(); }); intersectionImgView .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) intersectionImgView.setEffect(ds); else intersectionImgView.setEffect(null); }); /* Add roadNS icon click processing */ roadNSImgView.setOnMouseClicked( click -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.ROADNS); roadNSImgView.requestFocus(); }); roadNSImgView .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) roadNSImgView.setEffect(ds); else roadNSImgView.setEffect(null); }); /* Add roadEW icon click processing */ roadEWImgView.setOnMouseClicked( click -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.ROADEW); roadEWImgView.requestFocus(); }); roadEWImgView .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) roadEWImgView.setEffect(ds); else roadEWImgView.setEffect(null); }); /* Add grass icon click processing */ grassImgView.setOnMouseClicked( click -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.GRASS); grassImgView.requestFocus(); }); grassImgView .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) grassImgView.setEffect(ds); else grassImgView.setEffect(null); }); /* Add save button functionality */ saveButton.setOnMouseClicked( click -> { TextInputDialog nameDialog = new TextInputDialog(); nameDialog.setTitle("Save Map"); nameDialog.setHeaderText( "Please provide a name for your map (no spaces or special characters).\nSaved maps go into the /maps directory of your working directory."); nameDialog.setContentText("File name"); Button btOk = (Button) nameDialog.getDialogPane().lookupButton(ButtonType.OK); TextField textfield = nameDialog.getEditor(); Platform.runLater(() -> textfield.requestFocus()); btOk.setDisable(true); textfield .textProperty() .addListener( ((observable, oldValue, newValue) -> { btOk.setDisable(newValue.trim().isEmpty()); })); Optional<String> result = nameDialog.showAndWait(); result.ifPresent( name -> { name = name.concat(".map"); try { Map finalMap = buildAndSaveMap(map); finalMap.saveMap(name); goBack(primaryStage); } catch (Exception e) { e.printStackTrace(); } }); }); resetButton.setOnMouseClicked( click -> { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Component component = map.getAtLocation(new Coordinate(x, y)); if (component instanceof Road || component instanceof Intersection) { addGrass(x, y, map, mapGridGUIDecorator, mapGridPane, grassImgView); } } } }); backButton.setOnMouseClicked( click -> { try { goBack(primaryStage); } catch (Exception e) { e.printStackTrace(); } }); borderPane.setRight(sideComponents); Scene scene = new Scene(borderPane); primaryStage.setScene(scene); primaryStage.centerOnScreen(); primaryStage.setResizable(false); }
/** Done by Marco */ public void searchForPubs() { pubLayout.getChildren().remove(noPub); int y = 1; int x = 1; searchName = searchNameInput.getText(); searchStreet = searchStreetInput.getText(); /** End of marco's work */ /** Done by Ahmad */ if (!searchAgeInput.getText().equals("")) { searchAge = Integer.valueOf(searchAgeInput.getText()); } else searchAge = 100; pubs.getChildren().clear(); /* Random pub search */ randomPub = new Button("- Random Pub -"); randomPub.setId("randomPub-button"); randomPub.setMinWidth(230); randomPub.setMinHeight(100); Random random = new Random(); randomPub.setOnAction( (event) -> { idOfButton(random.nextInt(PubDataAccessor.pubs.size())); primaryStage.setScene(pubPage); setPubScene(); }); randomPub.setAlignment(Pos.CENTER); pubs.getChildren().add(randomPub); GridPane.setRowIndex(randomPub, 1); GridPane.setColumnIndex(randomPub, 0); /** End of Ahmad's Work */ /** Done by Shafiq & Antonino & Marco */ for (Pub pub : PubDataAccessor.pubs) { if (searchEvent && pub.eventName.isEmpty()) { continue; } if (area_checker != 2 && pub.location_id != area) { continue; } if (pub.name != null && (pub.name.toLowerCase().contains(searchName.toLowerCase())) && pub.street != null && (pub.street.toLowerCase().contains(searchStreet.toLowerCase())) && pub.age <= searchAge && pub.nrStars >= numberOfStars && pub.hasStudentDiscount >= discount && pub.hasFee <= fee) { /** End of Shafiq & Antonini & Marco's Work */ /** Done by Marco */ pubButton = new Button("- " + pub.name + " -"); pubButton.setId("pub-button"); pubButton.setMinWidth(230); pubButton.setMinHeight(100); pubButton.setOnAction( (event) -> { idOfButton(pub.id); primaryStage.setScene(pubPage); setPubScene(); }); pubButton.setStyle("-fx-background-image: url(" + "\"" + pub.picture + "\"" + "); "); pubButton.setAlignment(Pos.CENTER); pubs.getChildren().add(pubButton); GridPane.setRowIndex(pubButton, y); GridPane.setColumnIndex(pubButton, x); x++; } } if (pubs.getChildren().size() == 0) { pubLayout.getChildren().add(noPub); noPub.setId("nopubs_message"); } /* new elements */ pubs.setHgap(30); /** End of Marco's work */ }
public void setPubScene() { /** Done by Marco */ xPane.setStyle( "-fx-background-image: url(" + "\"" + Pub.getImage(Pub.getIndexById(this.id)) + "\"" + "); "); description = new StackPane(); events = new StackPane(); rating = new StackPane(); rating.setId("rating"); description.setId("description"); descriptionGrid.setId("description-text"); pubName = new Label("- " + Pub.getName(Pub.getIndexById(this.id)) + " -"); age = new Label(Pub.getAge(Pub.getIndexById(this.id)) + " years \uF000"); age.setId("infoLabel"); open = new Label(Pub.getOpening(Pub.getIndexById(this.id)) + " \uF017"); open.setId("infoLabel"); address = new Label(Pub.getAddress(Pub.getIndexById(this.id)) + " \uF124"); address.setId("infoLabel"); type = new Label(Pub.getType(Pub.getIndexById(this.id)) + " \uF005"); type.setId("infoLabel"); /** End of Marco's work */ /** Done by Aseel */ discountForStudents = new Label(Pub.getHasStudentDiscount(Pub.getIndexById(this.id)) + " \uF02D"); if (Pub.getHasStudentDiscount(Pub.getIndexById(this.id)) == 1) { discountForStudents = new Label("Discounts " + " \uF02D"); } else if (Pub.getHasStudentDiscount(Pub.getIndexById(this.id)) == 0) { discountForStudents = new Label("No Discounts " + "\uF02D"); } discountForStudents.setId("infoLabel"); entranceFees = new Label(Pub.getHasFee(Pub.getIndexById(this.id)) + "\uf153"); if (Pub.getHasFee(Pub.getIndexById(this.id)) == 1) { entranceFees = new Label("Fees " + " \uF153"); } else if (Pub.getHasFee(Pub.getIndexById(this.id)) == 0) { entranceFees = new Label("No Fees " + "\uF153"); } entranceFees.setId("infoLabel"); /** End of Aseel's work */ /** Done by Marco */ map.setMinWidth(1000); map.setMaxHeight(250); browser.load( "http://locateme.marcokoivisto.me/?lat=" + Pub.getLat(Pub.getIndexById(this.id)) + "&lon=" + Pub.getLon(Pub.getIndexById(this.id))); int nrStars = Pub.getNrStars(Pub.getIndexById(this.id)); String stars = ""; for (int i = 0; i < nrStars; i++) { stars += "\uF005 "; } rates = new Label(stars); rates.setId("ratingOfStars"); rating.getChildren().add(rates); rating.setAlignment(Pos.CENTER); xPane.add(pubName, 1, 1); descriptionGrid.add(discountForStudents, 1, 1); descriptionGrid.add(entranceFees, 2, 1); descriptionGrid.add(age, 3, 1); descriptionGrid.add(open, 4, 1); descriptionGrid.add(type, 5, 1); descriptionGrid.add(address, 6, 1); /** End of Marco's work */ /** Done by Marco */ descriptionGrid.setAlignment(Pos.CENTER); description.getChildren().addAll(descriptionGrid); eventDescriptionGrid.add(eventLabel, 1, 1); eventDescriptionGrid.add(eventPane, 1, 2); GridPane.setHalignment(eventLabel, HPos.CENTER); eventDescriptionGrid.setAlignment(Pos.CENTER); events.getChildren().addAll(eventDescriptionGrid); eventName = new Label(Pub.getEventName(Pub.getIndexById(this.id))); eventDescription = new Label(Pub.getEventDescription(Pub.getIndexById(this.id))); eventGrid.add(eventName, 1, 1); eventGrid.add(eventDescription, 1, 2); eventName.setId("eventName"); eventDescription.setId("eventDescription"); eventPane.getChildren().add(eventGrid); eventGrid.setId("event"); events.setId("eventField"); xPane.add(rating, 1, 2); xPane.add(description, 1, 3); xPane.add(map, 1, 4); if (Pub.getEventName(Pub.getIndexById(this.id)) != "") { xPane.add(events, 1, 5); } pubName.setId("pub_name"); GridPane.setHalignment(pubName, HPos.CENTER); GridPane.setValignment(pubName, VPos.TOP); GridPane.setValignment(back, VPos.TOP); GridPane.setHalignment(star, HPos.RIGHT); GridPane.setValignment(star, VPos.TOP); xPane.add(star, 1, 1); header.setFitWidth(1000); header.setPreserveRatio(true); /** End of Marco's work */ /** Done by Shafiq & Antonino */ int rate = PubDataAccessor.checkRate(this.id); star.setText(rate + " \uF08A"); /** End of Shafiq & Antonino's WORK */ }
/* ADMIN SCENE */ public void start(Stage primaryStage) throws Exception { /** Done by Marco */ primaryStage.setTitle("PubFinder"); primaryStage.setResizable(false); PubDataAccessor.PubDataAccessor(); /*Welcome scene*/ WelcomeScene.welcomeScene(); welcomeScene = WelcomeScene.welcomeScene; /*Welcome scene*/ /** End of Marcos Work */ /** Done by Shafiq and Anotnino */ /* Admin add scene*/ AdminAddScene.adminAddscene(); adminAddScene = AdminAddScene.adminAddScene; /* Admin add scene*/ /*Admin login scene*/ AdminLoginScene.adminloginscene(); adminLoginScene = AdminLoginScene.adminLoginScene; /*Admin login scene*/ /*Admin choice scene*/ AdminChoiceScene.adminchoicescene(); adminChoiceScene = AdminChoiceScene.adminChoiceScene; /*Admin choice scene*/ /* Admin Edit Scene*/ adminEditScene = AdminEditScene.editScene; /* Admin Edit Scene*/ /** End of Shafiq and Anotonino's Work */ /*Pub button scene*/ pubLayout = new StackPane(); /** Done by Ahmad */ searchNameInput = new TextField(); searchNameInput.setId("search-field"); searchNameInput.setPromptText("NAME"); /** End of Ahmad's Work */ searchStreetInput = new TextField(); searchStreetInput.setId("search-field"); searchStreetInput.setPromptText("STREET"); searchAgeInput = new TextField(); searchAgeInput.setId("search-field"); searchAgeInput.setPromptText("AGE"); /** Done by Aseel */ CheckBox searchStudentDiscount = new CheckBox("DISCOUNTS"); CheckBox searchBySpecialEvents = new CheckBox("EVENTS"); CheckBox searchWithoutFees = new CheckBox("NO FEES"); searchStudentDiscount.setId("check-search"); searchBySpecialEvents.setId("check-search"); searchWithoutFees.setId("check-search"); ComboBox searchByRating = new ComboBox( FXCollections.observableArrayList( "\uF005", "\uF005\uF005", "\uF005\uF005\uF005", "\uF005\uF005\uF005\uF005", "\uF005\uF005\uF005\uF005\uF005")); searchByRating.setTooltip(new Tooltip("RATING")); searchByRating.setPromptText("RATING"); searchByRating.setId("combo-search"); ComboBox searchByArea = new ComboBox( FXCollections.observableArrayList( "All", "Avenyn", "Linné", "Haga", "Järntorget", "Magasinsgatan", "Vasastaden", "Gamlestaden", "Heden", "Masthugget", "Stigberget", "Other")); searchByArea.setTooltip(new Tooltip("AREA")); searchByArea.setPromptText("AREA"); searchByArea.setId("combo-search"); /** End of Aseel's Work */ /** Done by Marco */ pubLayout.setId("pubs"); search = new Button("SEARCH"); search.setId("button-search"); GridPane inputGrid = new GridPane(); inputGrid.setMaxHeight(100); inputGrid.setHgap(10); inputGrid.setVgap(10); inputGrid.setId("searchGrid"); StackPane.setAlignment(inputGrid, Pos.TOP_LEFT); StackPane.setAlignment(search, Pos.TOP_RIGHT); /** End of Marco's Work */ search.setOnAction(e -> searchForPubs()); /** Done by Ahmad */ searchNameInput.setOnKeyReleased( event1 -> { if (event1.getCode() == KeyCode.ENTER) { searchForPubs(); } }); /** End of Ahmad's Work */ /** Done by Marco */ searchStreetInput.setOnKeyReleased( event2 -> { if (event2.getCode() == KeyCode.ENTER) { searchForPubs(); } }); /** End of Marco's Work */ /** Done by Ahmad */ searchAgeInput.setOnKeyReleased( event3 -> { if (event3.getCode() == KeyCode.ENTER) { searchForPubs(); } }); /** End of Ahmad's Work */ /** Done by Shafiq & Anotnino */ searchStudentDiscount.setOnAction( event4 -> { if (searchStudentDiscount.isSelected()) { discount = 1; } if (!searchStudentDiscount.isSelected()) { discount = 0; } }); searchWithoutFees.setOnAction( event5 -> { if (searchWithoutFees.isSelected()) { fee = 0; } if (!searchWithoutFees.isSelected()) { fee = 1; } }); searchBySpecialEvents.setOnAction( event6 -> { if (searchBySpecialEvents.isSelected()) { searchEvent = true; } if (!searchBySpecialEvents.isSelected()) { searchEvent = false; } }); searchByRating.setOnAction( event7 -> { if (searchByRating.getSelectionModel().isSelected(0)) { numberOfStars = 1; } else if (searchByRating.getSelectionModel().isSelected(1)) { numberOfStars = 2; } else if (searchByRating.getSelectionModel().isSelected(2)) { numberOfStars = 3; } else if (searchByRating.getSelectionModel().isSelected(3)) { numberOfStars = 4; } else if (searchByRating.getSelectionModel().isSelected(4)) { numberOfStars = 5; } }); /** End of Shafiq and Anotino's Work */ /** Done by Aseel and Antonino */ searchByArea.setOnAction( event8 -> { if (searchByArea.getSelectionModel().isSelected(0)) { area_checker = 2; } if (searchByArea.getSelectionModel().isSelected(1)) { area = 0; area_checker = 1; } else if (searchByArea.getSelectionModel().isSelected(2)) { area = 2; area_checker = 1; } else if (searchByArea.getSelectionModel().isSelected(3)) { area = 3; area_checker = 1; } else if (searchByArea.getSelectionModel().isSelected(4)) { area = 4; area_checker = 1; } else if (searchByArea.getSelectionModel().isSelected(5)) { area = 5; area_checker = 1; } else if (searchByArea.getSelectionModel().isSelected(6)) { area = 6; area_checker = 1; } else if (searchByArea.getSelectionModel().isSelected(7)) { area = 7; area_checker = 1; } else if (searchByArea.getSelectionModel().isSelected(8)) { area = 8; area_checker = 1; } else if (searchByArea.getSelectionModel().isSelected(9)) { area = 9; area_checker = 1; } else if (searchByArea.getSelectionModel().isSelected(10)) { area = 10; area_checker = 1; } else if (searchByArea.getSelectionModel().isSelected(11)) { area = 11; area_checker = 1; } }); /** End of Aeel and Antonino's Work */ /** Done by marco */ ScrollPane pubScroll = new ScrollPane(); pubScroll.setId("scroll"); pubScroll.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); pubScroll.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); pubs = new GridPane(); pubScroll.setContent(pubs); pubs.setId("pub-grid"); pubs.setAlignment(Pos.CENTER); pubLayout.getChildren().add(pubScroll); inputGrid.add(searchNameInput, 1, 1); inputGrid.add(searchStreetInput, 2, 1); inputGrid.add(searchAgeInput, 3, 1); inputGrid.add(searchByRating, 4, 1); inputGrid.add(searchByArea, 5, 1); inputGrid.add(searchStudentDiscount, 6, 1); inputGrid.add(searchBySpecialEvents, 7, 1); inputGrid.add(searchWithoutFees, 8, 1); pubLayout.getChildren().add(inputGrid); pubLayout.getChildren().add(search); noPub = new Label("No pubs found"); searchForPubs(); pubScene = new Scene(pubLayout, 1000, 600); pubScene.getStylesheets().addAll(this.getClass().getResource("style.css").toExternalForm()); /*Pub button scene*/ /*Pub scene*/ ScrollPane pubPageLayout = new ScrollPane(); pubPageLayout.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); pubPageLayout.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); pubPageLayout.setFitToWidth(true); pubPageLayout.setContent(xPane); xPane.setId("pubScene"); pubPageLayout.setId("gej"); star.setId("starButton"); eventLabel.setId("eventLabel"); /*Items*/ xPane.add(back, 1, 1); back.setId("button-logout"); back.setOnAction( (event) -> { primaryStage.setScene(pubScene); xPane .getChildren() .removeAll(description, rating, overlay, pubName, map, star, rates, events); descriptionGrid .getChildren() .removeAll(age, open, address, type, discountForStudents, entranceFees); events.getChildren().removeAll(eventDescriptionGrid); eventDescriptionGrid.getChildren().removeAll(eventLabel, eventPane); eventPane.getChildren().removeAll(eventGrid); eventGrid.getChildren().removeAll(eventName, eventDescription); star.setText("0 \uF08A"); star.setStyle( "#starButton{-fx-text-fill: #fff;} #starButton:hover{-fx-text-fill: #fff;}"); }); /** End of Marco's work */ /** Done by Shafiq & Antonino */ star.setOnAction( event -> { int rate = PubDataAccessor.checkRate(this.id); int rateUpdate = rate + 1; /** End of Shafiq & Antonino's Work */ /** Done by marco */ star.setText((rateUpdate) + " \uF004"); PubDataAccessor.updateRate(this.id); star.setStyle("-fx-text-fill: #731a2b;"); }); overlay.setHeight(header.getFitHeight()); overlay.setWidth(header.getFitWidth() + 24); overlay.setX(0); overlay.setY(0); overlay.fillProperty().set(javafx.scene.paint.Color.rgb(115, 26, 43, 0.3)); pubPage = new Scene(pubPageLayout, 1000, 600); pubPage.getStylesheets().addAll(this.getClass().getResource("style.css").toExternalForm()); /*Pub scene*/ primaryStage.setScene(welcomeScene); primaryStage.show(); Main.primaryStage = primaryStage; /** End of Marcos work */ }