Search in sources :

Example 21 with KeyFrame

use of javafx.animation.KeyFrame in project OTP2_R6_svaap by JNuutinen.

the class GameMain method slideIn.

/**
 * Liukumasiirtymä, näkymää vieritetään vasemmalle.
 * @param from Group, joka vieritetään pois näytöstä. Täytyy olla jo lisättynä Paneen.
 * @param to Group, joka vieritetään näyttöön. Lisätään paneen metodissa.
 * @param pane Pane, jota käsitellään.
 */
private void slideIn(Group from, Group to, Pane pane) {
    pane.getChildren().add(to);
    double width = pane.getWidth();
    KeyFrame start = new KeyFrame(Duration.ZERO, new KeyValue(to.translateXProperty(), width), new KeyValue(from.translateXProperty(), 0));
    KeyFrame end = new KeyFrame(Duration.seconds(0.5), new KeyValue(to.translateXProperty(), 0), new KeyValue(from.translateXProperty(), -width));
    Timeline slide = new Timeline(start, end);
    slide.setOnFinished(e -> pane.getChildren().remove(from));
    slide.play();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 22 with KeyFrame

use of javafx.animation.KeyFrame in project fx2048 by brunoborges.

the class Board method animateScore.

public void animateScore() {
    if (gameMovePoints.get() == 0) {
        return;
    }
    final Timeline timeline = new Timeline();
    lblPoints.setText("+" + gameMovePoints.getValue().toString());
    lblPoints.setOpacity(1);
    double posX = vScore.localToScene(vScore.getWidth() / 2d, 0).getX();
    lblPoints.setTranslateX(0);
    lblPoints.setTranslateX(lblPoints.sceneToLocal(posX, 0).getX() - lblPoints.getWidth() / 2d);
    lblPoints.setLayoutY(20);
    final KeyValue kvO = new KeyValue(lblPoints.opacityProperty(), 0);
    final KeyValue kvY = new KeyValue(lblPoints.layoutYProperty(), 100);
    Duration animationDuration = Duration.millis(600);
    final KeyFrame kfO = new KeyFrame(animationDuration, kvO);
    final KeyFrame kfY = new KeyFrame(animationDuration, kvY);
    timeline.getKeyFrames().add(kfO);
    timeline.getKeyFrames().add(kfY);
    timeline.play();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame) Duration(javafx.util.Duration)

Example 23 with KeyFrame

use of javafx.animation.KeyFrame in project fx2048 by brunoborges.

the class Board method createScore.

private void createScore() {
    Label lblTitle = new Label("2048");
    lblTitle.getStyleClass().addAll("game-label", "game-title");
    Label lblSubtitle = new Label("FX");
    lblSubtitle.getStyleClass().addAll("game-label", "game-subtitle");
    HBox hFill = new HBox();
    HBox.setHgrow(hFill, Priority.ALWAYS);
    hFill.setAlignment(Pos.CENTER);
    VBox vScores = new VBox();
    HBox hScores = new HBox(5);
    vScore.setAlignment(Pos.CENTER);
    vScore.getStyleClass().add("game-vbox");
    Label lblTit = new Label("SCORE");
    lblTit.getStyleClass().addAll("game-label", "game-titScore");
    lblScore.getStyleClass().addAll("game-label", "game-score");
    lblScore.textProperty().bind(gameScoreProperty.asString());
    vScore.getChildren().addAll(lblTit, lblScore);
    VBox vRecord = new VBox(-5);
    vRecord.setAlignment(Pos.CENTER);
    vRecord.getStyleClass().add("game-vbox");
    Label lblTitBest = new Label("BEST");
    lblTitBest.getStyleClass().addAll("game-label", "game-titScore");
    lblBest.getStyleClass().addAll("game-label", "game-score");
    lblBest.textProperty().bind(gameBestProperty.asString());
    vRecord.getChildren().addAll(lblTitBest, lblBest);
    hScores.getChildren().addAll(vScore, vRecord);
    VBox vFill = new VBox();
    VBox.setVgrow(vFill, Priority.ALWAYS);
    vScores.getChildren().addAll(hScores, vFill);
    hTop.getChildren().addAll(lblTitle, lblSubtitle, hFill, vScores);
    hTop.setMinSize(gridWidth, TOP_HEIGHT);
    hTop.setPrefSize(gridWidth, TOP_HEIGHT);
    hTop.setMaxSize(gridWidth, TOP_HEIGHT);
    vGame.getChildren().add(hTop);
    HBox hTime = new HBox();
    hTime.setMinSize(gridWidth, GAP_HEIGHT);
    hTime.setAlignment(Pos.BOTTOM_RIGHT);
    lblTime.getStyleClass().addAll("game-label", "game-time");
    lblTime.textProperty().bind(clock);
    timer = new Timeline(new KeyFrame(Duration.ZERO, e -> {
        clock.set(LocalTime.now().minusNanos(time.toNanoOfDay()).format(fmt));
    }), new KeyFrame(Duration.seconds(1)));
    timer.setCycleCount(Animation.INDEFINITE);
    hTime.getChildren().add(lblTime);
    vGame.getChildren().add(hTime);
    getChildren().add(vGame);
    lblPoints.getStyleClass().addAll("game-label", "game-points");
    lblPoints.setAlignment(Pos.CENTER);
    lblPoints.setMinWidth(100);
    getChildren().add(lblPoints);
}
Also used : HBox(javafx.scene.layout.HBox) Timeline(javafx.animation.Timeline) Label(javafx.scene.control.Label) KeyFrame(javafx.animation.KeyFrame) VBox(javafx.scene.layout.VBox)

Example 24 with KeyFrame

use of javafx.animation.KeyFrame in project Gargoyle by callakrsos.

the class CrudBaseGridView method saveBtnClickHandler.

/**
	 * 저장버튼 클릭 핸들러
	 *
	 * @param saveClickCallbackProperty2
	 *
	 * @Date 2015. 10. 10.
	 * @return
	 * @User KYJ
	 */
private EventHandler<MouseEvent> saveBtnClickHandler(ObjectProperty<Consumer<List<T>>> saveClickCallbackProperty) {
    return new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent event) {
            try {
                Consumer<List<T>> callback = saveClickCallbackProperty.get();
                if (callback == null) {
                    errorMsgCallback.accept("saveClickCallback 함수에 에러메세지 콜백을 등록하세요.");
                    return;
                }
                gridview.fireEvent(event);
                List<T> items = getItems();
                //필수값 검증로직 추가. 2016.12.08
                AbstractVoNullChecker<T> nullCheckHandler = new DefaultVoNullChecker<>(CrudBaseGridView.this);
                nullCheckHandler.setList(items);
                Optional<Field> findFirst = nullCheckHandler.findFirst();
                boolean present = findFirst.isPresent();
                if (present) {
                    String msgFieldName = nullCheckHandler.getMsgNameByfield();
                    //						String message = ValueUtil.getMessage("MSG_W_000001", msgFieldName);
                    int emptyIndex = nullCheckHandler.getEmptyIndex();
                    Set<Node> findAllByNodes = CrudBaseGridView.this.lookupAll("TableRow");
                    findAllByNodes.stream().map(n -> (TableRow) n).filter(r -> {
                        return emptyIndex == r.getIndex();
                    }).findFirst().ifPresent(n -> {
                        Timeline timeline = new Timeline();
                        timeline.setCycleCount(10);
                        timeline.setAutoReverse(true);
                        KeyFrame keyFrame = new KeyFrame(Duration.millis(500), new KeyValue(n.styleProperty(), "-fx-border-color : red ; -fx-border-width : 1px"));
                        KeyFrame keyFrame2 = new KeyFrame(Duration.millis(500), new KeyValue(n.styleProperty(), ""));
                        KeyValue keyValueX = new KeyValue(n.styleProperty(), "-fx-border-color : red ; -fx-border-width : 1px");
                        KeyValue keyValueY = new KeyValue(n.styleProperty(), "");
                        KeyFrame keyFrame3 = new KeyFrame(Duration.seconds(2), "", keyValueX, keyValueY);
                        timeline.getKeyFrames().add(keyFrame3);
                        timeline.play();
                    });
                    getSelectionModel().select(emptyIndex);
                    //						DialogUtil.showMessageDialog(SharedMemory.getPrimaryStage(), msgFieldName + " Field is empty.");
                    return;
                }
                List<T> arrayList = new ArrayList<T>(items);
                arrayList.addAll(deleteItems);
                callback.accept(arrayList);
                // 사용자 정의 로직이 이상없으면 deleteItems 항목도 비운다.
                deleteItems.clear();
            } catch (Exception e) {
                throw e;
            }
        }
    };
}
Also used : EventHandler(javafx.event.EventHandler) Button(javafx.scene.control.Button) Pos(javafx.geometry.Pos) MouseEvent(javafx.scene.input.MouseEvent) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) Insets(javafx.geometry.Insets) KeyValue(javafx.animation.KeyValue) HBox(javafx.scene.layout.HBox) KeyFrame(javafx.animation.KeyFrame) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) Node(javafx.scene.Node) TableRow(javafx.scene.control.TableRow) Set(java.util.Set) Timeline(javafx.animation.Timeline) Field(java.lang.reflect.Field) Objects(java.util.Objects) Consumer(java.util.function.Consumer) List(java.util.List) ActionEvent(javafx.event.ActionEvent) Duration(javafx.util.Duration) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) TableViewSelectionModel(javafx.scene.control.TableView.TableViewSelectionModel) SharedMemory(com.kyj.fx.voeditor.visual.momory.SharedMemory) MouseEvent(javafx.scene.input.MouseEvent) KeyValue(javafx.animation.KeyValue) Node(javafx.scene.Node) ArrayList(java.util.ArrayList) EventHandler(javafx.event.EventHandler) Field(java.lang.reflect.Field) Timeline(javafx.animation.Timeline) TableRow(javafx.scene.control.TableRow) KeyFrame(javafx.animation.KeyFrame) ArrayList(java.util.ArrayList) List(java.util.List) ObservableList(javafx.collections.ObservableList)

Example 25 with KeyFrame

use of javafx.animation.KeyFrame in project bitsquare by bitsquare.

the class Notification method animateDisplay.

@Override
protected void animateDisplay() {
    if (NotificationCenter.useAnimations) {
        double startX = 320;
        double duration = getDuration(600);
        Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1);
        Timeline timeline = new Timeline();
        ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();
        keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.translateXProperty(), startX, interpolator)));
        //bouncing
        /*   keyFrames.add(new KeyFrame(Duration.millis(duration * 0.6),
                    new KeyValue(gridPane.opacityProperty(), 1, interpolator),
                    new KeyValue(gridPane.translateXProperty(), -12, interpolator)
            ));
            keyFrames.add(new KeyFrame(Duration.millis(duration * 0.8),
                    new KeyValue(gridPane.opacityProperty(), 1, interpolator),
                    new KeyValue(gridPane.translateXProperty(), 4, interpolator)
            ));*/
        keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.translateXProperty(), 0, interpolator)));
        timeline.play();
    }
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame) Interpolator(javafx.animation.Interpolator)

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