本文整理汇总了Java中javafx.animation.Timeline.play方法的典型用法代码示例。如果您正苦于以下问题:Java Timeline.play方法的具体用法?Java Timeline.play怎么用?Java Timeline.play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.animation.Timeline
的用法示例。
在下文中一共展示了Timeline.play方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: 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();
}
示例4: handleStateChangeNotification
import javafx.animation.Timeline; //导入方法依赖的package包/类
@Override public void handleStateChangeNotification(StateChangeNotification evt) {
if (evt.getType() == StateChangeNotification.Type.BEFORE_INIT) {
// check if download was crazy fast and restart progress
if ((System.currentTimeMillis() - startDownload) < 500) {
raceTrack.setProgress(0);
}
// we have finished downloading application, now we are running application
// init() method, as we have no way of calculating real progress
// simplate pretend progress here
simulatorTimeline = new Timeline();
simulatorTimeline.getKeyFrames().add(
new KeyFrame(Duration.seconds(3),
new KeyValue(raceTrack.progressProperty(),1)
)
);
simulatorTimeline.play();
}
}
示例5: ensureVisible
import javafx.animation.Timeline; //导入方法依赖的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: moveCircle
import javafx.animation.Timeline; //导入方法依赖的package包/类
private void moveCircle(Circle C) {
double centerX = (scene.getWidth() - maxRadius) * Math.random() + maxRadius;
double centerY = scene.getHeight();
C.setCenterX(centerX);
//C.setTranslateY((scene.getHeight() - maxRadius) * Math.random() + maxRadius);
C.setCenterY(centerY);
double radius = (maxRadius - minRadius) * Math.random() + minRadius;
C.setFill(new Color(Math.random(), Math.random(), Math.random(), 1));
C.setRadius(radius);
Timeline timeline = new Timeline();
double timelength = ((maxTimeLength - minTimeLength) * Math.random() + minTimeLength) * 1000;
timeline.getKeyFrames().add(new KeyFrame(new Duration(timelength), new KeyValue(C.centerYProperty(), 0 - maxRadius, Interpolator.EASE_IN)));
/* SequentialTransition sequence = new SequentialTransition();
for(int i = 0; i < 10; i++) {
sequence.getChildren().add(new KeyFrame(new Duration(timelength / 10), new KeyValue(C.centerXProperty(), centerX - 100)));
sequence.getChildren().add(new KeyFrame(new Duration(timelength / 10), new KeyValue(C.centerXProperty(), centerX + 100)));
}*/
timeline.play();
timeline.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
//moveCircle(C);
newCircle();
}
});
}
示例7: zoomPane
import javafx.animation.Timeline; //导入方法依赖的package包/类
void zoomPane(double newZoom) {
double scale = newZoom / 100;
final Timeline timeline = new Timeline();
final KeyValue kv1 = new KeyValue(aDrawPane.scaleXProperty(), scale);
final KeyValue kv2 = new KeyValue(aDrawPane.scaleYProperty(), scale);
final KeyFrame kf = new KeyFrame(Duration.millis(100), kv1, kv2);
timeline.getKeyFrames().add(kf);
timeline.play();
}
示例8: animateGraph
import javafx.animation.Timeline; //导入方法依赖的package包/类
private void animateGraph(long timeMillis) {
Timeline beat = new Timeline(
new KeyFrame(Duration.millis(timeMillis), event -> animationStep(timeMillis))
);
beat.setAutoReverse(true);
beat.setCycleCount(1);
beat.play();
}
示例9: startSnakeGame
import javafx.animation.Timeline; //导入方法依赖的package包/类
/**
* Starts the timeline for the snake game and monitors the snake action
*/
private void startSnakeGame() {
hasGameStarted = true;
paused = false;
timeline = new Timeline(new KeyFrame(Duration.ZERO, new EventHandler() {
@Override
public void handle(Event event) {
if (pressedDir != null) {
snake.setNewDirection(pressedDir);
}
snake.move();
if (snake.snakeReachedFruit(fruit)) {
snakeEatsFruit();
}
if (snake.isGameOver()) {
timeline.stop();
createGameOverPane();
}
repaintPane();
}
}), new KeyFrame(Duration.millis(speed)));
if (snake.isSnakeAlive()) {
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
}
}
示例10: showDialog
import javafx.animation.Timeline; //导入方法依赖的package包/类
public void showDialog() {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Feedback Dialog");
alert.setHeaderText("Confirmation of action");
alert.setContentText(message);
alert.show();
Timeline idlestage = new Timeline(new KeyFrame(Duration.seconds(3), event -> alert.hide()));
idlestage.setCycleCount(1);
idlestage.play();
}
示例11: SymbolsAdder
import javafx.animation.Timeline; //导入方法依赖的package包/类
SymbolsAdder(String text, Integer delay) {
this.text = text;
if (delay < delayLimit){
addCount = delayLimit / delay;
delay = delayLimit;
} else
addCount = 1;
timeline = new Timeline(new KeyFrame(Duration.millis(delay), this));
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
}
示例12: initialize
import javafx.animation.Timeline; //导入方法依赖的package包/类
@Override
public void initialize(URL url, ResourceBundle rb) {
gc = drawingCanvas.getGraphicsContext2D();
w = drawingCanvas.getWidth();
h = drawingCanvas.getHeight();
r = 200;
cx = 0;
cy = 0;
theta = - Math.PI / 2.0;
dtheta = 2 * Math.PI / 60.0;
oneImage = new Image("resources/one.jpg");
// Labtask: animate the second's hand for an analog clock
// hometask:
// 1. put image labels for the different hour marks on the dial
// 2. animate the hour hand and the minute hand
// 3. fix the time so that it is synchronized with the current time
KeyFrame keyFrame = new KeyFrame(Duration.seconds(1), event -> {
gc.clearRect(0, 0, drawingCanvas.getWidth(), drawingCanvas.getHeight());
gc.strokeOval(cx + w / 2 - r, cy + h / 2 - r, r * 2, r * 2);
px = r * Math.cos(theta);
py = r * Math.sin(theta);
gc.drawImage(oneImage, px + w / 2, py + h / 2);
gc.strokeLine(cx + w / 2, cy + h / 2, px + w / 2, py + h / 2);
theta += dtheta;
});
Timeline timeline = new Timeline();
timeline.getKeyFrames().add(keyFrame);
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
// KeyFrame
// Timeline
}
示例13: initialize
import javafx.animation.Timeline; //导入方法依赖的package包/类
@Override
public void initialize(URL url, ResourceBundle rb) {
gc = drawingCanvas.getGraphicsContext2D();
frameCount = 1;
ballsList = new ArrayList<>();
ballsList.add(new Ball());
ballsList.add(new Ball());
ballsList.add(new Ball());
ballsList.get(1).setvX(1);
ballsList.get(1).setColor(Color.RED);
ballsList.get(1).setxPos(200);
ballsList.get(2).setvY(2);
ballsList.get(2).setColor(Color.BLUE);
ballsList.get(2).setxPos(400);
KeyFrame keyFrame = new KeyFrame(Duration.seconds(.05), event -> {
gc.clearRect(0, 0, drawingCanvas.getWidth(), drawingCanvas.getHeight());
Image image = new Image("images/RBH3.jpg");
for (Ball ball : ballsList) {
// draw the ball
gc.setFill(ball.getColor());
//
gc.fillOval(ball.getxPos(), ball.getyPos(), ball.getRadius() * 2, ball.getRadius() * 2);
gc.drawImage(image, ball.getxPos(), ball.getyPos());
ball.updateBall();
}
for (int i = 0; i < ballsList.size(); i++)
for (int j = i + 1; j < ballsList.size(); j++) {
if (ballsList.get(i).isColliding(ballsList.get(j))) {
System.out.println("COLLISSION between " + i + " " + j);
double tvX = ballsList.get(j).getvX();
double tvY = ballsList.get(j).getvY();
ballsList.get(j).setvX(ballsList.get(i).getvX());
ballsList.get(j).setvY(ballsList.get(i).getvY());
ballsList.get(i).setvX(tvX);
ballsList.get(i).setvY(tvY);
}
}
});
Timeline timeline = new Timeline();
timeline.getKeyFrames().add(keyFrame);
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
/*
gc.strokeRect(10, 10, 20, 20);
gc.strokeRect(20, 10, 20, 20);
gc.strokeRect(30, 10, 20, 20);
*/
}
示例14: configureBox
import javafx.animation.Timeline; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void configureBox(HBox root) {
StackPane container = new StackPane();
//container.setPrefHeight(700);
container.setPrefSize(boxBounds.getWidth(), boxBounds.getHeight());
container.setStyle("-fx-border-width:1px;-fx-border-style:solid;-fx-border-color:#999999;");
table= new TableView<AttClass>();
Label lview= new Label();
lview.setText("View Records");
lview.setId("lview");
bottomPane= new VBox();
tclock= new Text();
tclock.setId("lview");
//tclock.setFont(Font.font("Calibri", 20));
final Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
tclock.setText(DateFormat.getDateTimeInstance().format(new Date()));
}
}));
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
bottomPane.getChildren().addAll(tclock,lview);
bottomPane.setAlignment(Pos.CENTER);
//table pane
namecol= new TableColumn<>("First Name");
namecol.setMinWidth(170);
namecol.setCellValueFactory(new PropertyValueFactory<>("name"));
admcol= new TableColumn<>("Identication No.");
admcol.setMinWidth(180);
admcol.setCellValueFactory(new PropertyValueFactory<>("adm"));
typecol= new TableColumn<>("Type");
typecol.setMinWidth(130);
typecol.setCellValueFactory(new PropertyValueFactory<>("type"));
timecol= new TableColumn<>("Signin");
timecol.setMinWidth(140);
timecol.setCellValueFactory(new PropertyValueFactory<>("timein"));
datecol= new TableColumn<>("Date");
datecol.setMinWidth(180);
datecol.setCellValueFactory(new PropertyValueFactory<>("date"));
table.getColumns().addAll(namecol, admcol, typecol, timecol, datecol);
table.setItems(getAtt());
att= getAtt();
table.setItems(FXCollections.observableArrayList(att));
table.setMinHeight(500);
btnrefresh = new Button("Refresh");
btnrefresh.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
table.setItems(getAtt());
}
});
laytable= new VBox(10);
laytable.getChildren().addAll(table, btnrefresh);
laytable.setAlignment(Pos.TOP_LEFT);
container.getChildren().addAll(bottomPane,laytable);
setAnimation();
sc.setContent(container);
root.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672)");
root.getChildren().addAll(getActionPane(),sc);
//service.start();
}
示例15: setAnimation
import javafx.animation.Timeline; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private void setAnimation(){
// Initially hiding the Top Pane
clipRect = new Rectangle();
clipRect.setWidth(boxBounds.getWidth());
clipRect.setHeight(0);
clipRect.translateYProperty().set(boxBounds.getWidth());
laytable.setClip(clipRect);
laytable.translateYProperty().set(-boxBounds.getWidth());
// Animation for bouncing effect.
final Timeline timelineBounce = new Timeline();
timelineBounce.setCycleCount(2);
timelineBounce.setAutoReverse(true);
final KeyValue kv1 = new KeyValue(clipRect.heightProperty(), (boxBounds.getHeight()-15));
final KeyValue kv2 = new KeyValue(clipRect.translateYProperty(), 15);
final KeyValue kv3 = new KeyValue(laytable.translateYProperty(), -15);
final KeyFrame kf1 = new KeyFrame(Duration.millis(100), kv1, kv2, kv3);
timelineBounce.getKeyFrames().add(kf1);
// Event handler to call bouncing effect after the scroll down is finished.
EventHandler onFinished = new EventHandler() {
@Override
public void handle(Event event) {
timelineBounce.play();
}
};
timelineDown = new Timeline();
timelineUp = new Timeline();
// Animation for scroll down.
timelineDown.setCycleCount(1);
timelineDown.setAutoReverse(true);
final KeyValue kvDwn1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
final KeyValue kvDwn2 = new KeyValue(clipRect.translateYProperty(), 0);
final KeyValue kvDwn3 = new KeyValue(laytable.translateYProperty(), 0);
final KeyFrame kfDwn = new KeyFrame(Duration.millis(1000), onFinished, kvDwn1, kvDwn2, kvDwn3);
timelineDown.getKeyFrames().add(kfDwn);
// Animation for scroll up.
timelineUp.setCycleCount(1);
timelineUp.setAutoReverse(true);
final KeyValue kvUp1 = new KeyValue(clipRect.heightProperty(), 0);
final KeyValue kvUp2 = new KeyValue(clipRect.translateYProperty(), boxBounds.getHeight());
final KeyValue kvUp3 = new KeyValue(laytable.translateYProperty(), -boxBounds.getHeight());
final KeyFrame kfUp = new KeyFrame(Duration.millis(1000), kvUp1, kvUp2, kvUp3);
timelineUp.getKeyFrames().add(kfUp);
}