本文整理匯總了Java中javafx.animation.Timeline.setCycleCount方法的典型用法代碼示例。如果您正苦於以下問題:Java Timeline.setCycleCount方法的具體用法?Java Timeline.setCycleCount怎麽用?Java Timeline.setCycleCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.animation.Timeline
的用法示例。
在下文中一共展示了Timeline.setCycleCount方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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
}
示例2: 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);
}
示例3: initialize
import javafx.animation.Timeline; //導入方法依賴的package包/類
@Override
public void initialize(URL url, ResourceBundle rb){
ImageTimeLine = new Timeline(new KeyFrame(
Duration.millis(2500),
ae -> UpdateImage(ae)));
ImageTimeLine.setCycleCount(Animation.INDEFINITE);//タイマーを無限ループさせる.
}
示例4: Metronome
import javafx.animation.Timeline; //導入方法依賴的package包/類
public Metronome() {
// création du fond du métronome
ImageView fond_metronome = new ImageView(
new Image(Metronome.class.getResourceAsStream("images/metronome.png")));
fond_metronome.setFitHeight(40);
fond_metronome.setPreserveRatio(true);
// création de l'aiguille du métronome
ImageView aiguille = new ImageView(new Image(Metronome.class.getResourceAsStream("images/aiguille.png")));
aiguille.setFitHeight(32);
aiguille.setPreserveRatio(true);
aiguille.setTranslateX(16);
aiguille.setTranslateY(2);
// on applique une transformation à l'aiguille
Rotate rotation = new Rotate(0, 3, 29);
aiguille.getTransforms().add(rotation);
// création de l'animation de l'aiguille
Timeline timeline = new Timeline();
timeline.getKeyFrames().addAll(new KeyFrame(Duration.ZERO, new KeyValue(rotation.angleProperty(), 45)),
new KeyFrame(new Duration(1000), new KeyValue(rotation.angleProperty(), -45)));
timeline.setAutoReverse(true);
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
this.getChildren().add(fond_metronome);
this.getChildren().add(aiguille);
this.setTranslateX(400);
this.setTranslateY(200);
}
示例5: 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
}
示例6: periodicallyStrikeRandomNodes
import javafx.animation.Timeline; //導入方法依賴的package包/類
private void periodicallyStrikeRandomNodes(TilePane field) {
Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(0), event -> strikeRandomNode(field)),
new KeyFrame(Duration.seconds(2)));
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
}
示例7: AdvancedStockLineChartSample
import javafx.animation.Timeline; //導入方法依賴的package包/類
public AdvancedStockLineChartSample() {
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);
}
示例8: TimelineSample
import javafx.animation.Timeline; //導入方法依賴的package包/類
public TimelineSample() {
super(280,120);
//create a circle
final Circle circle = new Circle(25,25, 20, Color.web("1c89f4"));
circle.setEffect(new Lighting());
//create a timeline for moving the circle
timeline = new Timeline();
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.setAutoReverse(true);
//one can start/pause/stop/play animation by
//timeline.play();
//timeline.pause();
//timeline.stop();
//timeline.playFromStart();
//add the following keyframes to the timeline
timeline.getKeyFrames().addAll
(new KeyFrame(Duration.ZERO,
new KeyValue(circle.translateXProperty(), 0)),
new KeyFrame(new Duration(4000),
new KeyValue(circle.translateXProperty(), 205)));
getChildren().add(createNavigation());
getChildren().add(circle);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Timeline rate", timeline.rateProperty(), -4d, 4d)
//TODO it is possible to do it for integer?
);
// END REMOVE ME
}
示例9: create3dContent
import javafx.animation.Timeline; //導入方法依賴的package包/類
@Override public Node create3dContent() {
Cube c = new Cube(50,Color.RED,1);
c.rx.setAngle(45);
c.ry.setAngle(45);
Cube c2 = new Cube(50,Color.GREEN,1);
c2.setTranslateX(100);
c2.rx.setAngle(45);
c2.ry.setAngle(45);
Cube c3 = new Cube(50,Color.ORANGE,1);
c3.setTranslateX(-100);
c3.rx.setAngle(45);
c3.ry.setAngle(45);
animation = new Timeline();
animation.getKeyFrames().addAll(
new KeyFrame(Duration.ZERO,
new KeyValue(c.ry.angleProperty(), 0d),
new KeyValue(c2.rx.angleProperty(), 0d),
new KeyValue(c3.rz.angleProperty(), 0d)
),
new KeyFrame(Duration.seconds(1),
new KeyValue(c.ry.angleProperty(), 360d),
new KeyValue(c2.rx.angleProperty(), 360d),
new KeyValue(c3.rz.angleProperty(), 360d)
));
animation.setCycleCount(Animation.INDEFINITE);
return new Group(c,c2,c3);
}
示例10: initializeTimeline
import javafx.animation.Timeline; //導入方法依賴的package包/類
private void initializeTimeline () {
Timeline timeline = getTimeline();
Duration frameDuration = Duration.seconds(1.0d / FPS);
KeyFrame repeatedFrame = new KeyFrame(frameDuration, e -> step(frameDuration));
timeline.getKeyFrames().add(repeatedFrame);
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
}
示例11: Framework
import javafx.animation.Timeline; //導入方法依賴的package包/類
public Framework(int width, int height) {
this.setWidth(width);
this.setHeight(height);
random = new Random();
bullets = new ArrayList<>();
tanks = new ArrayList<>();
mines = new ArrayList<>();
pickUps = new ArrayList<>();
hud = new HUD(this);
canvas = new Canvas(width, height);
gc = canvas.getGraphicsContext2D();
canvas.setWidth(width);
canvas.setHeight(height);
this.getChildren().add(canvas);
//Create Game Loop
gameloop = new Timeline(new KeyFrame(
Duration.millis(16.666666666667),
ae -> update()));
gameloop.setCycleCount(Timeline.INDEFINITE);
//Set SCALE to current scale of Canvas
SCALE = this.getScaleX();
//Make the Canvas register keystrokes
this.addEventFilter(MouseEvent.ANY, (e) -> this.requestFocus());
//Set Inputs
setKeyInput();
setMouseInput();
}
示例12: 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();
}
示例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: 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());
layall.setClip(clipRect);
layall.translateYProperty().set(-boxBounds.getWidth());
layoffice.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(layall.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();
timelineoffice= 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(layall.translateYProperty(), 0);
final KeyValue kvDwn4 = new KeyValue(layoffice.translateYProperty(), -boxBounds.getHeight()-190);
final KeyFrame kfDwn = new KeyFrame(Duration.millis(1000), onFinished, kvDwn1, kvDwn2, kvDwn3, kvDwn4);
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(layall.translateYProperty(), -boxBounds.getHeight()-190);
final KeyValue kvUp4 = new KeyValue(layoffice.translateYProperty(), -boxBounds.getHeight()-190);
final KeyFrame kfUp = new KeyFrame(Duration.millis(1000), kvUp1, kvUp2, kvUp3, kvUp4);
timelineUp.getKeyFrames().add(kfUp);
//Animation for the scrollside
timelineoffice.setCycleCount(1);
timelineoffice.setAutoReverse(true);
final KeyValue kvside1 = new KeyValue(clipRect.heightProperty(), boxBounds.getWidth());
final KeyValue kvside2 = new KeyValue(clipRect.translateYProperty(), 0);
final KeyValue kvside3 = new KeyValue(layoffice.translateYProperty(), 0);
final KeyValue kvside4 = new KeyValue(layall.translateYProperty(), -boxBounds.getHeight());
final KeyFrame kfside = new KeyFrame(Duration.millis(1000), kvside1, kvside2, kvside3, kvside4);
timelineoffice.getKeyFrames().add(kfside);
}
示例15: testCalendar
import javafx.animation.Timeline; //導入方法依賴的package包/類
private void testCalendar(CalendarView calendarView) {
Queue<Runnable> tasks = new LinkedList<>();
Appointment app1 = new Appointment(new TimeInterval(LocalDateTime.now(), LocalDateTime.now().plusHours(3)), "Appointment1");
Appointment app2 = new Appointment(new TimeInterval(LocalDateTime.now().plusHours(4), LocalDateTime.now().plusHours(5)), "Appointment2");
Appointment app3 = new Appointment(new TimeInterval(LocalDateTime.now().plusHours(5), LocalDateTime.now().plusHours(6)), "Appointment3");
Appointment app_overlapping1 = new Appointment(new TimeInterval(LocalDateTime.now().plusHours(1), LocalDateTime.now().plusHours(3)), "AppointmentO1");
Appointment app_overlapping2 = new Appointment(new TimeInterval(LocalDateTime.now().plusHours(2), LocalDateTime.now().plusHours(4)), "AppointmentO2");
Appointment app_allday1 = new Appointment(LocalDate.now(), "Allday1");
Appointment app_allday2 = new Appointment(LocalDate.now(), "Allday2");
Calendar cal1 = new Calendar(app1, app2);
Calendar cal2 = new Calendar();
tasks.add(() -> {
System.out.println("clearing all calendars");
calendarView.getCalendars().clear();
});
tasks.add(() -> {
System.out.println("adding a new calendar with two appointments");
calendarView.getCalendars().add(cal1);
});
tasks.add(() -> {
System.out.println("adding a third appointment to this calendar");
cal1.add(app3);
});
tasks.add(() -> {
System.out.println("adding an overlapping appointment");
cal1.add(app_overlapping1);
cal1.add(app_overlapping2);
});
tasks.add(() -> {
System.out.println("removing the first appointment");
cal1.remove(app1);
});
tasks.add(() -> {
System.out.println("adding a new empty calendar");
calendarView.getCalendars().add(cal2);
});
tasks.add(() -> {
System.out.println("adding the first appointment again to the second calendar");
cal2.add(app1);
});
tasks.add(() -> {
System.out.println("adding the second appointment also to the second calendar");
cal2.add(app2);
});
tasks.add(() -> {
System.out.println("moving the second appointment 4 hours into the past");
app2.intervalProperty().set(new TimeInterval(LocalDateTime.now().minusHours(4), LocalDateTime.now().minusHours(3)));
});
tasks.add(() -> {
System.out.println("moving the first appointment to the next day");
app1.intervalProperty().set(new TimeInterval(LocalDateTime.now().plusDays(1), LocalDateTime.now().plusHours(2).plusDays(1)));
});
tasks.add(() -> {
System.out.println("Adding all-day appointment");
cal1.add(app_allday1);
});
tasks.add(() -> {
System.out.println("Adding another all-day appointment");
cal1.add(app_allday2);
});
Timeline indicatorupdate = new Timeline(new KeyFrame(javafx.util.Duration.seconds(5), actionEvent -> tasks.poll().run()));
indicatorupdate.setCycleCount(tasks.size());
indicatorupdate.play();
}