Beispiel #1
0
  public Progress(Stage owner) {
    this.owner = owner;

    Pane content = new Pane();
    content.setPrefWidth(200);
    content.setPrefHeight(200);
    indicator = new ProgressIndicator(-1.0);
    indicator.setStyle(" -fx-progress-color: white;");
    indicator.setTranslateX(60);
    indicator.setTranslateY(60);
    indicator.setPrefWidth(80);
    indicator.setPrefHeight(80);
    Rectangle back = new Rectangle(100, 100);
    back.setFill(Color.color(0, 0, 0, 0.5));
    back.setArcHeight(10);
    back.setArcWidth(10);
    back.setTranslateX(50);
    back.setTranslateY(50);
    content.getChildren().addAll(back, indicator);

    popup = new Popup();
    popup.getContent().addAll(content);
    popup.setAutoFix(true);
  }
  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;
  }