本文整理匯總了Java中javafx.animation.FadeTransition.play方法的典型用法代碼示例。如果您正苦於以下問題:Java FadeTransition.play方法的具體用法?Java FadeTransition.play怎麽用?Java FadeTransition.play使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.animation.FadeTransition
的用法示例。
在下文中一共展示了FadeTransition.play方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: seriesRemoved
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
@Override protected void seriesRemoved(Series<Number, Number> series) {
// remove all candle nodes
for (XYChart.Data<Number, Number> d : series.getData()) {
final Node candle = d.getNode();
if (shouldAnimate()) {
// fade out old candle
FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
ft.setToValue(0);
ft.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
getPlotChildren().remove(candle);
}
});
ft.play();
} else {
getPlotChildren().remove(candle);
}
}
}
示例2: setExitAnimationToNode
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
/**
*
* @param root
*/
private void setExitAnimationToNode(Node root) {
if(about.isShowing()) {
this.popupCloser(about, about_box);
}
if(help.isShowing()) {
this.popupCloser(help, help_box);
}
ScaleTransition st = new ScaleTransition(Duration.seconds(.4), root);
st.setToX(0);
st.setToY(0);
st.play();
FadeTransition fd = new FadeTransition(Duration.seconds(.3), root);
fd.setToValue(.1);
fd.play();
st.setOnFinished(e -> Platform.exit());
}
示例3: dataItemAdded
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
@Override protected void dataItemAdded(Series<Number, Number> series, int itemIndex, Data<Number, Number> item) {
Node candle = createCandle(getData().indexOf(series), item, itemIndex);
if (shouldAnimate()) {
candle.setOpacity(0);
getPlotChildren().add(candle);
// fade in new candle
FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
ft.setToValue(1);
ft.play();
} else {
getPlotChildren().add(candle);
}
// always draw average line on top
if (series.getNode() != null) {
series.getNode().toFront();
}
}
示例4: buttonClicked
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
/**
*
* @param b
*/
public void buttonClicked(Button b, KeyCode key) {
ScaleTransition st = new ScaleTransition(Duration.seconds(.2), b);
st.setFromX(.8);
st.setFromY(.8);
st.setToX(1.6);
st.setToY(1.6);
st.play();
FadeTransition ft = new FadeTransition(Duration.seconds(.2), b);
ft.setFromValue(.2);
ft.setToValue(1);
ft.play();
boolean movable = true;
Direction direction = new Direction(key);
if(direction.getKey().equals(KeyCode.UP)) movable = this.upMove(direction);
if(direction.getKey().equals(KeyCode.RIGHT)) movable = this.rightMove(direction);
if(direction.getKey().equals(KeyCode.DOWN)) movable = this.downMove(direction);
if(direction.getKey().equals(KeyCode.LEFT)) movable = this.leftMove(direction);
if(movable) {
int random_value = ((int)(new Random().nextDouble() * 10)) > 8 ? 4 : 2;
this.addNewTile(String.valueOf(random_value), Duration.seconds(.2));
}
}
示例5: handleStateChangeNotification
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
@Override
public void handleStateChangeNotification(StateChangeNotification evt) {
if (evt.getType() == StateChangeNotification.Type.BEFORE_START) {
if (stage.isShowing()) {
// fade out, hide stage at the end of animation
final FadeTransition fadeTransition =
new FadeTransition(
Duration.millis(1000), stage.getScene().getRoot());
fadeTransition.setFromValue(1.0);
fadeTransition.setToValue(0.0);
final EventHandler<ActionEvent> eventHandler = t -> stage.hide();
fadeTransition.setOnFinished(eventHandler);
fadeTransition.play();
} else {
stage.hide();
}
}
}
示例6: dataItemRemoved
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
@Override protected void dataItemRemoved(Data<Number, Number> item, Series<Number, Number> series) {
final Node candle = item.getNode();
if (shouldAnimate()) {
// fade out old candle
FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
ft.setToValue(0);
ft.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
getPlotChildren().remove(candle);
}
});
ft.play();
} else {
getPlotChildren().remove(candle);
}
}
示例7: seriesAdded
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
@Override protected void seriesAdded(Series<Number, Number> series, int seriesIndex) {
// handle any data already in series
for (int j = 0; j < series.getData().size(); j++) {
Data item = series.getData().get(j);
Node candle = createCandle(seriesIndex, item, j);
if (shouldAnimate()) {
candle.setOpacity(0);
getPlotChildren().add(candle);
// fade in new candle
FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
ft.setToValue(1);
ft.play();
} else {
getPlotChildren().add(candle);
}
}
// create series path
Path seriesPath = new Path();
seriesPath.getStyleClass().setAll("candlestick-average-line", "series" + seriesIndex);
series.setNode(seriesPath);
getPlotChildren().add(seriesPath);
}
示例8: makeFadeOut
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
/**
* Método para efeito de transição de saída
*/
private void makeFadeOut(String path) {
FadeTransition fadeTransition = new FadeTransition();
fadeTransition.setDuration(Duration.millis(250));
fadeTransition.setNode(rootPane);
fadeTransition.setFromValue(1);
fadeTransition.setToValue(0);
fadeTransition.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
try {
loadScreenPlay(path);
} catch (IOException ex) {
Logger.getLogger(ControllerLayoutInicial.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
fadeTransition.play();
}
示例9: makeFadeOut
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
private void makeFadeOut(String path) {
FadeTransition fadeTransition = new FadeTransition();
fadeTransition.setDuration(Duration.millis(250));
fadeTransition.setNode(rootPane);
fadeTransition.setFromValue(1);
fadeTransition.setToValue(0);
fadeTransition.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
try {
loadScreenPlay(path);
} catch (IOException ex) {
Logger.getLogger(ControllerLayoutInicial.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
fadeTransition.play();
}
示例10: setScreen
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
/**
* set a screen by string id
*
* @param name
*/
public void setScreen(String name) {
// dont try to set new screen
if (screens.get(name) == null) {
System.out.println("invalid screen");
return;
}
// fade out animation
if (screen != null) {
FadeTransition ft = new FadeTransition(new Duration(500), screen.getScene().getRoot());
ft.setFromValue(1);
ft.setToValue(0);
ft.play();
ticking = false;
ft.setOnFinished(e -> {
fadeIn(name);
});
} else {
fadeIn(name);
}
}
示例11: deleteSection
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
@Override
public void deleteSection(int sectionId) {
for(SectionView section : this.sections) {
if(section.gameId == sectionId) {
FadeTransition fadeTransition = new FadeTransition(Duration.seconds(7), section);
fadeTransition.setFromValue(0.6);
fadeTransition.setToValue(0);
fadeTransition.play();
fadeTransition.setOnFinished(event -> {
ConcreteLineView.this.getChildren().remove(section);
fadeTransition.setNode(null);
});
this.sections.remove(section);
break;
}
}
}
示例12: TransitionAlert
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
private void TransitionAlert(Pane player_pane, Pane energy_pane) {
Rectangle rectangle = new Rectangle(150, 50);
Stop[] stops = new Stop[]{new Stop(0, Color.RED), new Stop(1, Color.WHITE)};
LinearGradient gp = new LinearGradient(0, 0, 10, 24, true, CycleMethod.NO_CYCLE, stops);
rectangle.setFill(gp);
rectangle.setArcHeight(18);
rectangle.setArcWidth(18);
rectangle.setLayoutX(energy_pane.getLayoutX());
rectangle.setLayoutY(energy_pane.getLayoutY());
FadeTransition fadeTransition1 = new FadeTransition(Duration.millis(500), rectangle);
fadeTransition1.setFromValue(0f);
fadeTransition1.setToValue(0.6f);
fadeTransition1.setCycleCount(2);
fadeTransition1.setAutoReverse(true);
player_pane.getChildren().add(rectangle);
fadeTransition1.play();
}
示例13: showNotification
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
public void showNotification(String text)
{
labelNotification.setText(text);
labelNotification.setStyle("-fx-text-fill: #FFFFFF; -fx-font-size: 16; -fx-font-weight: bold; -fx-background-color: " + ConvertTo.toRGBHexWithoutOpacity(Colors.BACKGROUND_NOTIFICATION));
FadeTransition fadeIn = new FadeTransition(Duration.millis(200), labelNotification);
fadeIn.setFromValue(0.0);
fadeIn.setToValue(1.0);
FadeTransition fadeOut = new FadeTransition(Duration.millis(400), labelNotification);
fadeOut.setFromValue(1.0);
fadeOut.setToValue(0.0);
fadeOut.setDelay(Duration.millis(3000));
fadeOut.play();
SequentialTransition seqT = new SequentialTransition(fadeIn, fadeOut);
seqT.play();
seqT.setOnFinished((a) -> {
labelNotification.setStyle("-fx-text-fill: #FFFFFF; -fx-font-size: 16; -fx-font-weight: bold; -fx-background-color: transparent;");
});
}
示例14: TransitionForAll
import javafx.animation.FadeTransition; //導入方法依賴的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);
}
示例15: animate
import javafx.animation.FadeTransition; //導入方法依賴的package包/類
private void animate(Circle particle, Path path) {
Random randGen = new Random();
PathTransition pathTransition = new PathTransition(Duration.seconds(path.getElements().size() * (randGen.nextInt(30) + 30)), path, particle);
pathTransition.setInterpolator(Interpolator.EASE_OUT);
ScaleTransition scaleTransition = new ScaleTransition(Duration.seconds(3f), particle);
scaleTransition.setToX(10f);
scaleTransition.setToY(10f);
scaleTransition.setInterpolator(Interpolator.EASE_OUT);
FadeTransition fadeTransition = new FadeTransition(Duration.seconds(6f), particle);
fadeTransition.setToValue(0.7);
fadeTransition.setInterpolator(Interpolator.EASE_OUT);
pathTransition.play();
scaleTransition.play();
fadeTransition.play();
}