示例#1
0
  @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;
      }
    }
  }
  @Override
  public void handlePerspective(
      final Message<Event, Object> action, final PerspectiveLayout perspectiveLayout) {
    if (action.messageBodyEquals(MessageUtil.INIT)) {

      perspectiveLayout.registerRootComponent(createRoot());
      GridPane.setVgrow(perspectiveLayout.getRootComponent(), Priority.ALWAYS);
      GridPane.setHgrow(perspectiveLayout.getRootComponent(), Priority.ALWAYS);

      // register left panel
      perspectiveLayout.registerTargetLayoutComponent("content0", this.content1);
      perspectiveLayout.registerTargetLayoutComponent("content1", this.content2);
      perspectiveLayout.registerTargetLayoutComponent("content2", this.content3);
      ApplicationLauncherPerspectiveMessaginTest.latch.countDown();
    } else {
      if (counter.get() > 1) {
        counter.decrementAndGet();
        context.send("id10", "message");
      } else {
        System.out.println("Perspective id12: FINISH");
        if (wait.getCount() > 0) wait.countDown();
        if (PerspectiveMessagingTestP1.wait.getCount() > 0) context.send("id10", "message");
      }
    }
  }
  private void showDialog(String title, String message, Throwable throwable) {
    Alert alert = new Alert(Alert.AlertType.ERROR);
    alert.setTitle(title);
    alert.setHeaderText(title);
    alert.setContentText(message);
    StringWriter stringWriter = new StringWriter();
    PrintWriter printwriter = new PrintWriter(stringWriter);
    throwable.printStackTrace(printwriter);
    String exceptionText = stringWriter.toString();

    Label label = new Label("The exception stacktrace was:");

    TextArea textArea = new TextArea(exceptionText);
    textArea.setEditable(false);
    textArea.setWrapText(true);

    textArea.setMaxWidth(Double.MAX_VALUE);
    textArea.setMaxHeight(Double.MAX_VALUE);
    GridPane.setVgrow(textArea, Priority.ALWAYS);
    GridPane.setHgrow(textArea, Priority.ALWAYS);

    GridPane expContent = new GridPane();
    expContent.setMaxWidth(Double.MAX_VALUE);
    expContent.add(label, 0, 0);
    expContent.add(textArea, 0, 1);

    alert.getDialogPane().setExpandableContent(expContent);
    alert.showAndWait();
  }
  /** 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 add(String label, Node... nodes) {
   if (label == null) throw new IllegalArgumentException("label is null");
   if (nodes == null) throw new IllegalArgumentException("node is null");
   Label l = new Label(label);
   GridPane.setConstraints(l, 0, rowc);
   for (int i = 0; i < nodes.length; i++) GridPane.setConstraints(nodes[i], i + 1, rowc);
   GridPane.setHgrow(nodes[nodes.length - 1], Priority.SOMETIMES);
   grid.getChildren().add(l);
   grid.getChildren().addAll(nodes);
   rowc++;
 }
  public AddEditCredentialView(Credential credential) {
    super();
    Label domainLabel = new Label("Domain:");
    domainText = new TextField();
    domainText.setPrefWidth(250);
    domainText.setText(credential != null ? credential.getDomainName() : "");
    domainText.setPromptText("Domain");
    Platform.runLater(domainText::requestFocus);

    Label usernameLabel = new Label("Username:"******"");
    usernameText.setPromptText("Username");

    Label passwordLabel = new Label("Password:"******"");
    passwordText.setPromptText("Password");

    setHgap(10);
    setVgap(10);

    setPadding(new Insets(8, 8, 8, 8));

    add(domainLabel, 0, 0);
    add(domainText, 1, 0);
    add(usernameLabel, 0, 1);
    add(usernameText, 1, 1);
    add(passwordLabel, 0, 2);
    add(passwordText, 1, 2);
    GridPane.setHgrow(domainText, Priority.ALWAYS);
    GridPane.setHgrow(usernameText, Priority.ALWAYS);
    GridPane.setHgrow(passwordText, Priority.ALWAYS);
  }
示例#7
0
  private String showCreateOrRenameDialog(
      final String title,
      final String headerText,
      final File parent,
      final String name,
      final NameVerifier nameVerifier) {
    final Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle(title);
    alert.setHeaderText(headerText);

    final GridPane contentContainer = new GridPane();
    contentContainer.setPadding(new Insets(8));
    contentContainer.setHgap(8);
    contentContainer.setVgap(8);

    contentContainer.add(new Label("Parent:"), 0, 0);
    final TextField parentTextField = new TextField();
    parentTextField.setEditable(false);

    parentTextField.setText(parent.getAbsolutePath());
    contentContainer.add(parentTextField, 1, 0);

    contentContainer.add(new Label("Name:"), 0, 1);

    final TextField dirNameTextField = new TextField();
    dirNameTextField.setText(name);
    GridPane.setHgrow(dirNameTextField, Priority.ALWAYS);
    contentContainer.add(dirNameTextField, 1, 1);

    final InvalidationListener updateDisableInvalidationListener =
        (observable) -> {
          final String dirName = dirNameTextField.getText();
          final Node okButton = alert.getDialogPane().lookupButton(ButtonType.OK);
          if (isEmpty(dirName)) okButton.setDisable(true);
          else {
            final boolean nameAcceptable = nameVerifier.isNameAcceptable(dirName);
            okButton.setDisable(!nameAcceptable);
          }
        };
    dirNameTextField.textProperty().addListener(updateDisableInvalidationListener);

    alert.getDialogPane().setContent(contentContainer);
    alert.setOnShowing(
        (event) -> {
          dirNameTextField.requestFocus();
          dirNameTextField.selectAll();
          updateDisableInvalidationListener.invalidated(null);
        });

    if (alert.showAndWait().get() == ButtonType.OK) return dirNameTextField.getText();
    else return null;
  }
  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;
  }
  @Override
  public void start(Stage stage) {
    try {
      Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

      Scene scene = new Scene(root);

      stage.setScene(scene);
      stage.show();
    } catch (Exception ex) {
      Alert alert = new Alert(Alert.AlertType.ERROR);
      alert.setTitle("Lobo Software");
      alert.setHeaderText("Se ha presentado un error inesperado");
      alert.setContentText("El error técnico se muestra a continuación:");

      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      ex.printStackTrace(pw);
      String exceptionText = sw.toString();

      TextArea textArea = new TextArea(exceptionText);
      textArea.setEditable(false);
      textArea.setWrapText(true);

      textArea.setMaxWidth(Double.MAX_VALUE);
      textArea.setMaxHeight(Double.MAX_VALUE);
      GridPane.setVgrow(textArea, Priority.ALWAYS);
      GridPane.setHgrow(textArea, Priority.ALWAYS);

      GridPane expContent = new GridPane();
      expContent.setMaxWidth(Double.MAX_VALUE);
      expContent.add(textArea, 0, 1);

      alert.getDialogPane().setExpandableContent(expContent);
      alert.showAndWait();
    }
  }
示例#10
0
  private void updateGrid() {
    grid.getChildren().clear();

    // add the message to the top of the dialog
    updateContentText();

    // then build all the buttons
    int row = 1;
    for (final ButtonType buttonType : getDialogPane().getButtonTypes()) {
      if (buttonType == null) continue;

      final Button button = (Button) getDialogPane().lookupButton(buttonType);

      GridPane.setHgrow(button, Priority.ALWAYS);
      GridPane.setVgrow(button, Priority.ALWAYS);
      grid.add(button, 0, row++);
    }

    //        // last button gets some extra padding (hacky)
    //        GridPane.setMargin(buttons.get(buttons.size() - 1), new Insets(0,0,10,0));

    getDialogPane().setContent(grid);
    getDialogPane().requestLayout();
  }
 public void add(Node... nodes) {
   for (int i = 0; i < nodes.length; i++) GridPane.setConstraints(nodes[i], i, rowc);
   GridPane.setHgrow(nodes[nodes.length - 1], Priority.SOMETIMES);
   grid.getChildren().addAll(nodes);
   rowc++;
 }
示例#12
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);
  }
示例#13
0
  public SerieInfo(final Serie serie) {
    // TODO Auto-generated constructor stub

    GridPane grid = new GridPane();
    FlowPane flow = new FlowPane(Orientation.HORIZONTAL);
    flow.setAlignment(Pos.TOP_LEFT);
    flow.setHgap(40);

    DropShadow dropShadow = new DropShadow();
    dropShadow.setOffsetX(10);
    dropShadow.setOffsetY(10);
    dropShadow.setColor(Color.rgb(50, 50, 50, 0.7));

    Label poster = new Label();
    String style_inner =
        "-fx-font: Gill Sans;"
            + "-fx-font-family: Gill Sans;"
            + "-fx-effect: dropshadow(one-pass-box, black, 8, 0, 4, 4);";
    poster.setStyle(style_inner);

    final Label star = new Label();
    Image stella = new Image("img/greentick.png", 35, 35, true, true, true);
    star.setGraphic(new ImageView(stella));
    star.setVisible(false);

    ImageView image = new ImageView(serie.getPoster());
    poster.setGraphic(image);

    TextArea text = new TextArea();

    text.setPrefSize(600, 160);
    text.setText(serie.getOverview());
    text.setWrapText(true);
    text.setEditable(false);
    /*
     * text.setStyle("-fx-text-fill: black;"+ "-fx-font: Gill Sans;"+
     * "-fx-font-size: 13;" + "-fx-height:400");
     */

    text.setStyle(LABEL_STYLE);
    String name = null;
    if (serie.getNome().length() > 16) {
      name = serie.getNome().substring(0, 15);
      name = name.concat("...");
    } else {

      name = serie.getNome();
    }

    Label nome = new Label(name);
    nome.setTextFill(Color.BLACK);
    nome.setFont(Font.font("Helvetica", 28));

    final Button btn = new Button("  Add   ");
    ImageView imageview = new ImageView(new Image("img/add.png", 12, 12, true, true, true));
    btn.setGraphic(imageview);
    btn.setContentDisplay(ContentDisplay.LEFT);
    /*
     * String buttonCss = SerieInfo.class.getResource("CustomButton.css")
     * .toExternalForm(); btn.getStylesheets().add(buttonCss);
     */
    btn.getStyleClass().add("custom-browse");
    btn.setCursor(Cursor.HAND);
    btn.setTextFill(Color.WHITE);

    btn.addEventHandler(
        MouseEvent.MOUSE_CLICKED,
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent e) {

            star.setVisible(true);

            if (Preferiti.getInstance().addToPreferiti(serie) == false) {

              /*
               * new MyDialog(Guiseries2.stage,
               * Modality.APPLICATION_MODAL, "Warning!", serie);
               */

            } else {

              btn.setDisable(true);
              btn.setText("  Added  ");
              btn.setGraphic(null);
              // torrent...
              DaemonManager manager = new DaemonManager();
              Search search =
                  new Search(
                      serie,
                      manager,
                      "ENG",
                      new SearchListener() {

                        @Override
                        public void SearchListener() {
                          Platform.runLater(
                              new Runnable() {

                                @Override
                                public void run() {

                                  boolean compare = false;
                                  for (int i = 0; i < serie.getStagioni().size(); i++) {

                                    for (int j = 0;
                                        j < serie.getStagioni().get(i).getEpisodiStagione().size();
                                        j++) {

                                      compare = false;

                                      if ((serie
                                              .getStagioni()
                                              .get(i)
                                              .getEpisodiStagione()
                                              .get(j)
                                              .getTorrent()
                                          != null)) {
                                        for (int k = (1 + j);
                                            k
                                                < serie
                                                    .getStagioni()
                                                    .get(i)
                                                    .getEpisodiStagione()
                                                    .size();
                                            k++) {

                                          if (serie
                                                  .getStagioni()
                                                  .get(i)
                                                  .getEpisodiStagione()
                                                  .get(k)
                                                  .getTorrent()
                                              != null) {
                                            if (serie
                                                .getStagioni()
                                                .get(i)
                                                .getEpisodiStagione()
                                                .get(j)
                                                .getTorrent()
                                                .getName()
                                                .equals(
                                                    serie
                                                        .getStagioni()
                                                        .get(i)
                                                        .getEpisodiStagione()
                                                        .get(k)
                                                        .getTorrent()
                                                        .getName())) {

                                              compare = true;
                                            }
                                          }
                                        }

                                        if (compare == false) {

                                          TorrentSeriesElement.getInstance()
                                              .addToTorrents(
                                                  serie
                                                      .getStagioni()
                                                      .get(i)
                                                      .getEpisodiStagione()
                                                      .get(j)
                                                      .getTorrent());
                                          if ((TorrentSeriesElement.getInstance()
                                                      .torrents
                                                      .indexOf(
                                                          serie
                                                              .getStagioni()
                                                              .get(i)
                                                              .getEpisodiStagione()
                                                              .get(j)
                                                              .getTorrent())
                                                  % 2)
                                              == 0) {

                                            TabDownload.mainDownload
                                                .getChildren()
                                                .add(
                                                    TabDownload.addTorrentEvenToDownloadTab(
                                                        serie
                                                            .getStagioni()
                                                            .get(i)
                                                            .getEpisodiStagione()
                                                            .get(j)
                                                            .getTorrent()));

                                          } else {

                                            TabDownload.mainDownload
                                                .getChildren()
                                                .add(
                                                    TabDownload.addTorrentOddToDownloadTab(
                                                        serie
                                                            .getStagioni()
                                                            .get(i)
                                                            .getEpisodiStagione()
                                                            .get(j)
                                                            .getTorrent()));
                                          }

                                          System.out.println(
                                              serie
                                                  .getStagioni()
                                                  .get(i)
                                                  .getEpisodiStagione()
                                                  .get(j)
                                                  .getTorrent()
                                                  .getName());
                                        }
                                      }
                                    }
                                  }

                                  try {

                                    FilmistaDb.getInstance().addSeriesToFilmistaDb(serie);
                                  } catch (ClassNotFoundException e1) {
                                    // TODO Auto-generated
                                    // catch
                                    // block
                                    e1.printStackTrace();
                                  } catch (IOException e1) {
                                    // TODO Auto-generated
                                    // catch
                                    // block
                                    e1.printStackTrace();
                                  } catch (SQLException e1) {
                                    // TODO Auto-generated
                                    // catch
                                    // block
                                    e1.printStackTrace();
                                  }

                                  TabPreferiti.updateTab();
                                }
                              });
                        }
                      });
            }
          }
        });

    flow.getChildren().add(btn);
    flow.getChildren().add(nome);

    if (Preferiti.getInstance().series.contains(serie) == true) {

      btn.setText("  Added  ");
      btn.setDisable(true);
      star.setVisible(true);
      btn.setGraphic(null);
    }

    grid.setHgap(25);
    grid.setVgap(15);
    grid.add(poster, 0, 0, 1, 2);
    grid.add(flow, 1, 0);
    FlowPane paneStar = new FlowPane(Orientation.HORIZONTAL);
    paneStar.setAlignment(Pos.TOP_RIGHT);
    paneStar.getChildren().add(star);
    grid.add(paneStar, 2, 0, 1, 1);
    grid.add(text, 1, 1, 2, 1);

    grid.getColumnConstraints().add(0, new ColumnConstraints());
    grid.getColumnConstraints().add(1, new ColumnConstraints());
    grid.getColumnConstraints().add(2, new ColumnConstraints(150));

    // grid.setGridLinesVisible(true);
    grid.setHgrow(text, Priority.ALWAYS);
    grid.setVgrow(poster, Priority.ALWAYS);

    grid.setPadding(new Insets(25, 25, 25, 25));
    this.setCenter(grid);

    String customCss = SerieInfo.class.getResource("CustomBorder.css").toExternalForm();
    this.getStylesheets().add(customCss);
    this.getStyleClass().add("custom-border");
  }
  /** {@inheritDoc} */
  @Override
  public void buildContent() {
    Calendar calendar = calendarView.calendarProperty().get();

    // get the maximum number of days in a week for this calendar.
    numberOfDaysPerWeek = calendar.getMaximum(Calendar.DAY_OF_WEEK);

    // get the maximum number of days a month could have.
    int maxNumberOfDaysInMonth = calendar.getMaximum(Calendar.DAY_OF_MONTH);

    // assume the first row has only 1 day, then distribute the rest among the remaining weeks and
    // add the first week.
    int numberOfRows =
        (int) Math.ceil((maxNumberOfDaysInMonth - 1) / (double) numberOfDaysPerWeek) + 1;

    // remove all controls
    getChildren().clear();

    int colOffset = calendarView.getShowWeeks() ? 1 : 0;

    if (calendarView.getShowWeeks()) {
      Label empty = new Label();
      empty.setMaxWidth(Double.MAX_VALUE);
      empty.getStyleClass().add(CSS_CALENDAR_WEEKDAYS);
      add(empty, 0, 0);
    }
    // iterate through the columns
    for (int i = 0; i < numberOfDaysPerWeek; i++) {
      Label label = new Label();
      label.getStyleClass().add(CSS_CALENDAR_WEEKDAYS);
      label.setMaxWidth(Double.MAX_VALUE);
      label.setAlignment(Pos.CENTER);
      add(label, i + colOffset, 0);
    }

    // iterate through the rows
    for (int rowIndex = 0; rowIndex < numberOfRows; rowIndex++) {

      if (calendarView.getShowWeeks()) {
        Label label = new Label();
        label.setMaxWidth(Double.MAX_VALUE);
        label.setMaxHeight(Double.MAX_VALUE);
        label.getStyleClass().add(CSS_CALENDAR_WEEK_NUMBER);
        add(label, 0, rowIndex + 1);
      }

      // iterate through the columns
      for (int colIndex = 0; colIndex < numberOfDaysPerWeek; colIndex++) {
        final Button button = new Button();
        button.setMaxWidth(Double.MAX_VALUE);
        button.setMaxHeight(Double.MAX_VALUE);

        GridPane.setVgrow(button, Priority.ALWAYS);
        GridPane.setHgrow(button, Priority.ALWAYS);
        button.setOnAction(
            new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent actionEvent) {

                calendarView.selectedDate.set((Date) button.getUserData());
              }
            });
        // add the button, starting at second row.
        add(button, colIndex + colOffset, rowIndex + 1);
      }
    }
  }
  /** Create and initialise the song panel. */
  public BasicSongPanel() {
    final VBox centrePanel = new VBox();
    transposeDialog = new TransposeDialog();
    GridPane topPanel = new GridPane();

    titleField = new TextField();
    GridPane.setHgrow(titleField, Priority.ALWAYS);
    Label titleLabel = new Label(LabelGrabber.INSTANCE.getLabel("title.label"));
    GridPane.setConstraints(titleLabel, 1, 1);
    topPanel.getChildren().add(titleLabel);
    titleLabel.setLabelFor(titleField);
    GridPane.setConstraints(titleField, 2, 1);
    topPanel.getChildren().add(titleField);

    authorField = new TextField();
    GridPane.setHgrow(authorField, Priority.ALWAYS);
    Label authorLabel = new Label(LabelGrabber.INSTANCE.getLabel("author.label"));
    GridPane.setConstraints(authorLabel, 1, 2);
    topPanel.getChildren().add(authorLabel);
    authorLabel.setLabelFor(authorField);
    GridPane.setConstraints(authorField, 2, 2);
    topPanel.getChildren().add(authorField);

    centrePanel.getChildren().add(topPanel);
    lyricsArea = new SpellTextArea();
    lyricsArea.setMaxHeight(Double.MAX_VALUE);

    final VBox mainPanel = new VBox();
    ToolBar lyricsToolbar = new ToolBar();
    transposeButton = getTransposeButton();
    nonBreakingLineButton = getNonBreakingLineButton();
    lyricsToolbar.getItems().add(transposeButton);
    lyricsToolbar.getItems().add(nonBreakingLineButton);
    lyricsToolbar.getItems().add(new Separator());
    Region spacer = new Region();
    HBox.setHgrow(spacer, Priority.ALWAYS);
    lyricsToolbar.getItems().add(spacer);
    dictSelector = new ComboBox<>();
    Tooltip.install(
        dictSelector, new Tooltip(LabelGrabber.INSTANCE.getLabel("dictionary.language.text")));
    for (Dictionary dict : DictionaryManager.INSTANCE.getDictionaries()) {
      dictSelector.getItems().add(dict);
    }
    dictSelector
        .selectionModelProperty()
        .get()
        .selectedItemProperty()
        .addListener(
            new ChangeListener<Dictionary>() {

              @Override
              public void changed(
                  ObservableValue<? extends Dictionary> ov, Dictionary t, Dictionary t1) {
                lyricsArea.setDictionary(dictSelector.getValue());
              }
            });

    dictSelector.getSelectionModel().select(QueleaProperties.get().getDictionary());
    lyricsToolbar.getItems().add(dictSelector);
    lyricsToolbar.getItems().add(getDictButton());
    VBox.setVgrow(mainPanel, Priority.ALWAYS);
    mainPanel.getChildren().add(lyricsToolbar);
    VBox.setVgrow(lyricsArea, Priority.ALWAYS);
    mainPanel.getChildren().add(lyricsArea);
    centrePanel.getChildren().add(mainPanel);
    setCenter(centrePanel);
  }
  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);
  }