示例#1
0
 private Label limitDisplay() {
   return LabelBuilder.create()
       .minWidth(40)
       .prefWidth(45)
       .alignment(Pos.CENTER_RIGHT)
       .style("-fx-text-fill: #f2f2f2; -fx-font-size: 10px; ")
       .build();
 }
 public TaskProgressIndicator() {
   getChildren()
       .setAll(
           VBoxBuilder.create()
               .children(
                   label = LabelBuilder.create().text("Please wait...").build(),
                   progress = ProgressBarBuilder.create().build())
               .build());
 }
示例#3
0
  public ToolbarCounterDisplay(@Nonnull String name, @Nonnull Formatting formatting) {
    this.formatting = formatting;

    numberDisplay = numberDisplay();
    numberDisplay.setAlignment(Pos.CENTER_RIGHT);
    separationSlash =
        LabelBuilder.create()
            .style("-fx-text-fill: #f2f2f2; -fx-font-size: 10px;")
            .alignment(Pos.CENTER)
            .text("/")
            .build();
    limitDisplay = limitDisplay();

    BorderPane numberAndLimitDisplay =
        BorderPaneBuilder.create()
            .prefWidth(100)
            .maxWidth(160)
            .center(HBoxBuilder.create().children(numberDisplay, separationSlash).build())
            .right(limitDisplay)
            .style(
                "-fx-background-color: linear-gradient(to bottom, #545454 0%, #000000 50%, #000000 100%); -fx-padding: 0 6 0 6; -fx-background-radius: 5; -fx-border-width: 1; -fx-border-color: #333333; -fx-border-radius: 4; ")
            .build();

    progress = progressBar();

    Label label = label(name);

    HBox labelAndProgress =
        HBoxBuilder.create()
            .children(label, progress)
            .spacing(3)
            .alignment(Pos.BOTTOM_LEFT)
            .build();

    HBox.setHgrow(label, Priority.NEVER);
    HBox.setHgrow(progress, Priority.ALWAYS);

    getChildren().setAll(numberAndLimitDisplay, labelAndProgress);
    setSpacing(1);
    setAlignment(Pos.CENTER);
    setLimit(limit);
  }
  /**
   * Build and return the footer panel.
   *
   * @return the footer panel
   */
  protected Node getFooterPanel() {
    this.pageLabel =
        LabelBuilder.create()
            .text(String.valueOf(model().getSlide().getPage()))
            .font(PrezFonts.PAGE.get())
            .build();

    final AnchorPane ap = AnchorPaneBuilder.create().children(this.pageLabel).build();
    AnchorPane.setRightAnchor(this.pageLabel, 20.0);

    final StackPane sp =
        StackPaneBuilder.create()
            .styleClass("footer")
            .prefHeight(35.0)
            .minHeight(Region.USE_PREF_SIZE)
            .maxHeight(Region.USE_PREF_SIZE)
            .children(ap)
            .build();

    StackPane.setAlignment(ap, Pos.CENTER_RIGHT);

    return sp;
  }
示例#5
0
    public MediaControl(final MediaPlayer mp) {
      this.mp = mp;
      setStyle("-fx-background-color: #bfc2c7;"); // TODO: Use css file
      mediaView = new MediaView(mp);
      mvPane = new Pane();
      mvPane.getChildren().add(mediaView);
      mvPane.setStyle("-fx-background-color: black;"); // TODO: Use css file
      setCenter(mvPane);
      mediaBar = new HBox(5.0);
      mediaBar.setPadding(new Insets(5, 10, 5, 10));
      mediaBar.setAlignment(Pos.CENTER_LEFT);
      BorderPane.setAlignment(mediaBar, Pos.CENTER);

      final Button playButton = ButtonBuilder.create().minWidth(Control.USE_PREF_SIZE).build();

      playButton.setGraphic(imageViewPlay);
      playButton.setOnAction(
          new EventHandler<ActionEvent>() {
            public void handle(ActionEvent e) {
              updateValues();
              MediaPlayer.Status status = mp.getStatus();
              if (status == MediaPlayer.Status.UNKNOWN || status == MediaPlayer.Status.HALTED) {
                // don't do anything in these states
                return;
              }

              if (status == MediaPlayer.Status.PAUSED
                  || status == MediaPlayer.Status.READY
                  || status == MediaPlayer.Status.STOPPED) {
                // rewind the movie if we're sitting at the end
                if (atEndOfMedia) {
                  mp.seek(mp.getStartTime());
                  atEndOfMedia = false;
                  playButton.setGraphic(imageViewPlay);
                  // playButton.setText(">");
                  updateValues();
                }
                mp.play();
                playButton.setGraphic(imageViewPause);
                // playButton.setText("||");
              } else {
                mp.pause();
              }
            }
          });
      mp.currentTimeProperty()
          .addListener(
              new ChangeListener<Duration>() {
                @Override
                public void changed(
                    ObservableValue<? extends Duration> observable,
                    Duration oldValue,
                    Duration newValue) {
                  updateValues();
                }
              });
      mp.setOnPlaying(
          new Runnable() {
            public void run() {

              if (stopRequested) {
                mp.pause();
                stopRequested = false;
              } else {
                playButton.setGraphic(imageViewPause);
                // playButton.setText("||");
              }
            }
          });
      mp.setOnPaused(
          new Runnable() {
            public void run() {

              playButton.setGraphic(imageViewPlay);
              // playButton.setText("||");
            }
          });
      mp.setOnReady(
          new Runnable() {
            public void run() {
              duration = mp.getMedia().getDuration();
              updateValues();
            }
          });

      mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1);
      mp.setOnEndOfMedia(
          new Runnable() {
            public void run() {
              if (!repeat) {
                playButton.setGraphic(imageViewPlay);
                // playButton.setText(">");
                stopRequested = true;
                atEndOfMedia = true;
              }
            }
          });
      mediaBar.getChildren().add(playButton);

      // Time label
      Label timeLabel = new Label("Time");
      timeLabel.setMinWidth(Control.USE_PREF_SIZE);
      mediaBar.getChildren().add(timeLabel);

      // Time slider
      timeSlider = SliderBuilder.create().minWidth(30).maxWidth(Double.MAX_VALUE).build();
      HBox.setHgrow(timeSlider, Priority.ALWAYS);
      timeSlider
          .valueProperty()
          .addListener(
              new InvalidationListener() {
                public void invalidated(Observable ov) {
                  if (timeSlider.isValueChanging()) {
                    // multiply duration by percentage calculated by slider position
                    if (duration != null) {
                      mp.seek(duration.multiply(timeSlider.getValue() / 100.0));
                    }
                    updateValues();
                  }
                }
              });
      mediaBar.getChildren().add(timeSlider);

      // Play label
      playTime =
          LabelBuilder.create()
              // .prefWidth(130)
              .minWidth(Control.USE_PREF_SIZE)
              .build();

      mediaBar.getChildren().add(playTime);

      // Fullscreen button

      Button buttonFullScreen =
          ButtonBuilder.create().text("Full Screen").minWidth(Control.USE_PREF_SIZE).build();

      buttonFullScreen.setOnAction(
          new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
              if (!fullScreen) {
                newStage = new Stage();
                newStage
                    .fullScreenProperty()
                    .addListener(
                        new ChangeListener<Boolean>() {
                          @Override
                          public void changed(
                              ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                            onFullScreen();
                          }
                        });
                final BorderPane borderPane =
                    new BorderPane() {
                      @Override
                      protected void layoutChildren() {
                        if (mediaView != null && getBottom() != null) {
                          mediaView.setFitWidth(getWidth());
                          mediaView.setFitHeight(getHeight() - getBottom().prefHeight(-1));
                        }
                        super.layoutChildren();
                        if (mediaView != null) {
                          mediaView.setTranslateX(
                              (((Pane) getCenter()).getWidth() - mediaView.prefWidth(-1)) / 2);
                          mediaView.setTranslateY(
                              (((Pane) getCenter()).getHeight() - mediaView.prefHeight(-1)) / 2);
                        }
                      };
                    };

                setCenter(null);
                setBottom(null);
                borderPane.setCenter(mvPane);
                borderPane.setBottom(mediaBar);

                Scene newScene = new Scene(borderPane);
                newStage.setScene(newScene);
                // Workaround for disposing stage when exit fullscreen
                newStage.setX(-100000);
                newStage.setY(-100000);

                newStage.setFullScreen(true);
                fullScreen = true;
                newStage.show();

              } else {
                // toggle FullScreen
                fullScreen = false;
                newStage.setFullScreen(false);
              }
            }
          });
      mediaBar.getChildren().add(buttonFullScreen);

      // Volume label
      Label volumeLabel = new Label("Vol");
      volumeLabel.setMinWidth(Control.USE_PREF_SIZE);
      mediaBar.getChildren().add(volumeLabel);

      // Volume slider
      volumeSlider =
          SliderBuilder.create().prefWidth(70).minWidth(30).maxWidth(Region.USE_PREF_SIZE).build();
      volumeSlider
          .valueProperty()
          .addListener(
              new InvalidationListener() {
                public void invalidated(Observable ov) {}
              });
      volumeSlider
          .valueProperty()
          .addListener(
              new ChangeListener<Number>() {
                @Override
                public void changed(
                    ObservableValue<? extends Number> observable,
                    Number oldValue,
                    Number newValue) {
                  if (volumeSlider.isValueChanging()) {
                    mp.setVolume(volumeSlider.getValue() / 100.0);
                  }
                }
              });
      mediaBar.getChildren().add(volumeSlider);

      setBottom(mediaBar);
    }
示例#6
0
    @Override
    public void start(final Stage stage) throws Exception {
      File workingDir = new File(System.getProperty("loadui.working", ".")).getAbsoluteFile();
      Scene splashScene;
      try {
        splashScene =
            FXMLLoader.load(new File(workingDir, "res/loadui-splash.fxml").toURI().toURL());
      } catch (IOException e) {
        splashScene =
            SceneBuilder.create()
                .width(600)
                .height(320)
                .fill(Color.DARKGRAY)
                .root(LabelBuilder.create().text(System.getProperty(LOADUI_NAME, "loadUI")).build())
                .build();
      }

      Image[] icons = new Image[0];
      try {
        icons =
            new Image[] {
              new Image(new File(workingDir, "res/icon_64x64.png").toURI().toURL().toString()),
              new Image(new File(workingDir, "res/icon_32x32.png").toURI().toURL().toString())
            };
      } catch (Exception e) {
        // e.printStackTrace();
      }

      final String noFx = getParameters().getNamed().get(NOFX_OPTION);
      final String agent = getParameters().getNamed().get("agent");

      if ("true".equals(agent)) setDefaultSystemProperty("loadui.instance", "agent");

      if ("false".equals(noFx)) {
        setDefaultSystemProperty("loadui.headless", "false");
        final Stage splash =
            StageBuilder.create()
                .style(StageStyle.TRANSPARENT)
                .scene(splashScene)
                .icons(icons)
                .build();
        splash.initModality(Modality.APPLICATION_MODAL);
        splash.centerOnScreen();
        splash.show();
        splash.toFront();

        stage.getIcons().addAll(icons);
        stage.setOnShown(
            new EventHandler<WindowEvent>() {
              @Override
              public void handle(WindowEvent event) {
                System.out.println("closing splash!");
                splash.close();
              }
            });
      }

      System.out.println("start called!");

      Task<Void> task =
          new Task<Void>() {
            @Override
            protected Void call() throws Exception {
              System.setSecurityManager(null);

              System.out.println("LoadUIFXLauncher: Creating launcher");
              launcher = createLauncher(getParameters().getRaw().toArray(new String[0]));
              System.out.println("LoadUIFXLauncher: Initializing launcher");
              launcher.init();
              System.out.println("LoadUIFXLauncher: Starting launcher");
              launcher.start();

              if ("false".equals(noFx)) {
                launcher
                    .framework
                    .getBundleContext()
                    .registerService(Stage.class, stage, new Hashtable<String, Object>());
              }
              return null;
            }
          };

      new Thread(task).start();
    }
示例#7
0
  @Override
  public void start(final Stage primaryStage) {
    // initialize the stage
    primaryStage.setTitle("Modal Confirm Example");
    final WebView webView = new WebView();
    webView.getEngine().load("http://docs.oracle.com/javafx/");
    primaryStage.setScene(new Scene(webView));
    primaryStage.show();

    // initialize the confirmation dialog
    final Stage util = new Stage(StageStyle.TRANSPARENT);
    util.initModality(Modality.APPLICATION_MODAL);
    util.setScene(
        new Scene(
            StackPaneBuilder.create()
                .children(
                    PaneBuilder.create().styleClass("modal-dialog-glass").build(),
                    HBoxBuilder.create()
                        .styleClass("modal-dialog-content")
                        .children(
                            LabelBuilder.create().text("Will you like this page?").build(),
                            ButtonBuilder.create()
                                .text("Yes")
                                .defaultButton(true)
                                .onAction(
                                    new EventHandler<ActionEvent>() {
                                      @Override
                                      public void handle(ActionEvent actionEvent) {
                                        // take action and close the dialog.
                                        System.out.println(
                                            "Liked: " + webView.getEngine().getTitle());
                                        primaryStage.getScene().getRoot().setEffect(null);
                                        util.close();
                                      }
                                    })
                                .build(),
                            ButtonBuilder.create()
                                .text("No")
                                .cancelButton(true)
                                .onAction(
                                    new EventHandler<ActionEvent>() {
                                      @Override
                                      public void handle(ActionEvent actionEvent) {
                                        // abort action and close the dialog.
                                        System.out.println(
                                            "Disliked: " + webView.getEngine().getTitle());
                                        primaryStage.getScene().getRoot().setEffect(null);
                                        util.close();
                                      }
                                    })
                                .build())
                        .build())
                .build(),
            Color.TRANSPARENT));
    util.getScene()
        .getStylesheets()
        .add(getClass().getResource("/assets/fxml/modal-dialog.css").toExternalForm());

    // show the confirmation dialog each time a new page is loaded.
    webView
        .getEngine()
        .getLoadWorker()
        .stateProperty()
        .addListener(
            new ChangeListener<Worker.State>() {
              @Override
              public void changed(
                  ObservableValue<? extends Worker.State> observableValue,
                  Worker.State state,
                  Worker.State newState) {
                if (newState.equals(Worker.State.SUCCEEDED)) {
                  primaryStage.getScene().getRoot().setEffect(new BoxBlur());
                  util.show();
                  util.toFront();
                }
              }
            });
  }
  /**
   * Build and return the header panel.
   *
   * @return the header panel
   */
  protected Node getHeaderPanel() {

    final Pane headerPane =
        PaneBuilder.create()
            .styleClass("header")
            .layoutX(0.0)
            .layoutY(0.0)
            .minWidth(1024)
            .prefWidth(1024)
            .build();

    this.primaryTitle =
        LabelBuilder.create()
            // .styleClass("slideTitle")
            .font(JpFonts.SLIDE_TITLE.get())
            .textFill(PrezColors.SLIDE_TITLE.get())
            .text(model().getSlide().getTitle().replaceAll("\\\\n", "\n").replaceAll("\\\\t", "\t"))
            .layoutX(3000) // 40
            .layoutY(45)
            // .style("-fx-background-color:#CCCB20")
            .build();

    this.secondaryTitle =
        LabelBuilder.create()
            // .styleClass("slideTitle")
            .font(PrezFonts.SLIDE_SUB_TITLE.get())
            .textFill(PrezColors.SLIDE_TITLE.get())
            // .scaleX(1.5)
            // .scaleY(1.5)
            .layoutX(110)
            .layoutY(80)
            .minWidth(450)
            // .style("-fx-background-color:#E53B20")
            .alignment(Pos.CENTER_RIGHT)
            .textAlignment(TextAlignment.RIGHT)
            .build();

    this.prezTitle =
        LabelBuilder.create()
            // .styleClass("slideTitle")
            .font(JpFonts.PREZ_TITLE.get())
            .textFill(Color.LIGHTGRAY)
            // .scaleX(1.5)
            // .scaleY(1.5)
            // .layoutX(545)
            // .layoutY(711)
            .layoutX(480)
            .layoutY(14.0)
            .minWidth(450)
            // .style("-fx-background-color:#E53B20")
            .alignment(Pos.CENTER_RIGHT)
            .textAlignment(TextAlignment.RIGHT)
            .build();

    this.placeLogo =
        ImageViewBuilder.create()
            // .layoutX(680.0)
            // .layoutY(-14.0)
            .layoutX(1200)
            .layoutY(700)
            // .scaleX(0.6)
            // .scaleY(0.6)
            .image(JpImages.JREBIRTH_LOGO.get())
            .build();

    final Polyline pl =
        PolylineBuilder.create()
            .strokeWidth(3)
            .stroke(Color.web("F79508"))
            .points(684.0, 12.0, 946.0, 12.0, 946.0, 107.0)
            .build();

    this.topRectangle =
        RectangleBuilder.create()
            .layoutX(95.0)
            .layoutY(95.0)
            .width(0.0) // 60.0
            .height(14.0)
            .fill(Color.web("1C9A9A"))
            .build();
    this.bottomRectangle =
        RectangleBuilder.create()
            .layoutX(0)
            .layoutY(738)
            .width(0.0) // 60.0
            .height(14.0)
            .fill(Color.web("1C9A9A"))
            .build();

    // this.circle = CircleBuilder.create()
    // .scaleX(0)
    // .scaleY(0)
    // .layoutX(18 + 54)
    // .layoutY(18 + 54)
    // .radius(54)
    // .fill(Color.web("444442"))
    // .build();
    final Effect smallPokemonEffect =
        InnerShadowBuilder.create()
            .offsetX(1)
            .offsetY(1)
            .color(Color.LIGHTGRAY)
            .input(GlowBuilder.create().level(0.6).build())
            .build();

    final Effect bigPokemonEffect =
        DropShadowBuilder.create()
            .offsetX(2)
            .offsetY(2)
            .input(GlowBuilder.create().level(0.6).build())
            .build();

    this.smallPokemon =
        SVGPathBuilder.create()
            .scaleX(0)
            .scaleY(0)
            .layoutX(40)
            .layoutY(40)
            .fill(Color.web("F79508"))
            .effect(smallPokemonEffect)
            .content(
                "M64.332,33.584l3.166-3.166C65.99,14.311,53.104,1.493,36.916,0l-3.167,3.167L30.582,0 C14.394,1.493,1.507,14.312,0,30.419l3.166,3.166L0,36.751c1.508,16.106,14.395,28.925,30.582,30.418l3.167-3.167l3.168,3.168 c16.188-1.493,29.073-14.313,30.58-30.421L64.332,33.584z M37.387,44.951h-7.275c-5.114,0-9.26-4.146-9.26-9.26v-4.917 c0-5.114,4.146-9.26,9.26-9.26h7.275c5.114,0,9.26,4.146,9.26,9.26v4.917C46.646,40.805,42.501,44.951,37.387,44.951z")
            .build();

    this.bigPokemon =
        SVGPathBuilder.create()
            .scaleX(0)
            .scaleY(0)
            .layoutX(40)
            .layoutY(40)
            .fill(Color.web("D9E021"))
            .effect(bigPokemonEffect)
            .content(
                "M64.332,33.584l3.166-3.166C65.99,14.311,53.104,1.493,36.916,0l-3.167,3.167L30.582,0 C14.394,1.493,1.507,14.312,0,30.419l3.166,3.166L0,36.751c1.508,16.106,14.395,28.925,30.582,30.418l3.167-3.167l3.168,3.168 c16.188-1.493,29.073-14.313,30.58-30.421L64.332,33.584z M37.387,44.951h-7.275c-5.114,0-9.26-4.146-9.26-9.26v-4.917 c0-5.114,4.146-9.26,9.26-9.26h7.275c5.114,0,9.26,4.146,9.26,9.26v4.917C46.646,40.805,42.501,44.951,37.387,44.951z")
            .build();

    this.pageLabel =
        LabelBuilder.create()
            .layoutX(970)
            .layoutY(18.0)
            .text(String.valueOf(model().getSlide().getPage()))
            .font(PrezFonts.PAGE.get())
            .textFill(Color.WHITE)
            .rotate(90.0)
            .build();

    // final FlowPane fp = FlowPaneBuilder.create()
    // .orientation(Orientation.HORIZONTAL)
    // .alignment(Pos.BASELINE_CENTER)
    // .children(this.secondaryTitle)
    // // .style("-fx-background-color:#CCCCCC")
    // .build();

    headerPane
        .getChildren()
        .addAll(
            this.topRectangle,
            this.bottomRectangle,
            this.bigPokemon,
            this.smallPokemon,
            this.primaryTitle,
            this.placeLogo,
            this.secondaryTitle,
            pl,
            this.pageLabel,
            this.prezTitle);

    // AnchorPane.setLeftAnchor(primaryTitle, 40.0);
    // AnchorPane.setTopAnchor(primaryTitle, 45.0);
    //
    // AnchorPane.setRightAnchor(this.secondaryTitle, 80.0);
    // AnchorPane.setTopAnchor(primaryTitle, 20.0);

    // ap.setStyle("-fx-background-color:#002266");

    // sp.setStyle("-fx-background-color:#663366");
    // StackPane.setAlignment(ap, Pos.BOTTOM_CENTER);
    // sp.getChildren().add(ap);

    return headerPane;
  }
示例#9
0
  /*
   * Create and show a backup error dialog. This is probably overkill, but I
   * created this method just to make sure there always is an error dialog,
   * even when ErrorDialog.fxml cannot be loaded.
   */
  private static void showBackupErrorDialog() {
    final RemindersException exception = Model.getInstance().getNextException();

    final VBox root = new VBox(15);
    root.setPadding(new Insets(15));
    root.getStylesheets()
        .add(Dialogs.class.getResource("/resources/css/styles.css").toExternalForm());

    root.getChildren().add(TextBuilder.create().text("Oops...").styleClass("heading").build());

    if (exception.isRecoverable()) {
      root.getChildren()
          .add(
              new Label(
                  "Looks like something went wrong here.\nYou can continue working or quit and call it a day."));
    } else {
      root.getChildren()
          .add(
              new Label(
                  "Looks like something went wrong here.\nUnfortunately, the application cannot continue working."));
    }

    HBox buttons = new HBox(15);
    buttons.setAlignment(Pos.CENTER_RIGHT);

    Button quitButton =
        ButtonBuilder.create()
            .text("Quit")
            .styleClass("quit-button")
            .graphic(LabelBuilder.create().text(Icons.QUIT).styleClass("button-icon").build())
            .onAction(
                new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent t) {
                    System.exit(1);
                  }
                })
            .build();
    buttons.getChildren().add(quitButton);

    final Button continueButton =
        ButtonBuilder.create()
            .text("Continue")
            .onAction(
                new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent t) {
                    root.getScene().getWindow().hide();
                  }
                })
            .build();

    if (exception.isRecoverable()) {
      continueButton.setDefaultButton(true);
      buttons.getChildren().add(continueButton);
    } else {
      quitButton.setDefaultButton(true);
    }

    root.getChildren().add(buttons);

    showDialog(
        root,
        new OnShownAction() {
          @Override
          public void perform() {
            for (Node node : root.lookupAll(".button")) {
              if (node instanceof Button && ((Button) node).isDefaultButton()) {
                node.requestFocus();
              }
            }
          }
        });
  }