本文整理汇总了Java中javafx.animation.KeyFrame类的典型用法代码示例。如果您正苦于以下问题:Java KeyFrame类的具体用法?Java KeyFrame怎么用?Java KeyFrame使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyFrame类属于javafx.animation包,在下文中一共展示了KeyFrame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playCrossfade
import javafx.animation.KeyFrame; //导入依赖的package包/类
private void playCrossfade(final List<? extends Playable> items, final int index) {
MediaPlayer oldPlayer = currentPlayer;
final double currentVolume = oldPlayer.getVolume();
oldPlayer.volumeProperty().unbind();
playQueue = new ArrayList<>(items);
currentIndex = index;
MediaPlayer newPlayer = new MediaPlayer(new Media(playQueue.get(currentIndex).getUri().toString()));
newPlayer.setVolume(0);
newPlayer.play();
Timeline crossfade = new Timeline(new KeyFrame(Duration.seconds(CROSSFADE_DURATION),
new KeyValue(oldPlayer.volumeProperty(), 0),
new KeyValue(newPlayer.volumeProperty(), currentVolume)));
crossfade.setOnFinished(event -> {
oldPlayer.stop();
setCurrentPlayer(newPlayer);
});
crossfade.play();
}
示例2: Exe
import javafx.animation.KeyFrame; //导入依赖的package包/类
void Exe(int i) {
if(i==1) {
warnmesse="プレイ開始から5分経過しました\n混雑している場合は次の人に\n交代してください";
fontsize=25;
}else if(i==2) {
warnmesse="プレイ開始から10分経過しました\n混雑している場合は次の人に\n交代してください";
fontsize=25;
}else if(i==-1) {
warnmesse="user timer is reset";
fontsize=35;
}
final Stage primaryStage = new Stage(StageStyle.TRANSPARENT);
primaryStage.initModality(Modality.NONE);
final StackPane root = new StackPane();
final Scene scene = new Scene(root, 350, 140);
scene.setFill(null);
final Label label = new Label(warnmesse);
label.setFont(new Font("Arial", fontsize));
BorderPane borderPane = new BorderPane();
borderPane.setCenter(label);
borderPane.setStyle("-fx-background-radius: 10;-fx-background-color: rgba(0,0,0,0.3);");
root.getChildren().add(borderPane);
final Rectangle2D d = Screen.getPrimary().getVisualBounds();
primaryStage.setScene(scene);
primaryStage.setAlwaysOnTop(true);
primaryStage.setX(d.getWidth()-350);
primaryStage.setY(d.getHeight()-300);
primaryStage.show();
final Timeline timer = new Timeline(new KeyFrame(Duration.seconds(CLOSE_SECONDS), (ActionEvent event) -> primaryStage.close()));
timer.setCycleCount(Timeline.INDEFINITE);
timer.play();
}
示例3: createLetter
import javafx.animation.KeyFrame; //导入依赖的package包/类
private void createLetter(String c) {
final Text letter = new Text(c);
letter.setFill(Color.BLACK);
letter.setFont(FONT_DEFAULT);
letter.setTextOrigin(VPos.TOP);
letter.setTranslateX((getWidth() - letter.getBoundsInLocal().getWidth()) / 2);
letter.setTranslateY((getHeight() - letter.getBoundsInLocal().getHeight()) / 2);
getChildren().add(letter);
// over 3 seconds move letter to random position and fade it out
final Timeline timeline = new Timeline();
timeline.getKeyFrames().add(
new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
// we are done remove us from scene
getChildren().remove(letter);
}
},
new KeyValue(letter.translateXProperty(), getRandom(0.0f, getWidth() - letter.getBoundsInLocal().getWidth()),INTERPOLATOR),
new KeyValue(letter.translateYProperty(), getRandom(0.0f, getHeight() - letter.getBoundsInLocal().getHeight()),INTERPOLATOR),
new KeyValue(letter.opacityProperty(), 0f)
));
timeline.play();
}
示例4: bindUpdates
import javafx.animation.KeyFrame; //导入依赖的package包/类
private void bindUpdates() {
final KeyFrame oneFrame = new KeyFrame(Duration.seconds(1), (ActionEvent evt) -> {
if (this.batpack != null) {
this.batpack = BatteryMonitorSystem.getBatpack();
//System.out.println("layout: battery pack module 5 cell 5 voltage: " + batpack.getModules().get(4).getBatteryCells().get(4).getVoltageAsString());
checkConnection();
updateModules();
updateTotalVoltage();
updateMaxTemperature();
updateCriticalValues();
}
});
Timeline timer = TimelineBuilder.create().cycleCount(Animation.INDEFINITE).keyFrames(oneFrame).build();
timer.playFromStart();
}
示例5: ensureVisible
import javafx.animation.KeyFrame; //导入依赖的package包/类
void ensureVisible(double x, double y) {
ScrollPane scrollPane = diagramController.getScrollPane();
double xScroll = (x - scrollPane.getWidth() / 2) / (8000 - scrollPane.getWidth());
double yScroll = (y - scrollPane.getHeight() / 2) / (8000 - scrollPane.getHeight());
final Timeline timeline = new Timeline();
final KeyValue kv1 = new KeyValue(scrollPane.hvalueProperty(), xScroll);
final KeyValue kv2 = new KeyValue(scrollPane.vvalueProperty(), yScroll);
final KeyFrame kf = new KeyFrame(Duration.millis(100), kv1, kv2);
timeline.getKeyFrames().add(kf);
timeline.play();
aScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
aScrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
}
示例6: makeText
import javafx.animation.KeyFrame; //导入依赖的package包/类
private static void makeText(Stage ownerStage, String toastMsg, int toastDelay) {
Stage toastStage = new Stage();
toastStage.initOwner(ownerStage);
toastStage.setResizable(false);
toastStage.initStyle(StageStyle.TRANSPARENT);
Text text = new Text(toastMsg);
text.setFont(Font.font("Verdana", 20));
text.setFill(Color.BLACK);
StackPane root = new StackPane(text);
root.setStyle("-fx-background-radius: 20; -fx-background-color: rgba(255, 255, 255, 0.9); -fx-padding: 20px;");
root.setOpacity(0);
Scene scene = new Scene(root);
scene.setFill(Color.TRANSPARENT);
toastStage.setScene(scene);
toastStage.show();
Timeline fadeInTimeline = new Timeline();
KeyFrame fadeInKey1 = new KeyFrame(Duration.millis(200), new KeyValue(toastStage.getScene().getRoot().opacityProperty(), 1));
fadeInTimeline.getKeyFrames().add(fadeInKey1);
fadeInTimeline.setOnFinished((ae) -> new Thread(() -> {
try {
Thread.sleep(toastDelay);
} catch (InterruptedException e) {
e.printStackTrace();
}
Timeline fadeOutTimeline = new Timeline();
KeyFrame fadeOutKey1 = new KeyFrame(Duration.millis(500), new KeyValue(toastStage.getScene().getRoot().opacityProperty(), 0));
fadeOutTimeline.getKeyFrames().add(fadeOutKey1);
fadeOutTimeline.setOnFinished((aeb) -> toastStage.close());
fadeOutTimeline.play();
}).start());
fadeInTimeline.play();
}
示例7: FadeOutDownTransition
import javafx.animation.KeyFrame; //导入依赖的package包/类
/**
* Create new FadeOutDownTransition
*
* @param node The node to affect
*/
public FadeOutDownTransition(final Node node) {
super(
node,
new Timeline(
new KeyFrame(Duration.millis(0),
new KeyValue(node.opacityProperty(), 1, WEB_EASE),
new KeyValue(node.translateYProperty(), 0, WEB_EASE)
),
new KeyFrame(Duration.millis(1000),
new KeyValue(node.opacityProperty(), 0, WEB_EASE),
new KeyValue(node.translateYProperty(), 20, WEB_EASE)
)
)
);
setCycleDuration(Duration.seconds(1));
setDelay(Duration.seconds(0.2));
}
示例8: startAnimateForm300
import javafx.animation.KeyFrame; //导入依赖的package包/类
private Timeline startAnimateForm300() {
Timeline tml = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(pnlContent.maxHeightProperty(), 70)),
new KeyFrame(Duration.seconds(0.4), new KeyValue(pnlContent.maxHeightProperty(), 300, Interpolator.EASE_BOTH)));
tml.setOnFinished((ActionEvent event) -> {
pnlForm.setVisible(true);
txtSend.requestFocus();
});
return tml;
}
示例9: startAnimateForm130
import javafx.animation.KeyFrame; //导入依赖的package包/类
private Timeline startAnimateForm130() {
Timeline tml = new Timeline(
new KeyFrame(Duration.ZERO, new KeyValue(pnlContent.maxHeightProperty(), 70)),
new KeyFrame(Duration.seconds(0.4), new KeyValue(pnlContent.maxHeightProperty(), 130, Interpolator.EASE_BOTH)));
tml.setOnFinished((ActionEvent event) -> {
pnlForm.setVisible(false);
pnlMessage.setVisible(true);
});
return tml;
}
示例10: startPanAnimation
import javafx.animation.KeyFrame; //导入依赖的package包/类
private void startPanAnimation(double velocity, Timeline timeline, DoubleProperty animatedPan, DoubleProperty pan) {
if (isRunning(timeline)) {
return;
}
double durationInMillis = 1e10;
double distance = velocity * durationInMillis;
animatedPan.set(pan.get());
KeyValue keyValue = new KeyValue(animatedPan, animatedPan.get() - distance);
KeyFrame keyFrame = new KeyFrame(Duration.millis(durationInMillis), keyValue);
timeline.getKeyFrames().setAll(keyFrame);
timeline.playFromStart();
}
示例11: FadeOutRightTransition
import javafx.animation.KeyFrame; //导入依赖的package包/类
/**
* Create new FadeOutRightTransition
*
* @param node The node to affect
*/
public FadeOutRightTransition(final Node node) {
super(
node,
new Timeline(
new KeyFrame(Duration.millis(0),
new KeyValue(node.opacityProperty(), 1, WEB_EASE),
new KeyValue(node.translateXProperty(), 0, WEB_EASE)
),
new KeyFrame(Duration.millis(1000),
new KeyValue(node.opacityProperty(), 0, WEB_EASE),
new KeyValue(node.translateXProperty(), 20, WEB_EASE)
)
)
);
setCycleDuration(Duration.seconds(1));
setDelay(Duration.seconds(0.2));
}
示例12: init
import javafx.animation.KeyFrame; //导入依赖的package包/类
private void init(Stage primaryStage) {
Group root = new Group();
primaryStage.setScene(new Scene(root));
root.getChildren().add(createChart());
// create timeline to add new data every 60th of second
animation = new Timeline();
animation.getKeyFrames().add(new KeyFrame(Duration.millis(1000/60), new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent actionEvent) {
// 6 minutes data per frame
for(int count=0; count < 6; count++) {
nextTime();
plotTime();
}
}
}));
animation.setCycleCount(Animation.INDEFINITE);
}
示例13: createSyncTimer
import javafx.animation.KeyFrame; //导入依赖的package包/类
public void createSyncTimer(int duration) {
covertTask = new Timeline(new KeyFrame(javafx.util.Duration.seconds(duration), (event2) -> {
timer.start();
String html = markdownParser.convertToHTML(editor.getText());
webEngine.loadContent(html);
currentHtml = html;
covertTask.stop();
editorToolBar.setActionText("Refreshed view successfully in " + timer.end() + "ms");
}));
}
示例14: commitCrime
import javafx.animation.KeyFrame; //导入依赖的package包/类
@FXML
void commitCrime(ActionEvent event) {
crimeBtn.setDisable(true);
JFXRadioButton selectedRadio = (JFXRadioButton) group.getSelectedToggle();
String extractedCrime = selectedRadio.getText();
/*
Extract the selected crime from the selected radio button's text or bindIt and pass it to the GameEngine. */
GameEngine.game().isSuccessful(extractedCrime);
Timeline timeline = new Timeline();
for (int i = 0; i <= seconds; i++) {
final int timeRemaining = seconds - i;
KeyFrame frame = new KeyFrame(Duration.seconds(i),
e -> {
crimeBtn.setDisable(true);
crimeBtn.setText("Wait " + timeRemaining + " sec..");
});
timeline.getKeyFrames().add(frame);
}
timeline.setOnFinished(e -> {
crimeBtn.setText("Commit!");
crimeBtn.setDisable(false);
refresh();
seconds += 5;
});
timeline.play();
}
示例15: start
import javafx.animation.KeyFrame; //导入依赖的package包/类
@Override public void start(Stage stage) throws Exception {
preloaderStage = stage;
preloaderStage.setScene(preloaderScene);
preloaderStage.show();
if (DEMO_MODE) {
final DoubleProperty prog = new SimpleDoubleProperty(0){
@Override protected void invalidated() {
handleProgressNotification(new ProgressNotification(get()));
}
};
Timeline t = new Timeline();
t.getKeyFrames().add(new KeyFrame(Duration.seconds(20), new KeyValue(prog, 1)));
t.play();
}
}