本文整理汇总了Java中javafx.animation.TranslateTransition.setDuration方法的典型用法代码示例。如果您正苦于以下问题:Java TranslateTransition.setDuration方法的具体用法?Java TranslateTransition.setDuration怎么用?Java TranslateTransition.setDuration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.animation.TranslateTransition
的用法示例。
在下文中一共展示了TranslateTransition.setDuration方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
@FXML
public void initialize(){
Main.checkFullScreen();
Main.getAlertWindow().setOnCloseRequest(e -> spriteImage.setImage(new Image(Gang.getCarSpriteURL())));
// updating labels
distanceLabel.setText("To go: "+ Gang.getDistance() +"Mi");
conditionsLabel.setText("Condition: "+ Gang.getHealthConditions());
daysLabel.setText("Days: "+ Gang.getDays());
statusLabel.setText("Status: Resting");
// setting up how the animation will work
drivingTransition = new TranslateTransition();
drivingTransition.setDuration(Duration.seconds(animationDuration));
drivingTransition.setToX(Main.getMainWindow().getWidth() - 850);
drivingTransition.setNode(sprite);
drivingTransition.setCycleCount(Animation.INDEFINITE);
// fixes the bug with thread not ending when stage was closed
Main.getMainWindow().setOnCloseRequest(e -> Gang.setMoving(false));
}
示例2: updateGUI
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
@FXML
private void updateGUI(){
spriteImage.setImage(new Image(Gang.getCarSpriteURL()));
// updating drivingTransition
drivingTransition = new TranslateTransition();
drivingTransition.setDuration(Duration.seconds(animationDuration));
drivingTransition.setToX((Main.getMainWindow().getWidth() / -1) - 400);
drivingTransition.setNode(sprite);
drivingTransition.setCycleCount(Animation.INDEFINITE);
// updating labels
distanceLabel.setText("To go: "+ Gang.getDistance() +"Mi");
conditionsLabel.setText("Condition: "+ Gang.getHealthConditions());
daysLabel.setText("Days: "+ Gang.getDays());
statusLabel.setText("Status: Resting");
}
示例3: animation
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
public void animation(int cardid){
TranslateTransition transition = new TranslateTransition();
transition.setDuration(Duration.millis(150));
transition.setNode(hash_hhcard.get(cardid));
transition.setToY(-100);
transition.setAutoReverse(true);
transition.setCycleCount(2);
transition.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
try {
playCard(cardid);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
transition.play();
}
示例4: slideOut
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
/**
* Slides out a node from its current position to it's -width.
*
* @param node - Node to animate
* @param time - Duration of animation
* @return :TranslateTransition object
*/
public TranslateTransition slideOut(AnchorPane node, int time) {
TranslateTransition slide = new TranslateTransition();
slide.setNode(node);
slide.setDuration(Duration.seconds(time));
slide.fromXProperty();
slide.setToX(-node.getWidth() / 1.3);
slide.toXProperty();
return slide;
}
示例5: slideIn
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
/**
* Slides in a node back to its original position.
*
* @param node - Node to animate
* @param time - Duration of animation
* @return :TranslateTransition object
*/
public TranslateTransition slideIn(AnchorPane node, int time) {
TranslateTransition slide = new TranslateTransition();
slide.setNode(node);
slide.setDuration(Duration.seconds(time));
slide.fromXProperty();
slide.setToX(0);
slide.toXProperty();
return slide;
}
示例6: setPagePosition
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
public void setPagePosition(int position) {
if (animationFinished && (position - currentPosition) != 0) {
animationFinished = false;
TranslateTransition transition = new TranslateTransition();
transition.setByX(((TabTitle) (hBox.getChildren().get(0))).getWidth() * (position - currentPosition));
transition.setDuration(Duration.millis(150 * Math.abs(position - currentPosition)));
transition.setInterpolator(Interpolator.LINEAR);
transition.setNode(line);
transition.setOnFinished(e -> {
currentPosition = position;
animationFinished = true;
});
transition.play();
}
}
示例7: startOpenAnimation
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
public void startOpenAnimation(boolean finished) {
TranslateTransition transition = new TranslateTransition();
transition.setNode(this);
transition.setDuration(Duration.millis(500));
if (finished) {
transition.setToX(0);
transition.setOnFinished(ev -> {
drawerOpen = false;
actionBar.setDrawerOpen(false);
oldX = 0;
startX = 0;
});
} else {
transition.setToX(getPrefWidth());
transition.setOnFinished(ev -> {
drawerOpen = true;
actionBar.setDrawerOpen(true);
oldX = 0;
startX = 0;
});
}
transition.play();
animationFinished = false;
}
示例8: onMainMenuHide
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
private void onMainMenuHide() {
TranslateTransition translate = new TranslateTransition();
translate.setNode(mainMenuPane);
translate.setDuration(Duration.millis(MENU_SLIDE_ANIMATION_DURATION));
double width = mainMenuPane.getMinWidth();
translate.setToX(width * -1);
translate.play();
}
示例9: onMainMenuShow
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
private void onMainMenuShow() {
TranslateTransition translate = new TranslateTransition();
translate.setNode(mainMenuPane);
translate.setDuration(Duration.millis(MENU_SLIDE_ANIMATION_DURATION));
translate.setToX(0);
translate.play();
}
示例10: onActionShowMainMenu
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
public void onActionShowMainMenu() {
LoggerFacade.INSTANCE.debug(this.getClass(), "On action show MainMenu"); // NOI18N
// Dont listen in Preview and GameView on KeyEvents
PreferencesFacade.INSTANCE.putBoolean(
IGameConfiguration.PROP__KEY_RELEASED__FOR_GAMEVIEW,
IGameConfiguration.PROP__KEY_RELEASED__FOR_GAMEVIEW__DEFAULT_VALUE);
PreferencesFacade.INSTANCE.putBoolean(
IPreviewConfiguration.PROP__KEY_RELEASED__FOR_PREVIEW,
Boolean.FALSE);
// MainMenuView is shown
PreferencesFacade.INSTANCE.putBoolean(
IMainMenuConfiguration.PROP__MAIN_MENU_IS_SHOWN,
Boolean.TRUE);
// Button
lMenuButton.setDisable(Boolean.TRUE);
// HiddenLayer
apHiddenLayer.setOpacity(0.0d);
apHiddenLayer.setVisible(Boolean.TRUE);
apHiddenLayer.setManaged(Boolean.TRUE);
final FadeTransition ftShowHiddenLayer = new FadeTransition();
ftShowHiddenLayer.setDelay(Duration.millis(125.0d));
ftShowHiddenLayer.setDuration(Duration.millis(250.0d));
ftShowHiddenLayer.setFromValue(0.0d);
ftShowHiddenLayer.setToValue(1.0d);
ftShowHiddenLayer.setNode(apHiddenLayer);
// Init MainMenuView
final MainMenuView mainMenuView = new MainMenuView();
final Parent menu = mainMenuView.getView();
menu.setOpacity(0.0d);
bpMenuArea.setCenter(null);
bpMenuArea.setCenter(menu);
final FadeTransition ftShowMenuView = new FadeTransition();
ftShowMenuView.setDelay(Duration.millis(200.0d));
ftShowMenuView.setDuration(Duration.millis(375.0d));
ftShowMenuView.setFromValue(0.0d);
ftShowMenuView.setToValue(1.0d);
ftShowMenuView.setNode(menu);
ftShowMenuView.setOnFinished((ActionEvent event) -> {
bpMenuArea.setMouseTransparent(Boolean.FALSE);
if (this.hasMediaPlayerFollowing(MediaPlayer.Status.PLAYING)) {
mediaPlayer.pause();
}
ActionFacade.INSTANCE.handle(ON_ACTION__MANAGED_MAP_PLAYER);
});
// Move menu
final TranslateTransition translateTransition = new TranslateTransition();
translateTransition.setDelay(Duration.millis(200.0d));
translateTransition.setDuration(Duration.millis(375.0d));
translateTransition.setFromX(300.0d);
translateTransition.setToX(0.0d);
translateTransition.setNode(menu);
// Animate
final ParallelTransition pt = new ParallelTransition();
pt.getChildren().addAll(ftShowHiddenLayer, ftShowMenuView, translateTransition);
pt.playFromStart();
}
示例11: fazerTransicao
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
public static Transition fazerTransicao(Transicoes transicao, double duracaoSegundos, Node alvo) {
Duration duracao = new Duration(duracaoSegundos * 1000);
Transition t = null;
switch (transicao) {
case FADE:
FadeTransition fadeTransition = new FadeTransition();
fadeTransition.setFromValue(1);
fadeTransition.setToValue(0);
fadeTransition.setDuration(duracao);
fadeTransition.setNode(alvo);
t = fadeTransition;
break;
case FILL:
FillTransition fillTransition = new FillTransition();
fillTransition.setFromValue(Color.RED);
fillTransition.setToValue(Color.DARKGREEN);
fillTransition.setDuration(duracao);
fillTransition.setShape((Shape) alvo);
t = fillTransition;
break;
case ROTATE:
RotateTransition rotateTransition = new RotateTransition();
rotateTransition.setByAngle(360);
rotateTransition.setDuration(duracao);
rotateTransition.setNode(alvo);
t = rotateTransition;
break;
case SCALE:
ScaleTransition scaleTransition = new ScaleTransition();
scaleTransition.setFromX(1);
scaleTransition.setFromY(1);
scaleTransition.setToX(4);
scaleTransition.setToY(4);
scaleTransition.setDuration(duracao);
scaleTransition.setNode(alvo);
t = scaleTransition;
break;
case TRANSLATE:
TranslateTransition translateTransition = new TranslateTransition();
translateTransition.setToX(600);
translateTransition.setToY(250);
translateTransition.setDuration(duracao);
translateTransition.setNode(alvo);
t = translateTransition;
break;
default:
break;
}
t.setAutoReverse(true);
t.setCycleCount(2);
return t;
}