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();
}
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();
}
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);
}
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;
}
}
};
}
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();
}
}
Aggregations