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


Java KeyFrame類代碼示例

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


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

示例1: playCrossfade

import javafx.animation.KeyFrame; //導入依賴的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();
}
 
開發者ID:jakemanning,項目名稱:boomer-tuner,代碼行數:20,代碼來源:Player.java

示例2: Exe

import javafx.animation.KeyFrame; //導入依賴的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();
}
 
開發者ID:chrootRISCassembler,項目名稱:CapsLock,代碼行數:40,代碼來源:OverLayWindow.java

示例3: createLetter

import javafx.animation.KeyFrame; //導入依賴的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: bindUpdates

import javafx.animation.KeyFrame; //導入依賴的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();
}
 
開發者ID:de-sach,項目名稱:BatpackJava,代碼行數:17,代碼來源:batteryMonitorLayoutController.java

示例5: ensureVisible

import javafx.animation.KeyFrame; //導入依賴的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: makeText

import javafx.animation.KeyFrame; //導入依賴的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();
}
 
開發者ID:nwg-piotr,項目名稱:EistReturns,代碼行數:38,代碼來源:Utils.java

示例7: FadeOutDownTransition

import javafx.animation.KeyFrame; //導入依賴的package包/類
/**
 * Create new FadeOutDownTransition
 * 
 * @param node The node to affect
 */
public FadeOutDownTransition(final Node node) {
    super(
        node,
            new Timeline(
                new KeyFrame(Duration.millis(0),    
                    new KeyValue(node.opacityProperty(), 1, WEB_EASE),
                    new KeyValue(node.translateYProperty(), 0, WEB_EASE)
                ),
                new KeyFrame(Duration.millis(1000),    
                    new KeyValue(node.opacityProperty(), 0, WEB_EASE),
                    new KeyValue(node.translateYProperty(), 20, WEB_EASE)
                )
            )
        );
    setCycleDuration(Duration.seconds(1));
    setDelay(Duration.seconds(0.2));
}
 
開發者ID:EricCanull,項目名稱:fxexperience2,代碼行數:23,代碼來源:FadeOutDownTransition.java

示例8: startAnimateForm300

import javafx.animation.KeyFrame; //導入依賴的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;
}
 
開發者ID:RestComm,項目名稱:phone-simulator,代碼行數:11,代碼來源:USSDGUIController.java

示例9: startAnimateForm130

import javafx.animation.KeyFrame; //導入依賴的package包/類
private Timeline startAnimateForm130() {
    Timeline tml = new Timeline(
            new KeyFrame(Duration.ZERO, new KeyValue(pnlContent.maxHeightProperty(), 70)),
            new KeyFrame(Duration.seconds(0.4), new KeyValue(pnlContent.maxHeightProperty(), 130, Interpolator.EASE_BOTH)));
    tml.setOnFinished((ActionEvent event) -> {

        pnlForm.setVisible(false);
        pnlMessage.setVisible(true);
    });

    return tml;
}
 
開發者ID:RestComm,項目名稱:phone-simulator,代碼行數:13,代碼來源:USSDGUIController.java

示例10: startPanAnimation

import javafx.animation.KeyFrame; //導入依賴的package包/類
private void startPanAnimation(double velocity, Timeline timeline, DoubleProperty animatedPan, DoubleProperty pan) {
    if (isRunning(timeline)) {
        return;
    }
    double durationInMillis = 1e10;
    double distance = velocity * durationInMillis;
    animatedPan.set(pan.get());
    KeyValue keyValue = new KeyValue(animatedPan, animatedPan.get() - distance);
    KeyFrame keyFrame = new KeyFrame(Duration.millis(durationInMillis), keyValue);
    timeline.getKeyFrames().setAll(keyFrame);
    timeline.playFromStart();
}
 
開發者ID:rmfisher,項目名稱:fx-animation-editor,代碼行數:13,代碼來源:DragBehavior.java

示例11: FadeOutRightTransition

import javafx.animation.KeyFrame; //導入依賴的package包/類
/**
 * Create new FadeOutRightTransition
 * 
 * @param node The node to affect
 */
public FadeOutRightTransition(final Node node) {
    super(
        node,
        new Timeline(
                new KeyFrame(Duration.millis(0),    
                    new KeyValue(node.opacityProperty(), 1, WEB_EASE),
                    new KeyValue(node.translateXProperty(), 0, WEB_EASE)
                ),
                new KeyFrame(Duration.millis(1000),    
                    new KeyValue(node.opacityProperty(), 0, WEB_EASE),
                    new KeyValue(node.translateXProperty(), 20, WEB_EASE)
                )
            )
        );
    setCycleDuration(Duration.seconds(1));
    setDelay(Duration.seconds(0.2));
}
 
開發者ID:EricCanull,項目名稱:fxexperience2,代碼行數:23,代碼來源:FadeOutRightTransition.java

示例12: init

import javafx.animation.KeyFrame; //導入依賴的package包/類
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setScene(new Scene(root));
    root.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);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:ChartAdvancedStockLine.java

示例13: createSyncTimer

import javafx.animation.KeyFrame; //導入依賴的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

示例14: commitCrime

import javafx.animation.KeyFrame; //導入依賴的package包/類
@FXML
void commitCrime(ActionEvent event) {

    crimeBtn.setDisable(true);

    JFXRadioButton selectedRadio = (JFXRadioButton) group.getSelectedToggle();
    String extractedCrime = selectedRadio.getText();
    /*
    Extract the selected crime from the selected radio button's text or bindIt and pass it to the GameEngine. */
    GameEngine.game().isSuccessful(extractedCrime);

    Timeline timeline = new Timeline();
    for (int i = 0; i <= seconds; i++) {
        final int timeRemaining = seconds - i;
        KeyFrame frame = new KeyFrame(Duration.seconds(i),
                e -> {
                    crimeBtn.setDisable(true);
                    crimeBtn.setText("Wait " + timeRemaining + " sec..");
                });
        timeline.getKeyFrames().add(frame);
    }
    timeline.setOnFinished(e -> {
        crimeBtn.setText("Commit!");
        crimeBtn.setDisable(false);
        refresh();
        seconds += 5;
    });
    timeline.play();
}
 
開發者ID:gokcan,項目名稱:Mafia-TCoS-CS319-Group2A,代碼行數:30,代碼來源:CrimeScene.java

示例15: start

import javafx.animation.KeyFrame; //導入依賴的package包/類
@Override public void start(Stage stage) throws Exception {
    preloaderStage = stage;
    preloaderStage.setScene(preloaderScene);
    preloaderStage.show();
    
    if (DEMO_MODE) {
        final DoubleProperty prog = new SimpleDoubleProperty(0){
            @Override protected void invalidated() {
                handleProgressNotification(new ProgressNotification(get()));
            }
        };
        Timeline t = new Timeline();
        t.getKeyFrames().add(new KeyFrame(Duration.seconds(20), new KeyValue(prog, 1)));
        t.play();
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:17,代碼來源:DataAppPreloader.java


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