Search in sources :

Example 16 with KeyFrame

use of javafx.animation.KeyFrame in project fxexperience2 by EricCanull.

the class FadeOutDownBigTransition method starting.

@Override
protected void starting() {
    double endY = node.getScene().getHeight() - node.localToScene(0, 0).getY();
    timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(node.translateYProperty(), 0, WEB_EASE)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(node.translateYProperty(), endY, WEB_EASE)));
    super.starting();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 17 with KeyFrame

use of javafx.animation.KeyFrame in project fxexperience2 by EricCanull.

the class BounceInDownTransition method starting.

@Override
protected void starting() {
    double startY = -node.localToScene(0, 0).getY() - node.getBoundsInParent().getHeight();
    timeline = new Timeline();
    timeline.getKeyFrames().add(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(node.translateYProperty(), startY, WEB_EASE)));
    timeline.getKeyFrames().add(new KeyFrame(Duration.millis(600), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(node.translateYProperty(), 30, WEB_EASE)));
    timeline.getKeyFrames().add(new KeyFrame(Duration.millis(800), new KeyValue(node.translateYProperty(), -10, WEB_EASE)));
    timeline.getKeyFrames().add(new KeyFrame(Duration.millis(1000), new KeyValue(node.translateYProperty(), 0, WEB_EASE)));
    super.starting();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 18 with KeyFrame

use of javafx.animation.KeyFrame in project fxexperience2 by EricCanull.

the class BounceOutDownTransition method starting.

@Override
protected void starting() {
    double endY = node.getScene().getHeight() - node.localToScene(0, 0).getY();
    timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(node.translateYProperty(), 0, WEB_EASE)), new KeyFrame(Duration.millis(200), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(node.translateYProperty(), -20, WEB_EASE)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(node.translateYProperty(), endY, WEB_EASE)));
    super.starting();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 19 with KeyFrame

use of javafx.animation.KeyFrame in project fxexperience2 by EricCanull.

the class FadeInLeftBigTransition method starting.

@Override
protected void starting() {
    double startX = -node.localToScene(0, 0).getX() - node.getBoundsInParent().getWidth();
    timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(node.translateXProperty(), startX, WEB_EASE)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(node.translateXProperty(), 0, WEB_EASE)));
    super.starting();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 20 with KeyFrame

use of javafx.animation.KeyFrame in project TeachingInSimulation by ScOrPiOzzy.

the class ExamController method initialize.

public void initialize(LibraryPublish publish) {
    clear();
    this.publish = publish;
    this.library = publish.getLibrary();
    this.libraryName.setTitle(library.getName());
    // 创建答题卡项
    List<Question> questions = this.library.getQuestions();
    // // XXX 暂时不做:顺序打乱
    // Collections.shuffle(questions);
    float total = 0f;
    for (int i = 0; i < questions.size(); i++) {
        ToggleButton toggle = new ToggleButton(String.valueOf(i + 1));
        toggle.getStyleClass().add("undo");
        toggle.setUserData(i);
        toggle.setWrapText(false);
        flow.getChildren().add(toggle);
        group.getToggles().add(toggle);
        Question question = questions.get(i);
        LibraryAnswer libraryAnswer = new LibraryAnswer();
        libraryAnswer.setIndex(i);
        libraryAnswer.setQuestion(question);
        libraryAnswer.setQuestionId(question.getId());
        this.answers.put(i, libraryAnswer);
        total += question.getPoint();
    }
    this.total.setText(String.valueOf(total));
    groupListener = (b, o, n) -> {
        if (o == null) {
            return;
        } else if (n == null) {
            this.group.selectToggle(o);
            return;
        }
        if (!submited) {
            // 验证上一个试题是否作答完成
            checkAnswer((ToggleButton) o);
        }
        // 加载下一个试题
        currIndex = (int) n.getUserData();
        prev.setDisable(false);
        next.setDisable(false);
        if (currIndex <= 0) {
            prev.setDisable(true);
        }
        if (currIndex >= questions.size() - 1) {
            next.setDisable(true);
        }
        loadQuestion();
    };
    group.selectedToggleProperty().addListener(groupListener);
    group.selectToggle(group.getToggles().get(0));
    loadQuestion();
    // 启动计时器
    timeline = new Timeline();
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(1), (ActionEvent event1) -> {
        cost++;
        this.minute.setText(String.valueOf(cost / 60));
        this.second.setText(String.valueOf(cost % 60));
    }));
    timeline.play();
}
Also used : LibraryAnswer(com.cas.sim.tis.entity.LibraryAnswer) ToggleButton(javafx.scene.control.ToggleButton) Timeline(javafx.animation.Timeline) ActionEvent(javafx.event.ActionEvent) KeyFrame(javafx.animation.KeyFrame) Question(com.cas.sim.tis.entity.Question)

Aggregations

KeyFrame (javafx.animation.KeyFrame)232 Timeline (javafx.animation.Timeline)197 KeyValue (javafx.animation.KeyValue)150 ActionEvent (javafx.event.ActionEvent)66 FXML (javafx.fxml.FXML)54 Duration (javafx.util.Duration)48 EventHandler (javafx.event.EventHandler)43 Stage (javafx.stage.Stage)40 Alert (javafx.scene.control.Alert)35 Rotate (javafx.scene.transform.Rotate)26 IOException (java.io.IOException)25 URL (java.net.URL)24 ResourceBundle (java.util.ResourceBundle)24 Initializable (javafx.fxml.Initializable)23 Interpolator (javafx.animation.Interpolator)22 JFXButton (com.jfoenix.controls.JFXButton)21 FXMLLoader (javafx.fxml.FXMLLoader)21 MouseEvent (javafx.scene.input.MouseEvent)18 Pane (javafx.scene.layout.Pane)18 Node (javafx.scene.Node)17