@Override
  public void layout() {

    node.getChildren().clear();

    int row = 0;
    for (View child : getChildren()) {

      Label label = new Label(child.getTitle());

      Node control = child.getNode();

      LabelStyle style = child.getProperties().labelStyle;
      if (child instanceof Group) {
        style = LabelStyle.LABEL_HIDDEN;
      }

      switch (style) {
        case LABEL_HIDDEN:
          GridPane.setRowIndex(control, row);
          GridPane.setColumnIndex(control, 1);
          GridPane.setHgrow(control, Priority.NEVER);

          node.getChildren().addAll(control);
          row++;
          break;

        case LABEL_ON_SIDE:
          GridPane.setRowIndex(label, row);
          GridPane.setColumnIndex(label, 0);
          GridPane.setHalignment(label, HPos.LEFT);
          GridPane.setRowIndex(control, row);
          GridPane.setColumnIndex(control, 1);
          GridPane.setHgrow(control, Priority.NEVER);
          GridPane.setHalignment(control, HPos.RIGHT);

          node.getChildren().addAll(label, control);
          row++;
          break;

        case LABEL_ON_TOP:
          GridPane.setRowIndex(label, row);
          GridPane.setColumnIndex(label, 0);
          GridPane.setColumnSpan(label, 2);
          GridPane.setHalignment(label, HPos.LEFT);
          GridPane.setRowIndex(control, row + 1);
          GridPane.setColumnIndex(control, 0);
          GridPane.setColumnSpan(control, 2);
          GridPane.setHgrow(control, Priority.NEVER);
          GridPane.setHalignment(control, HPos.RIGHT);

          node.getChildren().addAll(label, control);
          row += 2;
          break;

        default:
          break;
      }
    }
  }
  /** Shows this Notifications popup */
  public void show() {
    // Use a gridpane to display the component
    GridPane pane = new GridPane();
    // Need a new scene to display the popup
    Scene scene = new Scene(pane);

    // Set the padding and gaps to 5px
    pane.setPadding(new Insets(5));
    pane.setHgap(5);
    pane.setVgap(5);

    // Add the message as a label if there is one
    if (message != null) {
      Label lblMsg = new Label(message);

      lblMsg.setPadding(new Insets(20));
      pane.add(lblMsg, 0, 0, 3, 1);
    }

    // Add the yes/no buttons if there are any
    if (yesNoBtns) {
      Button btnYes = new Button("Yes");
      Button btnNo = new Button("No");

      // Add the events and set as default/cancel buttons
      btnYes.setDefaultButton(true);
      btnYes.setOnAction(yesNoEvent);
      btnNo.setCancelButton(true);
      btnNo.setOnAction(yesNoEvent);

      // Align them to the right
      GridPane.setHalignment(btnNo, HPos.RIGHT);
      GridPane.setHalignment(btnYes, HPos.RIGHT);

      // Push the buttons to the right
      Region spacer = new Region();
      GridPane.setHgrow(spacer, Priority.ALWAYS);

      pane.add(spacer, 0, 1);
      pane.add(btnNo, 1, 1);
      pane.add(btnYes, 2, 1);
    }

    // Create a new stage to show the scene
    Stage stage = new Stage();

    stage.setScene(scene);
    // Don't want the popup to be resizable
    stage.setResizable(false);
    // Set the title if there is one
    if (title != null) {
      stage.setTitle(title);
    }
    // Resize it and show it
    stage.sizeToScene();
    stage.showAndWait();
  }
  public void displayPane() throws IOException {

    addStationsToCB();

    paneTop.getColumnConstraints().add(new ColumnConstraints(60));
    paneTop.getColumnConstraints().add(new ColumnConstraints(200));
    paneTop.getColumnConstraints().add(new ColumnConstraints(100));

    paneBot.getColumnConstraints().add(new ColumnConstraints(60));
    paneBot.getColumnConstraints().add(new ColumnConstraints(200));
    paneBot.getColumnConstraints().add(new ColumnConstraints(100));

    paneCenter.getColumnConstraints().add(new ColumnConstraints(300));

    paneTop.setPadding(new Insets(10, 10, 10, 10));
    paneTop.setAlignment(Pos.CENTER);
    paneTop.setHgap(5);
    paneTop.setVgap(5);

    paneBot.setPadding(new Insets(10, 10, 10, 10));
    paneBot.setAlignment(Pos.CENTER);
    paneBot.setHgap(5);
    paneBot.setVgap(5);

    paneTop.add(new Label("Station :"), 0, 0);
    paneTop.add(cbStations, 1, 0);
    paneTop.add(btOpen, 2, 0);

    paneBot.add(new Label("Quantity :"), 0, 0);
    paneBot.add(cbQuantity, 1, 0);
    paneBot.add(btShow, 2, 0);

    paneTop.setHalignment(btOpen, HPos.RIGHT);
    paneBot.setHalignment(btShow, HPos.RIGHT);

    paneCenter.setHgap(5);
    paneCenter.setVgap(5);
    paneCenter.setAlignment(Pos.CENTER);
    sp.setContent(paneCenter);
    sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
    bp.setMargin(sp, new Insets(20, 50, 40, 50));
    bp.setTop(paneTop);
    bp.setCenter(sp);
    bp.setBottom(paneBot);

    btOpen.setOnAction(
        e -> {
          try {
            open();
          } catch (IOException er) {
            er.printStackTrace();
          }
        });

    btShow.setOnAction(e -> showGraph());
  }
  @Override // Override the start method in the Application class
  public void start(Stage primaryStage) throws Exception {
    // Create a pane and set its properties
    GridPane pane = new GridPane();
    pane.setAlignment(Pos.CENTER);
    pane.setPadding(new Insets(11.5, 12.5, 13.5, 14.5));
    pane.setHgap(5.5);
    pane.setVgap(5.5);

    // Place nodes in the pane
    pane.add(new Label("First Name:"), 0, 0);
    pane.add(new TextField(), 1, 0);
    pane.add(new Label("MI:"), 0, 1);
    pane.add(new TextField(), 1, 1);
    pane.add(new Label("Last Name:"), 0, 2);
    pane.add(new TextField(), 1, 2);
    Button btAdd = new Button("Add Name");
    pane.add(btAdd, 1, 3);
    GridPane.setHalignment(btAdd, HPos.RIGHT);

    // Create a scene and place it in the stage
    Scene scene = new Scene(pane);
    primaryStage.setTitle("ShowGridPane"); // Set the stage title
    primaryStage.setScene(scene); // Place the scene in the stage
    primaryStage.show(); // Display the stage
  }
  public InputDialog(final String title, final Object[] data) {
    initOwner(null);

    setTitle(title);

    if (0 != data.length % 2) {
      throw new IllegalArgumentException("Object data must be even!");
    }

    final Group root = new Group();
    final Scene scene = new Scene(root);
    setScene(scene);

    final GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(5);
    gridpane.setVgap(5);

    for (int i = 0; i < data.length; i++) {
      if (0 == i % 2) {
        final Label label = new Label((String) data[i]);
        gridpane.add(label, 0, i / 2);
      } else {
        gridpane.add((Node) data[i], 1, (i - 1) / 2);
      }
    }

    gridpane.add(submit, 1, data.length / 2 + 1);
    GridPane.setHalignment(submit, HPos.RIGHT);
    root.getChildren().add(gridpane);
    sizeToScene();
    show();
  }
 public SoapServiceVirtualUiMainPanel(
     final SoapServiceVirtualizeDto soap, final VirtualizationUiOptions wireMockOptions) {
   this.soap = soap;
   this.wireMockOptions = wireMockOptions;
   GridPane pane = new GridPane();
   pane.setAlignment(Pos.TOP_LEFT);
   pane.setHgap(10);
   pane.setVgap(10);
   setPadding(new Insets(5, 10, 5, 10));
   Label wsdlUrl = new Label("Wsdl URL:");
   Text requestXml = new Text("Request\nXml");
   requestXml.setTextAlignment(TextAlignment.JUSTIFY);
   Text responseXml = new Text("Response\nXml");
   responseXml.setTextAlignment(TextAlignment.JUSTIFY);
   loadWsdlButton = new MsstButton("LoadWsdl");
   wsdrlUrlTextField = new MsstTextField();
   wsdrlUrlTextField.setText(soap.getWsdlURL());
   GridPane.setHalignment(wsdrlUrlTextField, HPos.LEFT);
   Text endPointUrl = new Text("End point\nURL");
   operationList = new ComboBox<String>();
   serviceEndPointUrl = new MsstTextField();
   pane.add(wsdlUrl, 0, 1, 1, 1);
   pane.add(wsdrlUrlTextField, 1, 1, 5, 1);
   pane.add(loadWsdlButton, 6, 1, 2, 1);
   pane.add(endPointUrl, 0, 2);
   pane.add(serviceEndPointUrl, 1, 2, 5, 1);
   pane.add(operationList, 6, 2, 1, 1);
   saveButton = new MsstButton("Save Stub");
   requestTextArea = new MsstTextArea(soap.getRequestXml());
   responseTextArea = new MsstTextArea(soap.getResponseXml());
   requestTextArea.setMinWidth(300);
   responseTextArea.setMinWidth(300);
   GridPane.setHalignment(saveButton, HPos.CENTER);
   pane.add(requestXml, 0, 3, 1, 1);
   pane.add(requestTextArea, 1, 3, 2, 1);
   pane.add(responseXml, 3, 3, 1, 1);
   pane.add(responseTextArea, 4, 3, 3, 1);
   pane.add(saveButton, 0, 4, 5, 1);
   saveButton.setOnAction(saveButtonActionEvent);
   operationList.setOnAction(listActionListener);
   loadWsdlButton.setOnAction(loadWsdlActionListener);
   setFitToHeight(true);
   setFitToWidth(true);
   setContent(pane);
 }
 public static Label addMultilineLabel(GridPane gridPane, int rowIndex, String text, double top) {
   Label label = new Label(text);
   label.setWrapText(true);
   GridPane.setHalignment(label, HPos.LEFT);
   GridPane.setRowIndex(label, rowIndex);
   GridPane.setColumnSpan(label, 2);
   GridPane.setMargin(label, new Insets(top, 0, 0, 0));
   gridPane.getChildren().add(label);
   return label;
 }
  /** @@author A0125419H */
  private void addMainMenu(ArrayList<Pair<String, String>> mainMenuOptions) {
    int numCommmands = mainMenuOptions.size();
    int totalPages =
        (int)
            Math.ceil(
                numCommmands / 1.0 / UiConstants.ENTRIES_PER_PAGE_HELP_MENU); // convert to double
    int entryNo = 0;
    for (int i = 0; i < totalPages; i++) {
      GridPane newGrid = gridHelper.setUpGrid(UiConstants.GRID_SETTINGS_ACTION_HELP);
      ArrayList<StackPane> menuElements = new ArrayList<StackPane>();
      // newGrid.setGridLinesVisible(true);
      for (int j = 0; j < UiConstants.ENTRIES_PER_PAGE_HELP_MENU; j++) {
        if (entryNo >= numCommmands) {
          break;
        }
        String optionText = mainMenuOptions.get(entryNo).getKey();
        Label current =
            gridHelper.createLabelInCell(
                0, j, optionText, UiConstants.STYLE_PROMPT_SELECTED, newGrid);
        GridPane.setFillWidth(current.getParent(), false);
        GridPane.setFillHeight(current.getParent(), false);
        GridPane.setHalignment(current.getParent(), HPos.CENTER);
        if (entryNo > 0) {
          menuElements.add(gridHelper.getWrapperAtCell(0, j, newGrid));
        }
        UiTextBuilder myBuilder = new UiTextBuilder();
        myBuilder.addMarker(0, UiConstants.STYLE_PROMPT_SELECTED);

        String descriptionText = mainMenuOptions.get(entryNo).getValue();
        gridHelper.createStyledCell(1, j, "", newGrid);
        gridHelper.addTextFlowToCell(
            1, j, myBuilder.build(descriptionText), TextAlignment.LEFT, newGrid);
        GridPane.setHalignment(current.getParent(), HPos.CENTER);
        entryNo++;
      }
      helpView.addGridToPagination(newGrid, menuElements);
    }
    helpView.initializeDisplay(totalPages); // update UI and bind call back
  }
  private GridPane buildRecordingGrid(Recording recording) {
    GridPane grid = new GridPane();
    grid.setHgap(5);
    grid.setVgap(5);

    Label status = new Label();
    status.setAlignment(Pos.CENTER);
    status.setMinWidth(STATUS_MIN_WIDTH);
    updateStatusIcon(recording, status);
    recording
        .fileExistsActionProperty()
        .addListener(observable -> updateStatusIcon(recording, status));

    Label title = new Label();
    title.setMinWidth(TITLE_MIN_WIDTH);
    title.textProperty().bind(recording.fullTitleProperty());

    Label destination = new Label();
    destination.getStyleClass().add("destination");
    destination.textProperty().bind(recording.destinationProperty().asString());
    LocalDate dateArchived = recording.getDateArchived();
    if (dateArchived != null) {
      String dateArchivedText =
          String.format("Archived %s", DateUtils.formatArchivedOnDate(dateArchived));
      Tooltip tooltip = new Tooltip(dateArchivedText);
      title.setTooltip(tooltip);
      destination.setTooltip(tooltip);
    }

    ReplaceOrRenameActionBar actionBar = new ReplaceOrRenameActionBar(recording, userPrefs);
    actionBar.setMinWidth(ACTION_BAR_MIN_WIDTH);
    GridPane.setHalignment(actionBar, HPos.RIGHT);
    GridPane.setHgrow(actionBar, Priority.ALWAYS);
    GridPane.setMargin(actionBar, new Insets(0, 0, 0, 10));

    grid.add(status, 0, 0, 1, 2);
    grid.add(title, 1, 0);
    grid.add(destination, 1, 1);
    grid.add(actionBar, 2, 0, 1, 2);

    return grid;
  }
  public MyDialog(Stage owner) {
    super();
    initOwner(owner);
    setTitle("title");
    initModality(Modality.APPLICATION_MODAL);
    Group root = new Group();
    Scene scene = new Scene(root, 250, 150, Color.WHITE);
    setScene(scene);

    GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(5);
    gridpane.setVgap(5);

    Label userNameLbl = new Label("User Name: ");
    gridpane.add(userNameLbl, 0, 1);

    Label passwordLbl = new Label("Password: "******"Admin");
    gridpane.add(userNameFld, 1, 1);

    final PasswordField passwordFld = new PasswordField();
    passwordFld.setText("password");
    gridpane.add(passwordFld, 1, 2);

    Button login = new Button("Change");
    login.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            close();
          }
        });
    gridpane.add(login, 1, 3);
    GridPane.setHalignment(login, HPos.RIGHT);
    root.getChildren().add(gridpane);
  }
  /** Initializes the controller class. */
  @Override
  public void initialize(URL url, ResourceBundle rb) {
    String[] campos =
        new String[] {
          "ventas.idVenta",
          "usuarios.nombreUsu",
          "clientes.nombreCli",
          "ventas.fechaVenta",
          "ventas.descuento",
          "ventas.Num_mesa",
          "ventas.total"
        };

    String[] nombresCampos =
        new String[] {
          "id Venta",
          "nombre Usuario",
          "nombre Cliente",
          "fecha Venta",
          "descuento",
          "Mesa",
          "Total"
        };

    camposQuery =
        new String[] {
          " ventas.`idVenta` AS 'ventas.idVenta' ",
          " usuarios.`nombreUsu` AS 'usuarios.nombreUsu' ",
          " clientes.`nombreCli` AS 'clientes.nombreCli' ",
          " STR_TO_DATE(ventas.fechaVenta,'%Y-%m-%d') AS 'ventas.fechaVenta' ",
          " ventas.`descuento` AS 'ventas.descuento' ",
          " ventas.`Num_mesa` AS 'ventas.Num_mesa' ",
          " ventas.`total` AS 'ventas.total' "
        };

    lblTabla.setText("Ventas ");
    cb = new CheckBox[campos.length];
    group = new CheckBox[campos.length];
    for (int i = 0; i < campos.length; i++) {

      cb[i] = new CheckBox();

      cb[i].setText(nombresCampos[i]);
      cb[i].setId(campos[i]);
      cb[i].setStyle(
          "-fx-border-color: lightblue; "
              + "-fx-font-size: 16;"
              + "-fx-border-insets: -2;"
              + "-fx-border-radius: 2;"
              + "-fx-border-style: dotted;"
              + "-fx-border-width: 1;");

      contenedorCampos.setMargin(cb[i], new Insets(10, 0, 10, 50));
      contenedorCampos.getChildren().add(cb[i]);
      group[i] = new CheckBox();
      group[i].setText(nombresCampos[i]);
      group[i].setId(campos[i]);
      group[i].setStyle(
          "-fx-border-color: lightblue; "
              + "-fx-font-size: 16;"
              + "-fx-border-insets: -2;"
              + "-fx-border-radius: 2;"
              + "-fx-border-style: dotted;"
              + "-fx-border-width: 1;");
      contenedorAgrupar.setMargin(group[i], new Insets(10, 0, 10, 50));
      contenedorAgrupar.getChildren().add(group[i]);
    }
    checkInDatePicker = new DatePicker();

    GridPane gridPane = new GridPane();
    gridPane.setHgap(10);
    gridPane.setVgap(10);

    Label checkInlabel = new Label("DESDE:");
    gridPane.add(checkInlabel, 0, 0);

    checkInDatePicker.setValue(LocalDate.now());

    GridPane.setHalignment(checkInlabel, HPos.LEFT);
    gridPane.add(checkInDatePicker, 0, 1);
    contenedorFecha1.getChildren().add(gridPane);
    //////////////////////////////

    checkInDatePicker2 = new DatePicker();

    GridPane gridPane2 = new GridPane();
    gridPane2.setHgap(10);
    gridPane2.setVgap(10);

    Label checkInlabel2 = new Label("HASTA:");
    gridPane2.add(checkInlabel2, 0, 0);

    checkInDatePicker2.setValue(LocalDate.now());

    GridPane.setHalignment(checkInlabel2, HPos.LEFT);
    gridPane2.add(checkInDatePicker2, 0, 1);

    // vbox.getChildren().add(gridPane);
    contenedorFecha2.getChildren().add(gridPane2);
  }
  public GridPane build() {
    area = getNewGrid();

    for (int i = 0; i < eaTabs.size(); i++) {
      EATab eaTab = eaTabs.get(i);

      /*Label label = new Label(eaTab.getTabText() + "  Gen: 0");
      eaTab.fitnessGrapher.genHolder.addListener((val) -> {
      	label.setText(eaTab.getTabText() + "  Gen: " + (Integer)val);
      });*/

      final Label label = new Label(eaTab.getTabText() + "  Fit: --");
      eaTab.fitnessGrapher.fitHolder.addListener(
          (val) -> {
            label.setText(
                eaTab.getTabText() + "  Fit: " + (Math.round(((Double) val) * 100.0) / 100.0));
          });

      final Popup popup = new Popup();
      final Label popupMessage = new Label(label.getText());
      popupMessage.getStylesheets().add("./ui/css/style.css");
      popupMessage.getStyleClass().add("popup");

      label.setOnMouseEntered(
          event -> {
            popup.setAnchorX(event.getScreenX() + 20);
            popup.setAnchorY(event.getScreenY());
            popup.setAutoFix(true);
            popup.setHideOnEscape(true);
            popup.getContent().clear();
            popup.getContent().add(popupMessage);
            popup.show(GUI.stage);
          });

      label.setOnMouseExited(
          event -> {
            popup.hide();
          });

      Line line = new Line();
      line.setEndX(100);
      line.setStroke(Paint.valueOf("B4B4B4"));
      GridPane.setColumnSpan(line, 2);
      GridPane.setRowSpan(line, 1);
      GridPane.setHalignment(line, HPos.CENTER);
      GridPane.setValignment(line, VPos.CENTER);
      area.add(line, 0, i * 2 + 1);

      TetheredProgressBar progress = new TetheredProgressBar(eaTab.progressBar);

      StackPane sp = new StackPane();
      sp.getChildren().add(label);

      StackPane sp2 = new StackPane();
      sp2.getChildren().add(progress);

      VBox vbox = new VBox();
      vbox.getChildren().addAll(sp, sp2);

      HBox hbox = new HBox();

      TetheredButton button = new TetheredButton(eaTab.startButton);

      MenuButton mb = new MenuButton();
      mb.setText("...");
      MenuItem save = new MenuItem("Save");
      save.setOnAction(
          (event) -> {
            System.out.println("SAVE");
            fxController.saveEvolution(eaTab);
          });

      MenuItem close = new MenuItem("Close");
      close.setOnAction(
          (event) -> {
            fxController.closeTab(eaTab);
          });
      mb.getItems().addAll(save, close, new MenuItem("Send"));

      hbox.getChildren().addAll(button, mb);
      hbox.setSpacing(5);

      area.add(vbox, 0, i * 2);
      area.add(hbox, 1, i * 2);

      // button = null;
    }

    return area;
  }
 @FXML
 public void loadGame(ActionEvent event) {
   Stage newStage = new Stage();
   if (event.getSource() == loadButton) {
     loadData = LoadSaveGame.load();
     if (loadData != null) {
       Controller.loaded = true;
       GameController.numPasses = (int) Controller.loadData.get(4);
       // GameController.landButton.setDisable(true);
       try {
         gameRoot = FXMLLoader.load(getClass().getResource("UIFiles/MainMap.fxml"));
         gameScene = new Scene(gameRoot);
         Parent startWindow = FXMLLoader.load(getClass().getResource("UIFiles/playerStart.fxml"));
         startScene = new Scene(startWindow);
       } catch (IOException e) {
         e.printStackTrace();
       }
       newStage.setScene(gameScene);
       newStage.setTitle("Game Screen");
       newStage.show();
       GridPane grid = (GridPane) gameRoot;
       landPlots = (Land[][]) loadData.get(0);
       level = (String) loadData.get(1);
       players = (Player[]) loadData.get(3);
       for (Player player : players) {
         for (Land land : player.getLandOwned()) {
           landPlots[land.getCol()][land.getRow()].setOwner(player);
         }
       }
       if (grid != null) {
         for (Land[] landArray : landPlots) {
           for (Land land : landArray) {
             if (land.isOwned()) {
               Player owner = land.getOwner();
               Rectangle color = new Rectangle();
               color.setFill(Color.valueOf(owner.getColor()));
               color.setHeight(25);
               color.setWidth(25);
               color.setOpacity(1);
               GridPane.setHalignment(color, HPos.LEFT);
               GridPane.setValignment(color, VPos.TOP);
               grid.add(color, land.getCol(), land.getRow());
               if (land.hasMule()) {
                 Image mulePic = new Image("gameConfig/UIFiles/Media/aMule.png");
                 ImageView muleView = new ImageView();
                 muleView.setImage(mulePic);
                 muleView.setFitWidth(50);
                 muleView.setPreserveRatio(true);
                 GridPane.setHalignment(muleView, HPos.LEFT);
                 GridPane.setValignment(muleView, VPos.CENTER);
                 muleView.setId(String.valueOf(land.getCol()) + String.valueOf(land.getRow()));
                 grid.add(muleView, land.getCol(), land.getRow());
               }
             }
           }
         }
       }
       numPlayer = players.length;
       Turns turns = new Turns(players);
       turns.setRounds((int) loadData.get(5));
       GameController.beginTurn();
     } else {
       Controller.loaded = false;
     }
   }
 }
Exemple #14
0
  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 */
  }
  private void updateStatisticsData(List<TaskWithWorklogs> displayResult) {

    if (!SettingsUtil.loadSettings().isShowStatistics()) {
      return;
    }

    statisticsView.getChildren().clear();

    WorklogStatistics statistics = new WorklogStatistics();

    // generic statistics
    displayResult.forEach(
        taskWithWorklogs -> {
          statistics.getTotalTimeSpent().addAndGet(taskWithWorklogs.getTotalInMinutes());

          for (WorklogItem worklogItem : taskWithWorklogs.getWorklogItemList()) {
            String employee = worklogItem.getUserDisplayname();

            // employee total time spent
            AtomicLong totalTimeSpent = statistics.getEmployeeToTotaltimeSpent().get(employee);
            if (totalTimeSpent == null) {
              totalTimeSpent = new AtomicLong(0);
              statistics.getEmployeeToTotaltimeSpent().put(employee, totalTimeSpent);
            }
            totalTimeSpent.addAndGet(worklogItem.getDurationInMinutes());

            // distinct tasks per employee
            Set<String> totalDistinctTasks =
                statistics.getEmployeeToTotalDistinctTasks().get(employee);
            if (totalDistinctTasks == null) {
              totalDistinctTasks = new HashSet<>();
              statistics.getEmployeeToTotalDistinctTasks().put(employee, totalDistinctTasks);
            }
            totalDistinctTasks.add(taskWithWorklogs.getIssue());

            // distinct tasks per employee per project
            Map<String, Set<String>> projectToDistinctTasks =
                statistics.getEmployeeToProjectToDistinctTasks().get(employee);
            if (projectToDistinctTasks == null) {
              projectToDistinctTasks = new HashMap<>();
              statistics
                  .getEmployeeToProjectToDistinctTasks()
                  .put(employee, projectToDistinctTasks);
            }

            Set<String> distinctTasks = projectToDistinctTasks.get(taskWithWorklogs.getProject());
            if (distinctTasks == null) {
              distinctTasks = new HashSet<>();
              projectToDistinctTasks.put(taskWithWorklogs.getProject(), distinctTasks);
            }

            distinctTasks.add(taskWithWorklogs.getIssue());

            // time spent per project
            Map<String, AtomicLong> projectToTimespent =
                statistics.getEmployeeToProjectToWorktime().get(employee);
            if (projectToTimespent == null) {
              projectToTimespent = new HashMap<>();
              statistics.getEmployeeToProjectToWorktime().put(employee, projectToTimespent);
            }

            AtomicLong timespentOnProject = projectToTimespent.get(taskWithWorklogs.getProject());
            if (timespentOnProject == null) {
              timespentOnProject = new AtomicLong(0);
              projectToTimespent.put(taskWithWorklogs.getProject(), timespentOnProject);
            }

            timespentOnProject.addAndGet(worklogItem.getDurationInMinutes());
          }
        });

    // render grid and bar graph
    final AtomicInteger currentGridRow = new AtomicInteger(0);

    GridPane employeeProjectSummaryGrid = new GridPane();
    employeeProjectSummaryGrid.setHgap(5);
    employeeProjectSummaryGrid.setVgap(5);

    NumberAxis projectEmployeeXAxis = new NumberAxis();
    projectEmployeeXAxis.setLabel(FormattingUtil.getFormatted("view.statistics.timespentinhours"));
    projectEmployeeXAxis.setTickLabelRotation(90);

    NumberAxis employeeProjectXAxis = new NumberAxis();
    employeeProjectXAxis.setLabel(FormattingUtil.getFormatted("view.statistics.timespentinhours"));
    employeeProjectXAxis.setTickLabelRotation(90);

    CategoryAxis projectEmployeeYAxis = new CategoryAxis();
    CategoryAxis employeeProjectYAxis = new CategoryAxis();

    StackedBarChart<Number, String> projectEmployeeBargraph =
        new StackedBarChart<>(projectEmployeeXAxis, projectEmployeeYAxis);
    StackedBarChart<Number, String> employeeProjectBargraph =
        new StackedBarChart<>(employeeProjectXAxis, employeeProjectYAxis);

    projectEmployeeBargraph.setTitle(
        FormattingUtil.getFormatted("view.statistics.byprojectandemployee"));
    employeeProjectBargraph.setTitle(
        FormattingUtil.getFormatted("view.statistics.byemployeeandproject"));

    Set<String> projectsToDisplay = new HashSet<>();
    displayResult.forEach(
        taskWithWorklogs -> {
          projectsToDisplay.add(taskWithWorklogs.getProject());
        });
    int projectEmployeeBargraphPreferedHeight =
        HEIGHT_PER_Y_AXIS_ELEMENT * projectsToDisplay.size()
            + HEIGHT_PER_X_AXIS_ELEMENT * statistics.getEmployeeToTotaltimeSpent().keySet().size()
            + ADDITIONAL_HEIGHT;
    projectEmployeeBargraph.setPrefHeight(projectEmployeeBargraphPreferedHeight);
    VBox.setVgrow(projectEmployeeBargraph, Priority.ALWAYS);

    int employeeProjectBargraphPreferedHeight =
        HEIGHT_PER_Y_AXIS_ELEMENT * statistics.getEmployeeToProjectToWorktime().keySet().size()
            + HEIGHT_PER_X_AXIS_ELEMENT * projectsToDisplay.size()
            + ADDITIONAL_HEIGHT;
    employeeProjectBargraph.setPrefHeight(employeeProjectBargraphPreferedHeight);
    VBox.setVgrow(employeeProjectBargraph, Priority.ALWAYS);

    Map<String, XYChart.Series<Number, String>> projectNameToSeries = Maps.newHashMap();

    statistics
        .getEmployeeToProjectToWorktime()
        .keySet()
        .stream()
        .sorted(COLLATOR::compare)
        .forEach(
            employee -> {

              // employee headline label
              Set<String> totalDistinctTasksOfEmployee =
                  statistics.getEmployeeToTotalDistinctTasks().get(employee);
              Label employeeLabel =
                  getBoldLabel(
                      FormattingUtil.getFormatted(
                          "view.statistics.somethingtoamountoftickets",
                          employee,
                          totalDistinctTasksOfEmployee.size()));
              employeeLabel.setPadding(new Insets(20, 0, 0, 0));
              GridPane.setConstraints(employeeLabel, 0, currentGridRow.getAndIncrement());
              GridPane.setColumnSpan(employeeLabel, 4);
              employeeProjectSummaryGrid.getChildren().addAll(employeeLabel);

              // bar graph data container
              XYChart.Series<Number, String> projectEmployeeSeries = new XYChart.Series<>();
              projectEmployeeSeries.setName(employee);
              projectEmployeeBargraph.getData().add(projectEmployeeSeries);

              // time spent per project
              Map<String, AtomicLong> projectToWorktime =
                  statistics.getEmployeeToProjectToWorktime().get(employee);
              Map<String, Label> projectToPercentageLabel = Maps.newHashMap();

              projectToWorktime
                  .keySet()
                  .stream()
                  .sorted(COLLATOR::compare)
                  .forEach(
                      projectName -> {
                        XYChart.Series<Number, String> employeeProjectSeries =
                            projectNameToSeries.get(projectName);
                        if (employeeProjectSeries == null) {
                          employeeProjectSeries = new XYChart.Series<>();
                          employeeProjectSeries.setName(projectName);
                          employeeProjectBargraph.getData().add(employeeProjectSeries);
                          projectNameToSeries.put(projectName, employeeProjectSeries);
                        }

                        // percentage label
                        Label percentageLabel = getBoldLabel("PLACEHOLDER");
                        percentageLabel.setAlignment(Pos.CENTER_RIGHT);
                        percentageLabel.setPadding(new Insets(0, 0, 0, 20));
                        GridPane.setConstraints(percentageLabel, 1, currentGridRow.get());
                        GridPane.setHalignment(percentageLabel, HPos.RIGHT);
                        projectToPercentageLabel.put(projectName, percentageLabel);

                        // project label
                        Set<String> distinctTasksPerProject =
                            statistics
                                .getEmployeeToProjectToDistinctTasks()
                                .get(employee)
                                .get(projectName);
                        Label projectLabel =
                            getBoldLabel(
                                FormattingUtil.getFormatted(
                                    "view.statistics.somethingtoamountoftickets",
                                    projectName,
                                    distinctTasksPerProject.size()));
                        GridPane.setConstraints(projectLabel, 2, currentGridRow.get());

                        // time spent for project label
                        long timespentInMinutes = projectToWorktime.get(projectName).longValue();
                        Label timespentLabel =
                            new Label(FormattingUtil.formatMinutes(timespentInMinutes, true));
                        GridPane.setConstraints(timespentLabel, 3, currentGridRow.get());
                        GridPane.setHgrow(timespentLabel, Priority.ALWAYS);
                        GridPane.setHalignment(timespentLabel, HPos.RIGHT);

                        employeeProjectSummaryGrid
                            .getChildren()
                            .addAll(percentageLabel, projectLabel, timespentLabel);
                        currentGridRow.incrementAndGet();

                        // bargraph data
                        projectEmployeeSeries
                            .getData()
                            .add(new XYChart.Data<>(timespentInMinutes / 60d, projectName));
                        employeeProjectSeries
                            .getData()
                            .addAll(new XYChart.Data<>(timespentInMinutes / 60d, employee));
                      });

              // total time spent
              Label totalLabel =
                  getBoldLabel(FormattingUtil.getFormatted("view.statistics.totaltimespent"));
              GridPane.setConstraints(totalLabel, 0, currentGridRow.get());
              GridPane.setColumnSpan(totalLabel, 4);

              Label timespentLabel =
                  new Label(
                      FormattingUtil.formatMinutes(
                          statistics.getEmployeeToTotaltimeSpent().get(employee).get(), true));
              GridPane.setConstraints(timespentLabel, 3, currentGridRow.get());
              GridPane.setHgrow(timespentLabel, Priority.ALWAYS);
              GridPane.setHalignment(timespentLabel, HPos.RIGHT);
              employeeProjectSummaryGrid.getChildren().addAll(totalLabel, timespentLabel);

              // set label now that we can calculate the percentage
              projectToWorktime
                  .keySet()
                  .forEach(
                      projectName -> {
                        Label percentageLabel = projectToPercentageLabel.get(projectName);

                        double totalSpentTime =
                            statistics.getEmployeeToTotaltimeSpent().get(employee).doubleValue();
                        double spentTimeOnProject =
                            projectToWorktime.get(projectName).doubleValue();

                        double percentage = spentTimeOnProject / totalSpentTime;
                        String percentageFormatted = FormattingUtil.formatPercentage(percentage);
                        percentageLabel.setText(percentageFormatted);
                      });

              currentGridRow.incrementAndGet();
            });

    // employeeProjectBargraph

    statisticsView
        .getChildren()
        .addAll(employeeProjectSummaryGrid, projectEmployeeBargraph, employeeProjectBargraph);

    // custom view statistics
    addAdditionalStatistics(statisticsView, statistics, displayResult);
  }
Exemple #16
0
  // This adds the Gridpane to the Search page (displays all entrys in the database)
  public static void addSearchGrid(int loopLength) {

    GridPane grid = new GridPane();
    // padding from outer frame
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setStyle("-fx-border-color: black;");
    // Padding
    grid.setVgap(10);
    grid.setHgap(10);
    // Grid lines visible
    grid.setGridLinesVisible(true);
    grid.setMinSize(1050, 510);
    // grid.setAlignment(Pos.CENTER);

    int numCol = 0;

    for (int i = 0; i < loopLength; i++) {

      GridPane smallGrid = new GridPane();
      smallGrid.setPadding(new Insets(10, 10, 10, 10));
      smallGrid.setMinSize(510, 157);

      if (i < 5) {

        hotelContainer[i] = new GridPane();

        hotelContainer[i].setStyle("-fx-border-color: black;");
        hotelLabel[i] = new Label();
        addressLabel[i] = new Label();
        starsLabel[i] = new Label();
        //          	poolLabel[i] = new Label();
        //          	gymLabel[i] = new Label();
        //          	petsLabel[i] = new Label();
        //          	barLabel[i] = new Label();
        priceLabel[i] = new Label();

        // ny
        imgView[i] = new ImageView();
        imgView[i].setFitHeight(150);
        imgView[i].setFitWidth(120);
        smallGrid.setHalignment(imgView[i], HPos.LEFT);
        smallGrid.setColumnSpan(imgView[i], 1);
        smallGrid.setRowSpan(imgView[i], 6);

        // imgView[i].setStyle("-fx-border-color: black;");

        // hotelContainer[i].getChildren().addAll(hotelLabel [i], addressLabel [i],starsLabel[i],
        // poolLabel[i],gymLabel[i],petsLabel[i], barLabel[i],  priceLabel[i]);
        System.out.println("loopstart");
        // container.getChildren().addAll(hotelContainer[i]);

        // ny
        // smallGrid.add(imv, numCol, i);
        smallGrid.add(imgView[i], numCol, i);
        smallGrid.add(hotelLabel[i], numCol + 1, i + 1);
        smallGrid.add(addressLabel[i], numCol + 1, i + 2);
        smallGrid.add(starsLabel[i], numCol + 1, i + 3);
        //        	smallGrid.add(starsLabel[i], numCol+1, i+2);
        //        	smallGrid.add(starsLabel, numCol+1, i+3);
        smallGrid.add(priceLabel[i], numCol + 1, i + 4);

        grid.add(smallGrid, 0, i);
        System.out.println("numCol " + numCol);
        System.out.println("i " + i);

        // smallGrid.add(hotelContainer[i], 0, i);
        System.out.println("i= " + i);

        // container.setPrefHeight(156*6);//loopLength

        //	numCol++;

      } else if (i >= 5 && i <= 10) { // && i<=6

        hotelContainer[i] = new GridPane();
        //   			hotelContainer[i].setPrefHeight(156);
        //   			hotelContainer[i].setLayoutY(i*156);
        hotelContainer[i].setStyle("-fx-border-color: black;");
        hotelLabel[i] = new Label();
        // hotelLabel[i].setStyle("-fx-border-color: black;");
        addressLabel[i] = new Label();
        starsLabel[i] = new Label();
        //             	poolLabel[i] = new Label();
        //             	gymLabel[i] = new Label();
        //             	petsLabel[i] = new Label();
        //             	barLabel[i] = new Label();
        priceLabel[i] = new Label();
        priceLabel[i].setPadding(new Insets(2, 1, 1, 1));

        // ny

        imgView[i] = new ImageView();
        imgView[i].setFitHeight(150);
        imgView[i].setFitWidth(120);
        // Shadow on image
        // imgView[i].setStyle("-fx-effect: dropshadow( gaussian , gray, 1,1,1,1 )");
        smallGrid.setHalignment(imgView[i], HPos.LEFT);
        smallGrid.setColumnSpan(imgView[i], 1);
        smallGrid.setRowSpan(imgView[i], 6);

        // hotelContainer[i].getChildren().addAll(hotelLabel [i], addressLabel [i],starsLabel[i],
        // poolLabel[i],gymLabel[i],petsLabel[i], barLabel[i],  priceLabel[i]);
        System.out.println("loopstart");
        // container.getChildren().addAll(hotelContainer[i]);

        // ny
        smallGrid.add(imgView[i], numCol, i);

        // smallGrid.add(imv, numCol, i);

        smallGrid.add(hotelLabel[i], numCol + 1, i + 1);
        smallGrid.add(addressLabel[i], numCol + 1, i + 2);
        smallGrid.add(starsLabel[i], numCol + 1, i + 3);
        //           	smallGrid.add(starsLabel[i], numCol+1, i+2);
        //           	smallGrid.add(starsLabel, numCol+1, i+3);
        smallGrid.add(priceLabel[i], numCol + 1, i + 4);

        grid.add(smallGrid, 1, i - 5); // -4
        System.out.println("else if numCol =  " + numCol);
        System.out.println("else if i =  " + i);

        // smallGrid.add(hotelContainer[i], 0, i);
        System.out.println("i= " + i);

        // container.setPrefHeight(156*6);//loopLength

      } // else if statement ends
      numCol++;
    } // forloop ends

    sc = (ScrollPane) Main.scene5.lookup("#scroll");
    sc.setContent(grid);
    sc.setPadding(new Insets(30, 0, 0, 40));
  } // method ends
  public VBox getPane() {
    gp = new GridPane();
    gp.setVgap(VERTICAL_GAP);
    gp.setHgap(HORIZ_GAP);
    gp.setPadding(new Insets(0, 0, 3, 0));

    Random rand = new Random();
    questionnaireCode = Integer.toString(rand.nextInt());

    // hard coded questions for example
    Question ques1 =
        new Question(
            "111",
            "Employees need to be supervised closely or they are not likely to do their work",
            "Quality Type A");

    Question ques2 =
        new Question(
            "202",
            "Providing guidance without pressure it they key to being a good leader",
            "Quality Type B");

    Question ques3 =
        new Question(
            "097",
            "Most workers want frequent and supportive communication from their leaders",
            "Style Type A");

    Question ques4 =
        new Question("125", "People are basically competent and do a good job", "Style Type B");

    Question ques5 =
        new Question(
            "222",
            "Most workers want frequent and supportive communication from their leaders",
            "Quality Type A");

    Question ques6 =
        new Question("021", "Most employees feel insecure about their work", "Style Type A");

    Question ques7 =
        new Question(
            "435",
            "The leader is the chief judge of the achievements of the group",
            "Style Type A");

    Question ques8 =
        new Question(
            "544",
            "Leaders should allow subordinates to appraise their own work",
            "Quality Type B");

    Question ques9 =
        new Question(
            "787", "Employees must be part of the decision-making process", "Style Type B");

    data = FXCollections.observableArrayList();

    // Add a new question
    Label quesName = new Label("New Question:");

    String lastCode = Question.lastCode();
    int nextCode = Integer.parseInt(lastCode) + 1;
    final String newCode = Integer.toString(nextCode);

    TextField newQuestion = new TextField();
    newQuestion.setPromptText("Question Text");
    newQuestion.setMinWidth(350);

    // later to be a cell factory
    ComboBox<String> typeCombo = new ComboBox<String>();
    typeCombo.getItems().addAll("Quality A", "Quality B", "Style A", "Style B");
    typeCombo.setPromptText("Question Type:");

    // Button to add new questions
    Button addQuesButton = new Button("Add Question");
    gp.setHalignment(addQuesButton, HPos.RIGHT);
    addQuesButton.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            // if (addQuesButton.isSelected()) {
            //
            data.add(new Question(newCode, newQuestion.getText(), typeCombo.getValue()));

            // qName.clear();
            newQuestion.clear();
          }
        });

    Label quesChoose = new Label("Select a Question:");

    // choose question in db
    ComboBox<String> quesCombo = new ComboBox<String>();

    // to display existing questions in system:
    quesCombo.setPromptText("Existing Questions:");

    TreeMap<String, Question> questionMap = new TreeMap<String, Question>();

    for (Map.Entry<String, Question> entry : Question.getQuesMap().entrySet()) {
      String key = entry.getKey();
      Question value = entry.getValue();

      questionMap.put(entry.getValue().getQuestionText(), value);

      String question = value.getQuestionText();
      quesCombo.getItems().add(question);
    }

    // to create a new question
    Button chooseQues = new Button("Add Question");
    gp.setHalignment(chooseQues, HPos.RIGHT);
    chooseQues.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            //

            data.add(questionMap.get(quesCombo.getValue()));

            // reset combo box
            // quesCombo.setPromptText("Existing Questions:");

          }
        });

    Label or = new Label("OR");

    gp.add(quesName, 0, 0);
    gp.add(newQuestion, 1, 0);
    gp.add(typeCombo, 2, 0);
    gp.add(addQuesButton, 3, 0);
    gp.add(or, 0, 1);

    gp.add(quesChoose, 0, 2);
    gp.add(quesCombo, 1, 2);
    gp.add(chooseQues, 3, 2);

    // Create a table with columns to display Organization information
    TableView<Question> table = new TableView<Question>();
    table.setEditable(true);

    TableColumn<Question, String> actionDelete = new TableColumn<Question, String>("Remove");
    actionDelete.setCellValueFactory(new PropertyValueFactory<Question, String>("OrgCode"));

    // Create button to delete records
    Callback<TableColumn<Question, String>, TableCell<Question, String>> deleteColumnCellFactory =
        new Callback<TableColumn<Question, String>, TableCell<Question, String>>() {

          @Override
          public TableCell call(final TableColumn param) {
            final TableCell cell =
                new TableCell() {

                  @Override
                  public void updateItem(Object item, boolean empty) {
                    super.updateItem(item, empty);
                    if (empty) {
                      setText(null);
                      setGraphic(null);
                    } else {
                      final Button deleteButton = new Button("Remove");
                      deleteButton.setOnAction(
                          new EventHandler<ActionEvent>() {

                            @Override
                            public void handle(ActionEvent event) {
                              param.getTableView().getSelectionModel().select(getIndex());

                              Question item = table.getSelectionModel().getSelectedItem();

                              // if (orgCode != null) {
                              // Confirmation of record deletion
                              Alert alert = new Alert(AlertType.CONFIRMATION);
                              alert.setTitle("ALERT");
                              alert.setHeaderText(
                                  "Please confirm that you would like to delete this record");
                              // alert.setContentText("Are you ok with this?");

                              ButtonType buttonTypeOne = new ButtonType("Cancel");
                              ButtonType buttonTypeTwo = new ButtonType("OK");

                              alert
                                  .showAndWait()
                                  .ifPresent(
                                      response -> {
                                        if (response == ButtonType.OK) {
                                          // code to
                                          // delete
                                          // record
                                          data.remove(item);
                                          table.getSelectionModel().clearSelection();
                                        } else {
                                          return;
                                        }
                                      });
                              // }
                            }
                          });
                      setGraphic(deleteButton);
                      setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
                    }
                  }
                };
            return cell;
          }
        };
    // Add delete button to table cell
    actionDelete.setCellFactory(deleteColumnCellFactory);

    TableColumn<Question, String> quesCode = new TableColumn<Question, String>("Code");
    quesCode.setMinWidth(50);
    quesCode.setCellValueFactory(new PropertyValueFactory<Question, String>("questionCode"));

    TableColumn<Question, String> quesText = new TableColumn<Question, String>("Text");
    quesText.setMinWidth(600);
    quesText.setCellValueFactory(new PropertyValueFactory<Question, String>("questionText"));

    TableColumn<Question, String> quesType = new TableColumn<Question, String>("Type");
    quesType.setMinWidth(150);
    quesType.setCellValueFactory(new PropertyValueFactory<Question, String>("questionType"));

    // Set the items from the ArrayList into the table
    table.setItems(data);
    table.getColumns().addAll(actionDelete, quesCode, quesText, quesType);
    table.setVisible(true);

    Button showQuestionnaire = new Button("Save This Questionnaire and View");
    gp.setHalignment(showQuestionnaire, HPos.RIGHT);
    showQuestionnaire.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            //
            MainMenu.addMap(questionnaireCode, data);
            qv = new QuestionnaireView(data);
            MainMenu.changePane(qv.getPane());
          }
        });

    // Create a vertical box that will display the table and search area
    vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(label, gp, table, showQuestionnaire);

    return vbox;
  }
  public GridPaneSample() {

    VBox vbox = new VBox();

    // grid1 places the child by specifying the rows and columns in
    // GridPane.setContraints()
    Label grid1Caption =
        new Label(
            "The example below shows GridPane content placement by specifying rows and columns:");
    grid1Caption.setWrapText(true);
    GridPane grid1 = new GridPane();
    grid1.setHgap(4);
    grid1.setVgap(6);
    grid1.setPadding(new Insets(18, 18, 18, 18));
    ObservableList<Node> content = grid1.getChildren();

    Label label = new Label("Name:");
    GridPane.setConstraints(label, 0, 0);
    GridPane.setHalignment(label, HPos.RIGHT);
    content.add(label);

    label = new Label("John Q. Public");
    GridPane.setConstraints(label, 1, 0, 2, 1);
    GridPane.setHalignment(label, HPos.LEFT);
    content.add(label);

    label = new Label("Address:");
    GridPane.setConstraints(label, 0, 1);
    GridPane.setHalignment(label, HPos.RIGHT);
    content.add(label);

    label = new Label("12345 Main Street, Some City, CA");
    GridPane.setConstraints(label, 1, 1, 5, 1);
    GridPane.setHalignment(label, HPos.LEFT);
    content.add(label);

    vbox.getChildren().addAll(grid1Caption, grid1, new Separator());

    // grid2 places the child by influencing the rows and columns themselves
    // via GridRowInfo and GridColumnInfo. This grid uses the preferred
    // width/height and max/min width/height.
    Label grid2Caption =
        new Label(
            "The example below shows GridPane content placement by influencing the rows and columns themselves.");
    grid2Caption.setWrapText(true);
    grid2Caption.setWrapText(true);
    GridPane grid2 = new GridPane();
    grid2.setPadding(new Insets(18, 18, 18, 18));
    RowConstraints rowinfo = new RowConstraints(40, 40, 40);
    ColumnConstraints colinfo = new ColumnConstraints(90, 90, 90);

    for (int i = 0; i <= 2; i++) {
      grid2.getRowConstraints().add(rowinfo);
    }

    for (int j = 0; j <= 2; j++) {
      grid2.getColumnConstraints().add(colinfo);
    }

    Label category = new Label("Category:");
    GridPane.setHalignment(category, HPos.RIGHT);
    Label categoryValue = new Label("Wines");
    Label company = new Label("Company:");
    GridPane.setHalignment(company, HPos.RIGHT);
    Label companyValue = new Label("Acme Winery");
    Label rating = new Label("Rating:");
    GridPane.setHalignment(rating, HPos.RIGHT);
    Label ratingValue = new Label("Excellent");

    ImageView imageView = new ImageView(ICON_48);
    GridPane.setHalignment(imageView, HPos.CENTER);

    // Place content
    GridPane.setConstraints(category, 0, 0);
    GridPane.setConstraints(categoryValue, 1, 0);
    GridPane.setConstraints(company, 0, 1);
    GridPane.setConstraints(companyValue, 1, 1);
    GridPane.setConstraints(imageView, 2, 1);
    GridPane.setConstraints(rating, 0, 2);
    GridPane.setConstraints(ratingValue, 1, 2);
    grid2
        .getChildren()
        .addAll(category, categoryValue, company, companyValue, imageView, rating, ratingValue);

    vbox.getChildren().addAll(grid2Caption, grid2, new Separator());

    // grid3 places the child by influencing the rows and columns
    // via GridRowInfo and GridColumnInfo. This grid uses the percentages
    Label grid3Caption =
        new Label(
            "The example below shows GridPane content placement by influencing row and column percentages.  Also, grid lines are made visible in this example.  The lines can be helpful in debugging.");
    grid3Caption.setWrapText(true);
    GridPane grid3 = new GridPane();
    grid3.setPadding(new Insets(18, 18, 18, 18));
    grid3.setGridLinesVisible(true);
    RowConstraints rowinfo3 = new RowConstraints();
    rowinfo3.setPercentHeight(50);

    ColumnConstraints colInfo2 = new ColumnConstraints();
    colInfo2.setPercentWidth(25);

    ColumnConstraints colInfo3 = new ColumnConstraints();
    colInfo3.setPercentWidth(50);

    grid3.getRowConstraints().add(rowinfo3); // 2*50 percent
    grid3.getRowConstraints().add(rowinfo3);

    grid3.getColumnConstraints().add(colInfo2); // 25 percent
    grid3.getColumnConstraints().add(colInfo3); // 50 percent
    grid3.getColumnConstraints().add(colInfo2); // 25 percent

    Label condLabel = new Label(" Member Name:");
    GridPane.setHalignment(condLabel, HPos.RIGHT);
    GridPane.setConstraints(condLabel, 0, 0);
    Label condValue = new Label("MyName");
    GridPane.setMargin(condValue, new Insets(0, 0, 0, 10));
    GridPane.setConstraints(condValue, 1, 0);

    Label acctLabel = new Label("Member Number:");
    GridPane.setHalignment(acctLabel, HPos.RIGHT);
    GridPane.setConstraints(acctLabel, 0, 1);
    TextField textBox = new TextField("Your number");
    GridPane.setMargin(textBox, new Insets(10, 10, 10, 10));
    GridPane.setConstraints(textBox, 1, 1);

    Button button = new Button("Help");
    GridPane.setConstraints(button, 2, 1);
    GridPane.setMargin(button, new Insets(10, 10, 10, 10));
    GridPane.setHalignment(button, HPos.CENTER);

    GridPane.setConstraints(condValue, 1, 0);
    grid3.getChildren().addAll(condLabel, condValue, button, acctLabel, textBox);

    vbox.getChildren().addAll(grid3Caption, grid3);

    getChildren().add(vbox);
  }
Exemple #19
0
  /** リザルト画面を生成する。 */
  public ResultScreen() {
    // スペースキー押下時にタイトル画面に切り替えるようにする。
    setOnKeyTyped(
        event -> {
          // KeyTyped イベントの場合は KeyCode を得られないので,Character で判定する。
          if (event.getCharacter().equals(" ")) {
            Main.changeScreen(0);
          }
        });
    setFocusTraversable(true);

    // ゲーム情報の最終値を取得する。
    long score = GameContext.getScore();
    long lifeBonus = GameContext.getLifeCount() * Configuration.SCORE_PER_LIFE;
    GameContext.addScore(lifeBonus);
    long totalScore = GameContext.getScore();

    // ランクを計算する。
    String rank;
    if (totalScore >= Configuration.SCORE_BORDER_OF_RANK_S) {
      rank = "S";
    } else if (totalScore >= Configuration.SCORE_BORDER_OF_RANK_A) {
      rank = "A";
    } else if (totalScore >= Configuration.SCORE_BORDER_OF_RANK_B) {
      rank = "B";
    } else if (totalScore >= Configuration.SCORE_BORDER_OF_RANK_C) {
      rank = "C";
    } else if (totalScore >= Configuration.SCORE_BORDER_OF_RANK_D) {
      rank = "D";
    } else {
      rank = "E";
    }

    // 画面に表示するテキストを生成する。
    Text resultCaptionText = createText("CONGRATULATION!!", 100, Color.GREENYELLOW);
    Text scoreCaptionText = createText("SCORE", 50, Color.GREENYELLOW);
    Text scoreText = createText(Long.toString(score), "monospace", 50, Color.GREENYELLOW);
    Text lifeBonusCaptionText = createText("LIFE BONUS", 50, Color.GREENYELLOW);
    Text lifeBonusText = createText(Long.toString(lifeBonus), "monospace", 50, Color.GREENYELLOW);
    Text totalScoreCaptionText = createText("TOTAL SCORE", 50, Color.GREENYELLOW);
    Text totalScoreText = createText(Long.toString(totalScore), "monospace", 50, Color.GREENYELLOW);
    Text rankCaptionText = createText("RANK", 50, Color.GREENYELLOW);
    Text rankText = createText(rank, 50, Color.GREENYELLOW);

    // 区切り線を生成する。
    VBox[] partitionPanes = new VBox[3];
    IntStream.range(0, partitionPanes.length)
        .forEach(
            i -> {
              partitionPanes[i] = new VBox();
              partitionPanes[i].setPrefHeight(Configuration.PARTITION_HEIGHT);
              partitionPanes[i].setStyle("-fx-background-color: greenyellow;");
            });

    // テキスト,および区切り線をグリッドペインに配置する。
    GridPane gridPane = new GridPane();
    GridPane.setHalignment(resultCaptionText, HPos.CENTER);
    GridPane.setHalignment(scoreText, HPos.RIGHT);
    GridPane.setHalignment(lifeBonusText, HPos.RIGHT);
    GridPane.setHalignment(totalScoreText, HPos.RIGHT);
    GridPane.setHalignment(rankText, HPos.CENTER);
    GridPane.setHgrow(scoreCaptionText, Priority.ALWAYS);
    gridPane.add(resultCaptionText, 0, 0, 2, 1);
    gridPane.add(partitionPanes[0], 0, 1, 2, 1);
    gridPane.add(scoreCaptionText, 0, 2);
    gridPane.add(scoreText, 1, 2);
    gridPane.add(lifeBonusCaptionText, 0, 3);
    gridPane.add(lifeBonusText, 1, 3);
    gridPane.add(partitionPanes[1], 0, 4, 2, 1);
    gridPane.add(totalScoreCaptionText, 0, 5);
    gridPane.add(totalScoreText, 1, 5);
    gridPane.add(rankCaptionText, 0, 6);
    gridPane.add(rankText, 1, 6);
    gridPane.add(partitionPanes[2], 0, 7, 2, 1);

    // グリッドペインをスタックペインに配置する。
    // こうすることで,グリッドペインが画面の中央に配置される。
    StackPane stackPane = new StackPane(new Group(gridPane));
    stackPane.setPrefSize(Configuration.SCREEN_WIDTH, Configuration.SCREEN_HEIGHT);
    stackPane.setStyle("-fx-background-color: black;");

    // 画面にスタックペインを配置する。
    getChildren().add(stackPane);
  }