本文整理汇总了Java中javafx.animation.TranslateTransition.setFromY方法的典型用法代码示例。如果您正苦于以下问题:Java TranslateTransition.setFromY方法的具体用法?Java TranslateTransition.setFromY怎么用?Java TranslateTransition.setFromY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.animation.TranslateTransition
的用法示例。
在下文中一共展示了TranslateTransition.setFromY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPlusScoreAnimation
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
/**
* Animates a label with the plus(new additional value) text.
* @param plus
*/
private void setPlusScoreAnimation(String plus) {
if(plus.length() > 2 ) {
double width = 25 * plus.length();
PLUS_SCORE.setMinSize(width, 45);
}
PLUS_SCORE.setText("+" + plus);
this.setScoreStyle();
PLUS_SCORE.setTextFill(Color.WHITE);
FadeTransition ft = new FadeTransition(Duration.seconds(.7), PLUS_SCORE);
ft.setFromValue(1);
ft.setToValue(0);
ft.play();
TranslateTransition tt = new TranslateTransition(Duration.seconds(.7), PLUS_SCORE);
tt.setFromX(55);
tt.setFromY(-50);
tt.setToY(50);
tt.play();
}
示例2: TransitionForAll
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
private void TransitionForAll(Rectangle rectangle, double layoutXFrom, double layoutXTo, double layoutYFrom, double layoutYTo) {
mainPane.getChildren().add(rectangle);
TranslateTransition translateTransition = new TranslateTransition(Duration.millis(800), rectangle);
translateTransition.setFromX(layoutXFrom);
translateTransition.setToX(layoutXTo);
translateTransition.setFromY(layoutYFrom);
translateTransition.setToY(layoutYTo);
translateTransition.setCycleCount(1);
translateTransition.setAutoReverse(true);
FadeTransition fadeTransition = new FadeTransition(Duration.millis(800), rectangle);
fadeTransition.setFromValue(1.0f);
fadeTransition.setToValue(0f);
fadeTransition.setCycleCount(1);
fadeTransition.setAutoReverse(true);
translateTransition.play();
fadeTransition.play();
rectangle.setDisable(true);
Rectangle newRectangle = new Rectangle(10, 10);
eventExit(rectangle, newRectangle);
}
示例3: initializePromptMoveTransition
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
private void initializePromptMoveTransition() {
ScaleTransition promptScale = new ScaleTransition(promptAnimationDuration, this.promptLabel);
promptScale.setFromX(1);
promptScale.setFromY(1);
promptScale.setToX(.7);
promptScale.setToY(.7);
promptScale.setInterpolator(promptAnimationInterpolator);
TranslateTransition promptTranslate = new TranslateTransition(promptAnimationDuration, this.promptLabel);
promptTranslate.setFromY(0);
promptTranslate.setToY(-AnchorPane.getTopAnchor(this.promptLabel) - 4);
promptTranslate.setInterpolator(promptAnimationInterpolator);
this.promptLabel.translateXProperty().bind(
this.promptLabel.widthProperty()
.multiply(this.promptLabel.scaleXProperty()
.subtract(1)
.divide(2)));
this.promptMoveAnimation = new ParallelTransition(promptScale, promptTranslate);
this.promptUp = false;
}
示例4: show
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
/**
* Laat de Spelregels pane zien in de huidige stage. Er wordt een nieuwe StackPane aangemaakt,
* waarin de nieuwe pane en de huidige pane worden geplaatst. De huidige pane wordt later dan de
* nieuwe pane (van de SpelregelsView) geplaatst, zodat die onderop ligt. De nieuwe pane krijgt
* opnieuw de css styling mee. De nieuwe StackPane wordt in de huidige scene geplaatst van de
* singleton stage.
*/
public void show() {
holder = new StackPane();
holder.getChildren().addAll(stage.getScene().getRoot().getChildrenUnmodifiable());
holder.getChildren().add(stPane);
holder.getStylesheets().add("Machiavelli/Resources/style.css");
FadeTransition ft = new FadeTransition(Duration.millis(300), holder);
ft.setFromValue(0.0);
ft.setToValue(1.0);
ft.play();
TranslateTransition tt = new TranslateTransition(Duration.millis(300), modal);
tt.setFromY(50);
tt.setToY(0);
tt.play();
this.scene = new Scene(holder, 1440, 900);
stage.setScene(scene);
stage.show();
}
示例5: initialize
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
log(CMPDL.title());
log("Java version " + System.getProperty("java.version"));
destinationPath.setText(System.getProperty("user.home") + File.separator + "modpack");
if (System.getProperty("os.name").toLowerCase().contains("win")) {
TranslateTransition transition = new TranslateTransition(Duration.seconds(1), title);
transition.setFromY(-10);
transition.setToY(10);
transition.setCycleCount(Animation.INDEFINITE);
transition.setAutoReverse(true);
transition.play();
}
}
示例6: playBtnSlideIn
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
private void playBtnSlideIn(){
bottomHBox.setVisible(true);
playTrue = true;
TranslateTransition playBtnTransition = new TranslateTransition(Duration.millis(300), bottomHBox);
playBtnTransition.setFromY(56);
playBtnTransition.setToY(0);
playBtnTransition.play();
}
示例7: playBtnSlideOut
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
private void playBtnSlideOut(){
playTrue = false;
TranslateTransition playBtnTransition = new TranslateTransition(Duration.millis(300), bottomHBox);
playBtnTransition.setFromY(0);
playBtnTransition.setToY(56);
playBtnTransition.play();
}
示例8: init
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
public static void init(VBox vbox, Label label) {
notificationBox = vbox;
notificationLabel = label;
transitionIn = new TranslateTransition(TRANSITION_DURATION, notificationBox);
transitionIn.setToY(0);
transitionOut = new TranslateTransition(TRANSITION_DURATION, notificationBox);
transitionOut.setFromY(0);
transitionOut.setOnFinished((e) -> notificationBox.setVisible(false));
}
示例9: updatePosition
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
@Override
public void updatePosition(Point2D moveBy) {
double translateX = holder.getNode().getTranslateX();
double translateY = holder.getNode().getTranslateY();
Point2D playerPosition = new Point2D(translateX, translateY);
this.position = playerPosition;
TranslateTransition smoothMove = new TranslateTransition(
Duration.millis(2000), this.getNode());
smoothMove.setFromX(translateX);
smoothMove.setFromY(translateY);
// FIXME: Change 1000 to screenWidth()
int leftRightDirection = 0;
int upDownDirection = 0;
switch (shootingDirection) {
case ("west"):
leftRightDirection = -1000;
break;
case ("east"):
leftRightDirection = 1000;
break;
case ("north"):
upDownDirection = -1000;
break;
case ("south"):
upDownDirection = 1000;
break;
default:
//some other directions?
break;
}
smoothMove.setByX(this.getPosition().getX() + leftRightDirection);
smoothMove.setByY(this.getPosition().getY() + upDownDirection);
smoothMove.setAutoReverse(true);
smoothMove.setCycleCount(1);
smoothMove.play();
}
示例10: showOrHide
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
/**
* Shows or hides the pane with an animation.
*
* @param stackPane The StackPane, which is shown or hidden.
* @param show True, when shown, false when hidden.
*/
private void showOrHide(final AnimatedStackPane stackPane, final boolean show) {
stackPane.setVisible(true);
ongoingTransitions++;
TranslateTransition translateTransition = new TranslateTransition(Duration.seconds(.5), stackPane);
FadeTransition fadeTransition = new FadeTransition(Duration.seconds(.5), stackPane);
stackPane.setCache(true);
stackPane.setCacheHint(CacheHint.SPEED);
contentPane.setClip(new Rectangle(stackPane.getBoundsInLocal().getWidth(), stackPane.getBoundsInLocal().getHeight()));
if (show) {
translateTransition.setFromY(-stackPane.getBoundsInLocal().getHeight());
translateTransition.setToY(0);
fadeTransition.setToValue(1);
fadeTransition.setFromValue(0);
translateTransition.setInterpolator(new CircularInterpolator(EasingMode.EASE_OUT));
fadeTransition.setInterpolator(new CircularInterpolator(EasingMode.EASE_OUT));
} else {
translateTransition.setToY(-stackPane.getBoundsInLocal().getHeight());
translateTransition.setFromY(0);
fadeTransition.setToValue(0);
fadeTransition.setFromValue(1);
translateTransition.setInterpolator(new CircularInterpolator(EasingMode.EASE_OUT));
fadeTransition.setInterpolator(new CircularInterpolator(EasingMode.EASE_OUT));
}
ParallelTransition parallelTransition = new ParallelTransition();
parallelTransition.getChildren().add(translateTransition);
parallelTransition.getChildren().add(fadeTransition);
parallelTransition.playFromStart();
parallelTransition.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
if (!show) {
titleButton.requestFocus();
stackPane.setVisible(false);
}
stackPane.setCache(false);
ongoingTransitions--;
}
});
}
示例11: handleState
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
private void handleState(final boolean IS_OPEN) {
if (cards.isEmpty()) return;
if (IS_OPEN) {
firstTime = false;
icon.setIconCode(Material.CLOSE);
icon.setIconColor(Color.BLACK);
// Animate to open
openTransition.getChildren().clear();
for (int i = 0 ; i < cards.size() ; i++) {
TranslateTransition openCard = new TranslateTransition(Duration.millis(200), cards.get(i));
openCard.setFromX(cards.get(i).getTranslateX());
openCard.setFromY(cards.get(i).getTranslateY());
openCard.setToX(30 + i * 20);
openCard.setToY(30 + i * 40);
openTransition.getChildren().add(openCard);
};
openTransition.play();
} else {
icon.setIconCode(Material.MENU);
List<Card> allOtherCards = cards.stream().filter(card -> !card.equals(selectedCard)).collect(Collectors.toList());
// Animate to close
closeTransition.getChildren().clear();
TranslateTransition selectedCardTranslate = new TranslateTransition(Duration.millis(200), selectedCard);
selectedCardTranslate.setFromX(selectedCard.getTranslateX());
selectedCardTranslate.setFromY(selectedCard.getTranslateY());
selectedCardTranslate.setToX(0);
selectedCardTranslate.setToY(0);
ParallelTransition moveAllOut = new ParallelTransition();
allOtherCards.forEach(card -> {
TranslateTransition moveCardToRight = new TranslateTransition(Duration.millis(200), card);
moveCardToRight.setFromX(card.getTranslateX());
moveCardToRight.setFromY(card.getTranslateY());
moveCardToRight.setToX(getWidth() + 100);
moveCardToRight.setToY(card.getTranslateY());
moveAllOut.getChildren().addAll(moveCardToRight);
});
closeTransition.getChildren().addAll(moveAllOut, selectedCardTranslate);
closeTransition.setOnFinished(e -> icon.setIconColor(Color.WHITE));
closeTransition.play();
}
}
示例12: FilterEditingMenuView
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
/**
* <p>
* Creates a new FilterEditingMenuView. Through the FilterEditingMenuView you can add or
* edit filters.
* </p>
*
* @param config The config object that is used to access configuration data from the configuration files.
* @param filterViewModel The object that is used to create a new {@link FilterInput} object.
*/
public FilterEditingMenuView(final IConfig config,
final FilterViewModel filterViewModel) {
super("filter_edit_menu_overlay.fxml", new EnumMap<>(FilterInteraction.class));
// Load the labels
this.config = config;
SELECTION_LABEL = this.config.getProperty("SELECTION_LABEL");
INVERSE_SELECTION_LABEL = this.config.getProperty("INVERSE_SELECTION_LABEL");
MAC_LABEL = this.config.getProperty("MAC_LABEL");
IP_LABEL = this.config.getProperty("IP_LABEL");
NAME_LABEL = this.config.getProperty("NAME_LABEL");
// Set up the filterViewModel
this.filterViewModel = filterViewModel;
this.filterViewModel.setErrorText(errorText);
// Add menu to stackpane
// this.stackPane = stackPane;
// this.stackPane.getChildren().add(this);
StackPane.setAlignment(this, Pos.TOP_CENTER);
// Set up transition animation to show menu
transitionShow = new TranslateTransition(Duration.seconds(0.5), this);
transitionShow.setFromY(-450);
transitionShow.setToY(0);
// Set up transition animation to hide menu
transitionHide = new TranslateTransition(Duration.seconds(0.5), this);
transitionHide.setFromY(0);
transitionHide.setToY(-450);
// Hide by default
//stackPane.setVisible(false);
//this.setVisible(false);
// Fill combo-boxes
selectionComboBox.getItems().setAll(SELECTION_LABEL, INVERSE_SELECTION_LABEL);
filterByComboBox.getItems().setAll(IP_LABEL, MAC_LABEL, NAME_LABEL);
// Set up the buttons
createButton.setOnAction(eventHandler -> {
if (updatingFilter == null) {
addFilter();
} else {
updateFilter(updatingFilter);
}
});
cancelButton.setOnAction(eventHandler -> cancel());
helpButton.setOnAction(eventHandler -> help());
}
示例13: validateInput
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
public void validateInput() {
ValidationResult validation = this.getInputValidationCallback().call(this.getText());
if (this.previousResult != null && this.previousResult.equals(validation)) {
return;
}
this.previousResult = validation;
this.hintLabel.setText(validation.getMessage());
this.hintIcon.getStyleClass().clear();
this.hintIcon.getStyleClass().addAll("icon-pane", "message-icon");
if (validation.getIconStyleClasses().length > 0) {
this.hintIcon.getStyleClass().addAll(validation.getIconStyleClasses());
}
this.hintIcon.setOpacity(validation.getIconStyleClasses().length > 0 ? 1 : 0);
this.hintIcon.setStyle(String.format("-fx-background-color: #%02x%02x%02x%02x;",
(int)(validation.getMessageColor().getRed() * 255),
(int)(validation.getMessageColor().getGreen() * 255),
(int)(validation.getMessageColor().getBlue() * 255),
(int)(validation.getMessageColor().getOpacity() * 255)));
this.hintLabel.setTextFill(validation.messageColor);
// fade the secondary hint container in and slide it in from the top
FadeTransition secondaryFadeIn = new FadeTransition(
hintAnimationDuration, this.hintContainer);
secondaryFadeIn.setFromValue(0);
secondaryFadeIn.setToValue(1);
secondaryFadeIn.setInterpolator(hintAnimationInterpolator);
TranslateTransition secondaryTranslate = new TranslateTransition(
hintAnimationDuration, this.hintContainer);
secondaryTranslate.setFromY(-this.hintContainer.getHeight());
secondaryTranslate.setToY(0);
secondaryTranslate.setInterpolator(hintAnimationInterpolator);
// create a smooth transition for the color of the active underline
ObjectProperty<Color> highlightColor = new SimpleObjectProperty<>();
highlightColor.addListener((ov, o, n) -> {
this.activeUnderline.setStyle(String.format(
"-fx-background-color: #%02x%02x%02x%02x;",
(int)(n.getRed() * 255),
(int)(n.getGreen() * 255),
(int)(n.getBlue() * 255),
(int)(n.getOpacity() * 255)));
});
if (this.previousBackgroundColor == null) {
this.previousBackgroundColor = validation.getUnderlineColor();
}
Timeline highlightTransition = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(highlightColor,
this.previousBackgroundColor)),
new KeyFrame(hintAnimationDuration, new KeyValue(highlightColor,
validation.getUnderlineColor(),
hintAnimationInterpolator)));
this.previousBackgroundColor = validation.getUnderlineColor();
if (this.hintAnimation != null) {
this.hintAnimation.stop();
}
this.hintAnimation = new ParallelTransition(
secondaryFadeIn,
secondaryTranslate,
highlightTransition);
this.hintAnimation.play();
}
示例14: start
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
public void start(Stage stage) throws Exception
{
BorderPane contentPane = new BorderPane();
HBox top = new HBox();
top.getChildren().add(new Label("Top Area"));
top.setStyle("-fx-background-color: blue");
top.setPrefHeight(100);
contentPane.setTop(top);
HBox bottom = new HBox();
bottom.getChildren().add(new Label("Green Area"));
bottom.setStyle("-fx-background-color: green");
bottom.setPrefHeight(100);
contentPane.setBottom(bottom);
HBox left = new HBox();
left.getChildren().add(new Label("Green Area"));
left.setStyle("-fx-background-color: yellow");
left.setPrefWidth(100);
contentPane.setLeft(left);
HBox right = new HBox();
right.getChildren().add(new Label("Right Area"));
right.setStyle("-fx-background-color: red");
right.setPrefWidth(100);
contentPane.setRight(right);
FlowPane animationArea = new FlowPane();
Label label = new Label("Look at me, I'm flying!");
label.setStyle("-fx-background-color: #ffd; -fx-background-radius: 3; -fx-border-color: gray; -fx-background-radius: 3; ");
animationArea.getChildren().add(label);
contentPane.setCenter(animationArea);
Scene scene = new Scene(contentPane, 800, 600);
scene.getStylesheets().add("styles.css");
stage.setScene(scene);
stage.show();
TranslateTransition animation = new TranslateTransition(Duration.millis(2000), label);
animation.setFromX(-100);
animation.setToX(800);
animation.setFromY(-400);
animation.setToY(400);
animation.setAutoReverse(true);
animation.setCycleCount(Animation.INDEFINITE);
animation.playFromStart();
}
示例15: showOrHide
import javafx.animation.TranslateTransition; //导入方法依赖的package包/类
private void showOrHide(
CalendarControl<T> control,
Button titleButton,
SlidingStackPane stackPane,
boolean show
) {
Duration duration = control.lengthOfAnimationsProperty().get();
if (duration.lessThanOrEqualTo(Duration.ZERO)) {
if (!show) {
titleButton.requestFocus();
}
stackPane.updateVisibility(show);
return;
}
stackPane.updateVisibility(true);
control.ongoingTransitionsProperty().set(control.ongoingTransitionsProperty().get() + 1);
TranslateTransition translateTransition = new TranslateTransition(duration, stackPane);
FadeTransition fadeTransition = new FadeTransition(duration, stackPane);
translateTransition.setInterpolator(Interpolator.EASE_OUT);
fadeTransition.setInterpolator(Interpolator.EASE_OUT);
stackPane.setCache(true);
stackPane.setCacheHint(CacheHint.SPEED);
if (show) {
translateTransition.setFromY(-stackPane.getBoundsInLocal().getHeight());
translateTransition.setToY(0);
fadeTransition.setToValue(1);
fadeTransition.setFromValue(0);
} else {
translateTransition.setToY(-stackPane.getBoundsInLocal().getHeight());
translateTransition.setFromY(0);
fadeTransition.setToValue(0);
fadeTransition.setFromValue(1);
}
this.setClip(new Rectangle(stackPane.getBoundsInLocal().getWidth(), stackPane.getBoundsInLocal().getHeight()));
ParallelTransition parallelTransition = new ParallelTransition();
parallelTransition.getChildren().add(translateTransition);
parallelTransition.getChildren().add(fadeTransition);
parallelTransition.playFromStart();
parallelTransition.setOnFinished(
actionEvent -> {
if (!show) {
titleButton.requestFocus();
stackPane.updateVisibility(false);
}
stackPane.setCache(false);
control.ongoingTransitionsProperty().set(control.ongoingTransitionsProperty().get() - 1);
}
);
}