當前位置: 首頁>>代碼示例>>Java>>正文


Java Timeline.play方法代碼示例

本文整理匯總了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;
    }
 
開發者ID:CAPTNCAPS,項目名稱:java.IF17wi,代碼行數:27,代碼來源:Rechteck.java

示例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);
	}
}
 
開發者ID:JKostikiadis,項目名稱:MultiAxisCharts,代碼行數:17,代碼來源:MultiAxisAreaChart.java

示例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();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:KeyStrokeMotion.java

示例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();
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,代碼來源:DataAppPreloader.java

示例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);
}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:17,代碼來源:GraphController.java

示例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();
            }
        });
    }
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:38,代碼來源:Bubble.java

示例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();
}
 
開發者ID:kaanburaksener,項目名稱:octoBubbles,代碼行數:11,代碼來源:GraphController.java

示例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();
}
 
開發者ID:katharinebeaumont,項目名稱:Cluster,代碼行數:9,代碼來源:Cluster.java

示例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();
	}
}
 
開發者ID:sanijablan,項目名稱:M426_Scrum,代碼行數:30,代碼來源:SnakeGameGUI.java

示例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();
}
 
開發者ID:atbashEE,項目名稱:atbash-octopus,代碼行數:12,代碼來源:InfoDialog.java

示例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();
}
 
開發者ID:DeskChan,項目名稱:DeskChan,代碼行數:13,代碼來源:Balloon.java

示例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
}
 
開發者ID:kmhasan-class,項目名稱:spring2017java,代碼行數:35,代碼來源:FXMLDocumentController.java

示例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);
     */
}
 
開發者ID:kmhasan-class,項目名稱:spring2017java,代碼行數:54,代碼來源:FXMLDocumentController.java

示例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();
}
 
開發者ID:mikemacharia39,項目名稱:gatepass,代碼行數:74,代碼來源:AllAttendance.java

示例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);

}
 
開發者ID:mikemacharia39,項目名稱:gatepass,代碼行數:51,代碼來源:AllAttendance.java


注:本文中的javafx.animation.Timeline.play方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。