本文整理匯總了Java中javafx.animation.Timeline類的典型用法代碼示例。如果您正苦於以下問題:Java Timeline類的具體用法?Java Timeline怎麽用?Java Timeline使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Timeline類屬於javafx.animation包,在下文中一共展示了Timeline類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: playCrossfade
import javafx.animation.Timeline; //導入依賴的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: animiereRechteck
import javafx.animation.Timeline; //導入依賴的package包/類
public static Pane animiereRechteck() {
Random random = new Random();
Pane animationPane = new Pane();
animationPane.setPrefSize(500,200);
Rectangle rect = new Rectangle(75, 75, 100, 50);
animationPane.getChildren().add(rect);
Timeline timeline = new Timeline();
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.setAutoReverse(true);
KeyValue kVMoveX = new KeyValue(rect.xProperty(), random.nextInt(200) + 200);
KeyValue kVRotate = new KeyValue(rect.rotateProperty(), random.nextInt(360) + 180);
KeyValue kVArcHeight = new KeyValue(rect.arcHeightProperty(), 60);
KeyValue kVArcWidth = new KeyValue(rect.arcWidthProperty(), 60);
KeyFrame keyFrame = new KeyFrame(Duration.millis(random.nextInt(2000) + 2000), kVMoveX, kVRotate, kVArcHeight, kVArcWidth);
timeline.getKeyFrames().add(keyFrame);
timeline.play();
return animationPane;
}
示例3: Exe
import javafx.animation.Timeline; //導入依賴的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();
}
示例4: ChartData
import javafx.animation.Timeline; //導入依賴的package包/類
public ChartData(final String NAME, final double VALUE, final Color FILL_COLOR, final Color STROKE_COLOR, final Color TEXT_COLOR, final Instant TIMESTAMP, final boolean ANIMATED, final long ANIMATION_DURATION) {
name = NAME;
value = VALUE;
oldValue = 0;
fillColor = FILL_COLOR;
strokeColor = STROKE_COLOR;
textColor = TEXT_COLOR;
timestamp = TIMESTAMP;
currentValue = new DoublePropertyBase(value) {
@Override protected void invalidated() {
oldValue = value;
value = get();
fireChartDataEvent(UPDATE_EVENT);
}
@Override public Object getBean() { return ChartData.this; }
@Override public String getName() { return "currentValue"; }
};
timeline = new Timeline();
animated = ANIMATED;
animationDuration = ANIMATION_DURATION;
timeline.setOnFinished(e -> fireChartDataEvent(FINISHED_EVENT));
}
示例5: bindUpdates
import javafx.animation.Timeline; //導入依賴的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();
}
示例6: createLetter
import javafx.animation.Timeline; //導入依賴的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();
}
示例7: initTimeline
import javafx.animation.Timeline; //導入依賴的package包/類
private void initTimeline() {
timeline = new Timeline();
timeline.setCycleCount(Timeline.INDEFINITE);
KeyFrame kf = new KeyFrame(Config.ANIMATION_TIME, new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
if (state == STATE_SHOW_TITLE) {
stateArg++;
int center = Config.SCREEN_WIDTH / 2;
int offset = (int)(Math.cos(stateArg / 4.0) * (40 - stateArg) / 40 * center);
brick.setTranslateX(center - brick.getImage().getWidth() / 2 + offset);
breaker.setTranslateX(center - breaker.getImage().getWidth() / 2 - offset);
if (stateArg == 40) {
stateArg = 0;
state = STATE_SHOW_STRIKE;
}
return;
}
if (state == STATE_SHOW_STRIKE) {
if (stateArg == 0) {
strike.setTranslateX(breaker.getTranslateX() + brick.getImage().getWidth());
strike.setScaleX(0);
strike.setScaleY(0);
strike.setVisible(true);
}
stateArg++;
double coef = stateArg / 30f;
brick.setTranslateX(breaker.getTranslateX() +
(breaker.getImage().getWidth() - brick.getImage().getWidth()) / 2f * (1 - coef));
strike.setScaleX(coef);
strike.setScaleY(coef);
strike.setRotate((30 - stateArg) * 2);
if (stateArg == 30) {
stateArg = 0;
state = STATE_SUN;
}
return;
}
// Here state == STATE_SUN
if (pressanykey.getOpacity() < 1) {
pressanykey.setOpacity(pressanykey.getOpacity() + 0.05f);
}
stateArg--;
double x = SUN_AMPLITUDE_X * Math.cos(stateArg / 100.0);
double y = SUN_AMPLITUDE_Y * Math.sin(stateArg / 100.0);
if (y < 0) {
for (Node node : NODES_SHADOWS) {
// Workaround RT-1976
node.setTranslateX(-1000);
}
return;
}
double sunX = Config.SCREEN_WIDTH / 2 + x;
double sunY = Config.SCREEN_HEIGHT / 2 - y;
sun.setTranslateX(sunX - sun.getImage().getWidth() / 2);
sun.setTranslateY(sunY - sun.getImage().getHeight() / 2);
sun.setRotate(-stateArg);
for (int i = 0; i < NODES.length; i++) {
NODES_SHADOWS[i].setOpacity(y / SUN_AMPLITUDE_Y / 2);
NODES_SHADOWS[i].setTranslateX(NODES[i].getTranslateX() +
(NODES[i].getTranslateX() + NODES[i].getImage().getWidth() / 2 - sunX) / 20);
NODES_SHADOWS[i].setTranslateY(NODES[i].getTranslateY() +
(NODES[i].getTranslateY() + NODES[i].getImage().getHeight() / 2 - sunY) / 20);
}
}
});
timeline.getKeyFrames().add(kf);
}
示例8: makeText
import javafx.animation.Timeline; //導入依賴的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();
}
示例9: seriesRemoved
import javafx.animation.Timeline; //導入依賴的package包/類
@Override
protected void seriesRemoved(final MultiAxisChart.Series<X, Y> series) {
updateDefaultColorIndex(series);
// remove series Y multiplier
seriesYMultiplierMap.remove(series);
// remove all symbol nodes
if (shouldAnimate()) {
Timeline tl = new Timeline(createSeriesRemoveTimeLine(series, 400));
tl.play();
} else {
getPlotChildren().remove(series.getNode());
for (Data<X, Y> d : series.getData())
getPlotChildren().remove(d.getNode());
removeSeriesFromDisplay(series);
}
}
示例10: start
import javafx.animation.Timeline; //導入依賴的package包/類
@Override
public void start(Stage mainWin) throws IOException {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
DEFAULT_HEIGHT = screenSize.height - 100;
DEFAULT_WIDTH = screenSize.width - 100;
teamTabs = new TabPane(); // Initialize the pane with for the tabs
setUpHelp = new GUIHelper(this); // Initialize the GUI helper class
info = setUpHelp.createTextBox("Server not configured!"); // Initialize the textbox
menuBar = setUpHelp.getMenu(info); // Initialize the menubar and the menus
elementSect = new StackPane(); // Initialize the element stackpane
elementSect.getChildren().add(teamTabs); // Add the tabs from teamtabs there
borderPane = new BorderPane(); // Add the border pane
borderPane.setTop(menuBar); // Add stuff to the borders
borderPane.setCenter(elementSect); // But the elementSect in the middle
borderPane.setBottom(info); // Put the textpane in the bottom
Scene scene = new Scene(borderPane, DEFAULT_WIDTH, DEFAULT_HEIGHT); // Create the scene for the height
mainWin.getIcons().add(new Image(ICON_LOC)); // Set the icon as the CyberTiger icon
mainWin.setTitle("CyberTiger Scoreboard"); // Get the window name
mainWin.setScene(scene); // Set the window
mainWin.show(); // Show the window
refreshData(); // Refresh the data since this creates the rest of teh GUI
Timeline scoreboardRefresh = new Timeline(new KeyFrame(Duration.seconds(REFRESH_TIMEOUT), (ActionEvent event) -> {
try {
refreshData(); // Put the refresh method in this method to autorefresh every minute
} catch (IOException ex) { // Catch the exception from the database conn
info.setText("Error refreshing scores! " + ex); // Show the errors
}
}));
scoreboardRefresh.setCycleCount(Timeline.INDEFINITE); // Set the number of times to run
scoreboardRefresh.play(); // Run the timer
}
示例11: setupDismissAnimation
import javafx.animation.Timeline; //導入依賴的package包/類
@Override
protected Timeline setupDismissAnimation() {
Timeline tl = new Timeline();
KeyValue kv1 = new KeyValue(stage.yLocationProperty(), stage.getY() + stage.getWidth());
KeyFrame kf1 = new KeyFrame(Duration.millis(2000), kv1);
KeyValue kv2 = new KeyValue(stage.opacityProperty(), 0.0);
KeyFrame kf2 = new KeyFrame(Duration.millis(2000), kv2);
tl.getKeyFrames().addAll(kf1, kf2);
tl.setOnFinished(e -> {
trayIsShowing = false;
stage.close();
stage.setLocation(stage.getBottomRight());
});
return tl;
}
示例12: ShakeTransition
import javafx.animation.Timeline; //導入依賴的package包/類
/**
* Create new ShakeTransition
*
* @param node The node to affect
*/
public ShakeTransition(final Node node) {
super(
node,
new Timeline(
new KeyFrame(Duration.millis(0), new KeyValue(node.translateXProperty(), 0, WEB_EASE)),
new KeyFrame(Duration.millis(100), new KeyValue(node.translateXProperty(), -10, WEB_EASE)),
new KeyFrame(Duration.millis(200), new KeyValue(node.translateXProperty(), 10, WEB_EASE)),
new KeyFrame(Duration.millis(300), new KeyValue(node.translateXProperty(), -10, WEB_EASE)),
new KeyFrame(Duration.millis(400), new KeyValue(node.translateXProperty(), 10, WEB_EASE)),
new KeyFrame(Duration.millis(500), new KeyValue(node.translateXProperty(), -10, WEB_EASE)),
new KeyFrame(Duration.millis(600), new KeyValue(node.translateXProperty(), 10, WEB_EASE)),
new KeyFrame(Duration.millis(700), new KeyValue(node.translateXProperty(), -10, WEB_EASE)),
new KeyFrame(Duration.millis(800), new KeyValue(node.translateXProperty(), 10, WEB_EASE)),
new KeyFrame(Duration.millis(900), new KeyValue(node.translateXProperty(), -10, WEB_EASE)),
new KeyFrame(Duration.millis(1000), new KeyValue(node.translateXProperty(), 0, WEB_EASE))
)
);
setCycleDuration(Duration.seconds(1));
setDelay(Duration.seconds(0.2));
}
示例13: ChartItem
import javafx.animation.Timeline; //導入依賴的package包/類
public ChartItem(final String NAME, final double VALUE, final Color FILL, final Color STROKE, final Color TEXT_COLOR, final Instant TIMESTAMP, final boolean ANIMATED, final long ANIMATION_DURATION) {
_name = NAME;
_value = VALUE;
oldValue = 0;
_fill = FILL;
_stroke = STROKE;
_textColor = TEXT_COLOR;
_timestamp = TIMESTAMP;
_symbol = Symbol.NONE;
_animated = ANIMATED;
currentValue = new DoublePropertyBase(_value) {
@Override protected void invalidated() {
oldValue = getValue();
setValue(get());
fireItemEvent(UPDATE_EVENT);
}
@Override public Object getBean() { return ChartItem.this; }
@Override public String getName() { return "currentValue"; }
};
timeline = new Timeline();
animationDuration = ANIMATION_DURATION;
timeline.setOnFinished(e -> fireItemEvent(FINISHED_EVENT));
}
示例14: FadeInUpTransition
import javafx.animation.Timeline; //導入依賴的package包/類
/**
* Create new FadeInUpTransition
*
* @param node The node to affect
*/
public FadeInUpTransition(final Node node) {
super(
node,
new Timeline(
new KeyFrame(Duration.millis(0),
new KeyValue(node.opacityProperty(), 0, WEB_EASE),
new KeyValue(node.translateYProperty(), 20, WEB_EASE)
),
new KeyFrame(Duration.millis(1000),
new KeyValue(node.opacityProperty(), 1, WEB_EASE),
new KeyValue(node.translateYProperty(), 0, WEB_EASE)
)
)
);
setCycleDuration(Duration.seconds(1));
setDelay(Duration.seconds(0.2));
}
示例15: startAnimateForm300
import javafx.animation.Timeline; //導入依賴的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;
}