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


Java Timeline.stop方法代碼示例

本文整理匯總了Java中javafx.animation.Timeline.stop方法的典型用法代碼示例。如果您正苦於以下問題:Java Timeline.stop方法的具體用法?Java Timeline.stop怎麽用?Java Timeline.stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.animation.Timeline的用法示例。


在下文中一共展示了Timeline.stop方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createSyncTimer

import javafx.animation.Timeline; //導入方法依賴的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");
    }));
}
 
開發者ID:jdesive,項目名稱:textmd,代碼行數:11,代碼來源:EditorPane.java

示例2: 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

示例3: buildEvent

import javafx.animation.Timeline; //導入方法依賴的package包/類
private EventHandler<Event> buildEvent() {
    return new EventHandler<Event>() {
        @Override
        public void handle(Event e) {

            if (turned)
                return;

            if (e.getEventType() == MouseEvent.MOUSE_ENTERED || e.getEventType() == GazeEvent.GAZE_ENTERED) {

                progressIndicator.setOpacity(1);
                progressIndicator.setProgress(0);

                Timeline timelineCard = new Timeline();

                timelineCard.getKeyFrames().add(new KeyFrame(new Duration(1),
                        new KeyValue(card.xProperty(), card.getX() - (initWidth * zoom_factor - initWidth) / 2)));
                timelineCard.getKeyFrames().add(new KeyFrame(new Duration(1),
                        new KeyValue(card.yProperty(), card.getY() - (initHeight * zoom_factor - initHeight) / 2)));
                timelineCard.getKeyFrames().add(
                        new KeyFrame(new Duration(1), new KeyValue(card.widthProperty(), initWidth * zoom_factor)));
                timelineCard.getKeyFrames().add(new KeyFrame(new Duration(1),
                        new KeyValue(card.heightProperty(), initHeight * zoom_factor)));

                timelineProgressBar = new Timeline();

                timelineProgressBar.getKeyFrames().add(new KeyFrame(new Duration(fixationlength),
                        new KeyValue(progressIndicator.progressProperty(), 1)));

                timelineCard.play();

                timelineProgressBar.play();

                timelineProgressBar.setOnFinished(new EventHandler<ActionEvent>() {

                    @Override
                    public void handle(ActionEvent actionEvent) {

                        turned = true;

                        card.setFill(new ImagePattern(image, 0, 0, 1, 1, true));

                        card.removeEventFilter(MouseEvent.ANY, enterEvent);
                        card.removeEventFilter(GazeEvent.ANY, enterEvent);

                        if (winner) {
                            onCorrectCardSelected();
                        } else {// bad card
                            onWrongCardSelected();
                        }
                    }
                });
            } else if (e.getEventType() == MouseEvent.MOUSE_EXITED || e.getEventType() == GazeEvent.GAZE_EXITED) {

                Timeline timeline = new Timeline();

                timeline.getKeyFrames().add(new KeyFrame(new Duration(1),
                        new KeyValue(card.xProperty(), card.getX() + (initWidth * zoom_factor - initWidth) / 2)));
                timeline.getKeyFrames().add(new KeyFrame(new Duration(1),
                        new KeyValue(card.yProperty(), card.getY() + (initHeight * zoom_factor - initHeight) / 2)));
                timeline.getKeyFrames()
                        .add(new KeyFrame(new Duration(1), new KeyValue(card.widthProperty(), initWidth)));
                timeline.getKeyFrames()
                        .add(new KeyFrame(new Duration(1), new KeyValue(card.heightProperty(), initHeight)));

                timeline.play();

                timelineProgressBar.stop();

                progressIndicator.setOpacity(0);
                progressIndicator.setProgress(0);
            }
        }
    };
}
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:76,代碼來源:Card.java


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