예제 #1
0
 public Pane getCSSStyledPane() {
   Pane p = new Pane();
   p.setPrefSize(100, 50);
   p.setStyle(
       "-fx-background-color: lightgray, red;"
           + "-fx-background-insets: 0, 4;"
           + "-fx-background-radius: 4, 2;");
   return p;
 }
  @Override
  public void onDisplay() {
    GoogleUINaviController naviController =
        UIStateController.getInstance().getGoogleNaviController();
    album = naviController.getActiveAlbum();
    setPager(naviController.getPager());

    albumNode = (Pane) naviController.getSelectedAlbumNode();
    albumNode.setStyle(GoogleUINaviController.STYLE_INACTIVE);

    showPlayerMode(true);
    updatePage(album.getActiveSong());
  }
예제 #3
0
파일: Main.java 프로젝트: Vinusla/ContaCRF
 @Override
 public void init() {
   ImageView splash = new ImageView(new Image(SPLASH_IMAGE));
   loadProgress = new ProgressBar();
   loadProgress.setPrefWidth(SPLASH_WIDTH);
   progressText = new Label("Will find friends for peanuts . . .");
   splashLayout = new VBox();
   splashLayout.getChildren().addAll(splash, loadProgress, progressText);
   progressText.setAlignment(Pos.CENTER);
   splashLayout.setStyle(
       "-fx-padding: 5; "
           + "-fx-background-color: white; "
           + "-fx-border-width:5; "
           + "-fx-border-color: "
           + "linear-gradient("
           + "to bottom, "
           + "green, "
           + "derive(green, 50%)"
           + ");");
   splashLayout.setEffect(new DropShadow());
 }
예제 #4
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);
    }
예제 #5
0
    public MediaControl(final MediaPlayer mp) {
      this.mp = mp;
      setStyle("-fx-background-color: #bfc2c7;"); // TODO: Use css file
      mediaView = new MediaView(mp);
      Pane mvPane = new Pane() {};

      mvPane.getChildren().add(mediaView);
      mvPane.setStyle("-fx-background-color: black;"); // TODO: Use css file
      setCenter(mvPane);
      mediaBar = new HBox();
      mediaBar.setPadding(new Insets(5, 10, 5, 10));
      mediaBar.setAlignment(Pos.CENTER_LEFT);
      BorderPane.setAlignment(mediaBar, Pos.CENTER);

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

              if (status == Status.PAUSED || status == Status.READY || status == 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() {
              // System.out.println("onPlaying");
              if (stopRequested) {
                mp.pause();
                stopRequested = false;
              } else {
                playButton.setGraphic(imageViewPause);
                // playButton.setText("||");
              }
            }
          });
      mp.setOnPaused(
          new Runnable() {
            public void run() {
              // System.out.println("onPaused");
              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);
      // Add spacer
      Label spacer = new Label("   ");
      mediaBar.getChildren().add(spacer);
      // Time label
      Label timeLabel = new Label("Time: ");
      timeLabel.setMinWidth(Control.USE_PREF_SIZE);
      mediaBar.getChildren().add(timeLabel);
      // Time slider
      timeSlider = new Slider();
      HBox.setHgrow(timeSlider, Priority.ALWAYS);
      timeSlider.setMinWidth(50);
      timeSlider.setMaxWidth(Double.MAX_VALUE);
      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 = new Label();
      playTime.setPrefWidth(130);
      playTime.setMinWidth(50);
      mediaBar.getChildren().add(playTime);
      // Volume label
      Label volumeLabel = new Label("Vol: ");
      volumeLabel.setMinWidth(Control.USE_PREF_SIZE);
      mediaBar.getChildren().add(volumeLabel);
      // Volume slider
      volumeSlider = new Slider();
      volumeSlider.setPrefWidth(70);
      volumeSlider.setMaxWidth(Region.USE_PREF_SIZE);
      volumeSlider.setMinWidth(30);
      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(Stage stage) {
    LoginFX.stage = stage;
    stage.setTitle("SGAP - Login");
    pane = new Pane();
    pane.setPrefSize(400, 120);
    pane.setStyle(
        "-fx-background-color:linear-gradient(from 0% 0% to 100% 100%, silver 0%, gold 100%);");

    tfLogin = new TextField();
    tfLogin.setPromptText("Digite aqui seu login");
    tfLogin.setPrefSize(200, tfLogin.getFont().getSize());
    tfSenha = new PasswordField();
    tfSenha.setPromptText("Digite aqui a senha");
    tfSenha.setPrefSize(200, tfSenha.getFont().getSize());
    tfSenha.setOnKeyPressed(
        new EventHandler<KeyEvent>() {

          @Override
          public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.ENTER) {
              botaoLogar();
            }
          }
        });

    bEntrar = new Button("Entrar");
    bEntrar.setPrefSize(100, bEntrar.getFont().getSize() + 5);
    bEntrar.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            botaoLogar();
          }
        });
    bSair = new Button("Sair");
    bSair.setPrefSize(100, bSair.getFont().getSize() + 5);
    bSair.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            botaoSair();
          }
        });

    tfLogin.setLayoutX(
        (pane.getPrefWidth() - 1.5 * bEntrar.getPrefWidth() - tfLogin.getPrefWidth()) / 2);
    tfSenha.setLayoutX(
        (pane.getPrefWidth() - 1.5 * bEntrar.getPrefWidth() - tfLogin.getPrefWidth()) / 2);
    bEntrar.setLayoutX(
        (pane.getPrefWidth() + 3.5 * bEntrar.getPrefWidth() - tfLogin.getPrefWidth()) / 2);
    bSair.setLayoutX(
        (pane.getPrefWidth() + 3.5 * bEntrar.getPrefWidth() - tfLogin.getPrefWidth()) / 2);
    tfLogin.setLayoutY((pane.getPrefHeight() - tfLogin.getPrefHeight()) / 2 - 20);
    tfSenha.setLayoutY((pane.getPrefHeight() - tfLogin.getPrefHeight()) / 2 + 20);
    bEntrar.setLayoutY((pane.getPrefHeight() - tfLogin.getPrefHeight()) / 2 - 20);
    bSair.setLayoutY((pane.getPrefHeight() - tfLogin.getPrefHeight()) / 2 + 20);

    pane.getChildren().addAll(tfLogin, tfSenha, bEntrar, bSair);
    Scene cena = new Scene(pane);
    stage.setScene(cena);
    stage.show();
  }