예제 #1
0
파일: Main.java 프로젝트: kofer99/testcode
  @Override
  public void start(Stage primaryStage) {
    try {
      Group root = new Group();
      Scene scene = new Scene(root, 400, 400);
      scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
      primaryStage.setScene(scene);
      primaryStage.show();

      final Rectangle rectBasicTimeline = new Rectangle();
      rectBasicTimeline.setX(0);
      rectBasicTimeline.setY(0);
      rectBasicTimeline.widthProperty().bind(scene.widthProperty());
      rectBasicTimeline.heightProperty().bind(scene.heightProperty());
      rectBasicTimeline.setFill(Color.RED);
      root.getChildren().add(rectBasicTimeline);
      final Timeline timeline = new Timeline();
      timeline.setCycleCount(Timeline.INDEFINITE);
      timeline.setAutoReverse(true);
      final KeyValue kv1 = new KeyValue(rectBasicTimeline.fillProperty(), Color.YELLOW);
      final KeyValue kv2 = new KeyValue(rectBasicTimeline.fillProperty(), Color.GREEN);
      final KeyValue kv3 = new KeyValue(rectBasicTimeline.fillProperty(), Color.BLUE);
      final KeyFrame kf1 = new KeyFrame(Duration.millis(5000), kv1);
      final KeyFrame kf2 = new KeyFrame(Duration.millis(10000), kv2);
      final KeyFrame kf3 = new KeyFrame(Duration.millis(15000), kv3);
      timeline.getKeyFrames().add(kf1);
      timeline.getKeyFrames().add(kf2);
      timeline.getKeyFrames().add(kf3);
      timeline.play();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #2
0
  private void runProcessingAnimation(double duration) {
    timeline.setAutoReverse(true);
    timeline.setCycleCount(2);

    //        transitionRect = new TranslateTransition(Duration.millis(duration), rectangle);
    //        transitionCircle = new TranslateTransition(Duration.millis(duration), circle);
    transitionCircle.setDuration(Duration.millis(duration));
    transitionCircle.setNode(circle);
    transitionCircle.setAutoReverse(false);
    transitionCircle.setByX(150);
    transitionCircle.setFromX(0);

    transitionRect.setAutoReverse(false);
    transitionRect.setDuration(Duration.millis(duration));
    transitionRect.setNode(rectangle);
    transitionRect.setByX(150);
    transitionRect.setFromX(0);

    KeyValue keyValue = new KeyValue(imageViewTop.translateYProperty(), 90);
    KeyFrame keyFrame =
        new KeyFrame(
            Duration.millis(duration),
            (ActionEvent) -> {
              toggleHide(rectangle);
              transitionRect.play();
              transitionCircle.play();
              stackProducts(rectangle, imageViewRightStorage, this);
            },
            keyValue);

    timeline.getKeyFrames().clear();
    timeline.getKeyFrames().add(keyFrame);
    timeline.play();
  }
예제 #3
0
  void animateRoute(List<Path> path, Circle entranceMarker, GraphicsContext gc) {
    double entranceX = entranceMarker.getCenterX();
    double entranceY = entranceMarker.getCenterY();

    int currentKeyFrameTimeInMs = 0, keyframeTimeInMs = 50;

    List<KeyFrame> keyFrames = new ArrayList<>();
    List<AnimationTimer> timers = new ArrayList<>();

    for (int i = 0; i < path.size(); i++) {
      Path pathEntry = path.get(i);
      DoubleProperty opacity = new SimpleDoubleProperty();
      keyFrames.add(
          new KeyFrame(Duration.millis(currentKeyFrameTimeInMs), new KeyValue(opacity, 0)));
      keyFrames.add(
          new KeyFrame(
              Duration.millis(currentKeyFrameTimeInMs + keyframeTimeInMs),
              new KeyValue(opacity, 0.3)));

      timeline.setAutoReverse(true);
      timeline.setCycleCount(1);

      currentKeyFrameTimeInMs += keyframeTimeInMs;

      timers.add(
          new AnimationTimer() {
            @Override
            public void handle(long now) {
              gc.setFill(Color.FORESTGREEN.deriveColor(0, 1, 1, opacity.get()));
              if (maze.representation().length > 24) {
                gc.fillRect(
                    entranceX + calculateNextPosX(pathEntry.x, 2) - 20,
                    entranceY + calculateNextPosY(pathEntry.y, 2) - 176,
                    CELL_LENGTH,
                    CELL_LENGTH);
              } else {
                gc.fillRect(
                    entranceX + calculateNextPosX(pathEntry.x, 5) - 23,
                    entranceY + calculateNextPosY(pathEntry.y, 5) - 178,
                    CELL_LENGTH,
                    CELL_LENGTH);
              }
            }
          });
    }

    timeline.getKeyFrames().addAll(keyFrames);

    for (int i = 0; i < path.size(); i++) {
      timers.get(i).start();
    }
    timeline.play();
  }
 /*     */ public Object animate(KeyFrame[] paramArrayOfKeyFrame) /*     */ {
   /*  87 */ Timeline localTimeline = new Timeline();
   /*  88 */ localTimeline.setAutoReverse(false);
   /*  89 */ localTimeline.setCycleCount(1);
   /*  90 */ localTimeline.getKeyFrames().addAll(paramArrayOfKeyFrame);
   /*  91 */ localTimeline.setOnFinished(this);
   /*     */
   /*  93 */ if (this.activeTimeLines.isEmpty()) start();
   /*     */
   /*  95 */ this.activeTimeLines.put(localTimeline, localTimeline);
   /*     */
   /*  97 */ localTimeline.play();
   /*  98 */ return localTimeline;
   /*     */ }