javafx.animation.Timeline.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中javafx.animation.Timeline.<init>()方法的一些代码示例,展示了Timeline.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timeline.<init>()方法的具体详情如下:
包路径:javafx.animation.Timeline
类名称:Timeline
方法名:<init>

Timeline.<init>介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

Timeline fiveSecondsWonder = new Timeline(new KeyFrame(Duration.seconds(5), new EventHandler<ActionEvent>() {

  @Override
  public void handle(ActionEvent event) {
    System.out.println("this is called every 5 seconds on UI thread");
  }
}));
fiveSecondsWonder.setCycleCount(Timeline.INDEFINITE);
fiveSecondsWonder.play();

代码示例来源:origin: jfoenixadmin/JFoenix

@Override
public <U> void setViewContext(ViewContext<U> context) {
  updatePlaceholder(context.getRootNode());
  if (animation != null) {
    animation.stop();
  }
  animation = new Timeline();
  animation.getKeyFrames().addAll(animationProducer.apply(this));
  animation.getKeyFrames().add(new KeyFrame(duration, (e) -> clearPlaceholder()));
  animation.play();
}

代码示例来源:origin: stackoverflow.com

DoubleProperty y  = new SimpleDoubleProperty();
Timeline timeline = new Timeline(
  new KeyFrame(Duration.seconds(0),
      new KeyValue(x, 0),
timeline.setCycleCount(Timeline.INDEFINITE);
stage.setScene(
  new Scene(
    new Group(
stage.show();
timeline.play();

代码示例来源:origin: stackoverflow.com

stage.setScene(new Scene(layout));
stage.show();
  @Override
  public void handle(ActionEvent actionEvent) {
    Timeline flash = new Timeline(
      new KeyFrame(Duration.seconds(0),    new KeyValue(warningColor, Color.GRAY, Interpolator.LINEAR)),
      new KeyFrame(Duration.seconds(0.25), new KeyValue(warningColor, Color.GRAY, Interpolator.LINEAR)),

代码示例来源:origin: stackoverflow.com

private void createSlideshow(Stage stage, ArrayList<BufferedImage> slideList, int durationInSecs) throws InterruptedException {

  stage.show();
  Timeline slideshow = new Timeline();

  ImageView slide = new ImageView();

  for (int i = 0; i < slideList.size(); i++) {
    BufferedImage bi = slideList.get(i);
    KeyFrame newImageFrame = new KeyFrame(Duration.seconds(durationInSeconds * 3 * i), e -> 
      slide.setImage(SwingFXUtils.toFXImage(bi, null)));

    KeyFrame startFadeIn = new KeyFrame(Duration.seconds(durationInSeconds * 3 * i), 
      new KeyValue(slide.opacityProperty(), 0));

    KeyFrame endFadeIn = new KeyFrame(Duration.seconds(durationsInSeconds * (3 * i + 1)), 
      new KeyValue(slide.opacityProperty(), 1));

    KeyFrame startFadeOut = new KeyFrame(Duration.seconds(durationInSeconds * (3 * i + 2)), 
      new KeyValue(slide.opacityProperty(), 1));

    slideshow.getKeyFrames().addAll(newImageFrame, startFadeIn, endFadeIn, startFadeOut);

  }
  slideshow.play();
}

代码示例来源:origin: jfoenixadmin/JFoenix

timeline.getKeyFrames().clear();
timeline = new Timeline(blueFrame[0],
  blueFrame[1],
  blueFrame[2],
  greenFrame[3],
  endingFrame);
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.setDelay(Duration.ZERO);
timeline.playFromStart();

代码示例来源:origin: stackoverflow.com

PseudoClass flashHighlight = PseudoClass.getPseudoClass("flash-highlight");
Node flashingNode = ... ;

Timeline flasher = new Timeline(

  new KeyFrame(Duration.seconds(0.5), e -> {
    flashingNode.pseudoClassStateChanged(flashHighlight, true);
  }),

  new KeyFrame(Duration.seconds(1.0), e -> {
    flashingNode.pseudoClassStateChanged(flashHighlight, false);
  })
);
flasher.setCycleCount(Animation.INDEFINITE);

代码示例来源:origin: jfoenixadmin/JFoenix

public void show() {
  dialog.setOpacity(0);
  //		pickerDecorator.setOpacity(0);
  if (dialog.getOwner() != null) {
    dialog.widthProperty().addListener(positionAdjuster);
    dialog.heightProperty().addListener(positionAdjuster);
    positionAdjuster.invalidated(null);
  }
  if (dialog.getScene() == null) {
    dialog.setScene(customScene);
  }
  curvedColorPicker.preAnimate();
  dialog.show();
  if (initOnce) {
    initRun.run();
    initOnce = false;
  }
  Timeline timeline = new Timeline(new KeyFrame(Duration.millis(120),
    new KeyValue(dialog.opacityProperty(),
      1,
      Interpolator.EASE_BOTH)));
  timeline.setOnFinished((finish) -> curvedColorPicker.animate());
  timeline.play();
}

代码示例来源:origin: stackoverflow.com

public void moveCircle(Circle circle, Scene scene) {
  Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), ev -> {
    circle.setCenterX(random((int) scene.getX()));
    circle.setCenterY(random((int) scene.getY()));
  }));
  timeline.setCycleCount(Animation.INDEFINITE);
  timeline.play();
}

代码示例来源:origin: stackoverflow.com

public class Main extends Application {

public static void main(String[] args) {
  launch(args);
}

@Override
public void start(Stage primaryStage) throws Exception {
  IntegerProperty letters= new SimpleIntegerProperty(0);
  Label label = new Label();
  Button animate = new Button("animate");
  letters.addListener((a, b, c) -> {
    label.setText("animate".substring(0, c.intValue()));
  });

  animate.setOnAction((e)->{
    Timeline timeline = new Timeline();
    KeyValue kv = new KeyValue(letters, "animate".length());
    KeyFrame kf = new KeyFrame(Duration.seconds(3), kv);
    timeline.getKeyFrames().add(kf);
    timeline.play();
  });
  BorderPane pane = new BorderPane(label, null, null, animate, null);

  primaryStage.setScene(new Scene(pane, 300,300));
  primaryStage.show();
}
}

代码示例来源:origin: jfoenixadmin/JFoenix

private void hideError() {
  if (heightChanged) {
    new Timeline(new KeyFrame(Duration.millis(160),
      new KeyValue(translateYProperty(), 0, Interpolator.EASE_BOTH))).play();
    // reset the height of text field
    new Timeline(new KeyFrame(Duration.millis(160),
      new KeyValue(minHeightProperty(), initHeight, Interpolator.EASE_BOTH))).play();
    heightChanged = false;
  }
  // clear error label text
  errorLabel.setText(null);
  oldErrorLabelHeight = errorLabelInitHeight;
  // clear error icon
  errorIcon.getChildren().clear();
  // reset the height of the text field
  currentFieldHeight = initHeight;
  // hide error container
  errorContainer.setVisible(false);
  errorShown = false;
}

代码示例来源:origin: com.nexitia.emaginplatform/emagin-jfxcore-engine

public void show(boolean autohide) {
 if(canShow) {
  _prepareShow(autohide);
  dialogStage.getScene().getRoot().opacityProperty().set(0);
  dialogStage.show();
  Timeline timeline = new Timeline();
  KeyFrame key = new KeyFrame(Duration.millis(100),
    new KeyValue (dialogStage.getScene().getRoot().opacityProperty(), 1));
  timeline.getKeyFrames().add(key);
  timeline.play();
  canShow = false;
 }
}

代码示例来源:origin: org.reactfx/reactfx

private FxTimer(java.time.Duration timeout, Runnable action, int cycles) {
  this.timeout = Duration.millis(timeout.toMillis());
  this.timeline = new Timeline();
  this.action = action;
  timeline.setCycleCount(cycles);
}

代码示例来源:origin: jfoenixadmin/JFoenix

jfxBarInf.setProgress(-1.0f);
Timeline timeline = new Timeline(
  new KeyFrame(
    Duration.ZERO,
    new KeyValue(jfxBar.progressProperty(), 1)));
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
scene.getStylesheets().add(ProgressBarDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
stage.setTitle("JFX ProgressBar Demo ");
stage.setScene(scene);
stage.setResizable(false);
stage.show();

代码示例来源:origin: jfoenixadmin/JFoenix

final double[] derivatives = new double[frictions.length];
Timeline timeline = new Timeline();
final EventHandler<MouseEvent> dragHandler = event -> timeline.stop();
final EventHandler<ScrollEvent> scrollHandler = event -> {
      timeline.play();
timeline.setCycleCount(Animation.INDEFINITE);

代码示例来源:origin: stackoverflow.com

public class StageFadeExample extends Application {

  @Override
  public void start(Stage arg0) throws Exception {
    Stage stage = new Stage();
    stage.initStyle(StageStyle.TRANSPARENT); //Removes window decorations

    Button close = new Button("Fade away");
    close.setOnAction((actionEvent) ->  {
      Timeline timeline = new Timeline();
      KeyFrame key = new KeyFrame(Duration.millis(2000),
              new KeyValue (stage.getScene().getRoot().opacityProperty(), 0)); 
      timeline.getKeyFrames().add(key);   
      timeline.setOnFinished((ae) -> System.exit(1)); 
      timeline.play();
    });

    Scene scene = new Scene(close, 300, 300);
    scene.setFill(Color.TRANSPARENT); //Makes scene background transparent
    stage.setScene(scene);
    stage.show();
  }

  public static void main (String[] args) {
    launch();
  }
}

代码示例来源:origin: speedment/speedment

fade.play();
  final Timeline timeline = new Timeline(new KeyFrame(
    TIMER, ev -> ref.get().fadeAway()
  ));
  timeline.play();
});

代码示例来源:origin: torakiki/pdfsam

Timeline timeline = new Timeline(new KeyFrame(Duration.millis(2500)),
    new KeyFrame(Duration.millis(0), new KeyValue(node.scaleXProperty(), 1, EASE_BOTH),
        new KeyValue(node.scaleYProperty(), 1, EASE_BOTH),
        new KeyValue(node.scaleYProperty(), 1, EASE_BOTH),
        new KeyValue(node.rotateProperty(), 0, EASE_BOTH)));
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.setDelay(Duration.millis(2000));
return timeline;

代码示例来源:origin: stackoverflow.com

final ProgressBar bar = new ProgressBar();
final Timeline timeline = new Timeline(
 new KeyFrame(Duration.millis(0),    new KeyValue(bar.progressProperty(), 0)),
 new KeyFrame(Duration.millis(3000), new KeyValue(bar.progressProperty(), 1))
layout.getChildren().setAll(bar, reset);
layout.getStylesheets().add(getClass().getResource("progress.css").toExternalForm());
stage.setScene(new Scene(layout));
stage.show();
timeline.play();

代码示例来源:origin: jfoenixadmin/JFoenix

@PostConstruct
public void init() {
  Timeline timeline = new Timeline(
    new KeyFrame(
      Duration.ZERO,
      new KeyValue(blueSpinner.progressProperty(), 0),
      new KeyValue(greenSpinner.progressProperty(), 0)
    ),
    new KeyFrame(
      Duration.seconds(0.5),
      new KeyValue(greenSpinner.progressProperty(), 0.5)
    ),
    new KeyFrame(
      Duration.seconds(2),
      new KeyValue(blueSpinner.progressProperty(), 1),
      new KeyValue(greenSpinner.progressProperty(), 1)
    )
  );
  timeline.setCycleCount(Timeline.INDEFINITE);
  timeline.play();
}

相关文章