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


Java Animation類代碼示例

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


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

示例1: bindUpdates

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

示例2: start

import javafx.animation.Animation; //導入依賴的package包/類
@Override
public void start(Stage primaryStage) {
	GameChooser gameManager = new GameChooser(primaryStage);		
	primaryStage.setScene(makeScene());
	primaryStage.setFullScreenExitHint("");
	primaryStage.setFullScreenExitKeyCombination(null);
	primaryStage.show();
	primaryStage.setFullScreen(true);
       Animation myAnimation = makeAnimation(myActor, 100, 200, 100);
       // start animation
       myAnimation.play();
       
       Animation myAnimation1 = makeAnimation(myActor1, 100, 200, 100);
       // start animation
       myAnimation1.play();
       
       Animation myAnimation2 = makeAnimation(myActor2,100,240,140);
       // start animation
       myAnimation2.play();
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:21,代碼來源:LoaderTester.java

示例3: init

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

示例4: AdvancedStockLineChartSample

import javafx.animation.Animation; //導入依賴的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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:16,代碼來源:AdvancedStockLineChartSample.java

示例5: create3dContent

import javafx.animation.Animation; //導入依賴的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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:30,代碼來源:CubeSample.java

示例6: initializeTimeline

import javafx.animation.Animation; //導入依賴的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();
}
 
開發者ID:tomrom95,項目名稱:GameAuthoringEnvironment,代碼行數:9,代碼來源:GameEngine.java

示例7: initialize

import javafx.animation.Animation; //導入依賴的package包/類
@FXML
public void initialize(){

    Main.checkFullScreen();

    Main.getAlertWindow().setOnCloseRequest(e -> spriteImage.setImage(new Image(Gang.getCarSpriteURL())));

    // updating labels
    distanceLabel.setText("To go: "+ Gang.getDistance() +"Mi");
    conditionsLabel.setText("Condition: "+ Gang.getHealthConditions());
    daysLabel.setText("Days: "+ Gang.getDays());
    statusLabel.setText("Status: Resting");

    // setting up how the animation will work
    drivingTransition = new TranslateTransition();
    drivingTransition.setDuration(Duration.seconds(animationDuration));
    drivingTransition.setToX(Main.getMainWindow().getWidth() - 850);
    drivingTransition.setNode(sprite);
    drivingTransition.setCycleCount(Animation.INDEFINITE);

    // fixes the bug with thread not ending when stage was closed
    Main.getMainWindow().setOnCloseRequest(e -> Gang.setMoving(false));
}
 
開發者ID:TheRedSpy15,項目名稱:The-Trail,代碼行數:24,代碼來源:TravelController.java

示例8: updateGUI

import javafx.animation.Animation; //導入依賴的package包/類
@FXML
private void updateGUI(){

    spriteImage.setImage(new Image(Gang.getCarSpriteURL()));

    // updating drivingTransition
    drivingTransition = new TranslateTransition();
    drivingTransition.setDuration(Duration.seconds(animationDuration));
    drivingTransition.setToX((Main.getMainWindow().getWidth() / -1) - 400);
    drivingTransition.setNode(sprite);
    drivingTransition.setCycleCount(Animation.INDEFINITE);

    // updating labels
    distanceLabel.setText("To go: "+ Gang.getDistance() +"Mi");
    conditionsLabel.setText("Condition: "+ Gang.getHealthConditions());
    daysLabel.setText("Days: "+ Gang.getDays());
    statusLabel.setText("Status: Resting");
}
 
開發者ID:TheRedSpy15,項目名稱:The-Trail,代碼行數:19,代碼來源:TravelController.java

示例9: seriesBeingRemovedIsAdded

import javafx.animation.Animation; //導入依賴的package包/類
@Override
void seriesBeingRemovedIsAdded(Series<X, Y> series) {
	boolean lastSeries = (pt.getChildren().size() == 1) ? true : false;
	if (pt != null) {
		if (!pt.getChildren().isEmpty()) {
			for (Animation a : pt.getChildren()) {
				a.setOnFinished(null);
			}
		}
		for (Data<X, Y> item : series.getData()) {
			processDataRemove(series, item);
			if (!lastSeries) {
				restoreDataValues(item);
			}
		}
		XYValueMap.clear();
		pt.setOnFinished(null);
		pt.getChildren().clear();
		pt.stop();
		removeSeriesFromDisplay(series);
	}
}
 
開發者ID:JKostikiadis,項目名稱:MultiAxisCharts,代碼行數:23,代碼來源:MultiAxisBarChart.java

示例10: rotateHer

import javafx.animation.Animation; //導入依賴的package包/類
public void rotateHer(Label labelHer, ImageView iv)
{
	RotateTransition rotation = new RotateTransition(Duration.seconds(2), iv);
	rotation.setCycleCount(Animation.INDEFINITE);
	rotation.setByAngle(360);

	iv.setTranslateZ(iv.getBoundsInLocal().getWidth() / 2.0);
	iv.setRotationAxis(Rotate.Y_AXIS);
	
	labelHer.setOnMouseEntered(e ->
	{ 
		rotation.play();
		iv.setRotate(180);
	});
	labelHer.setOnMouseExited(e ->
	{ 
		rotation.pause();
		iv.setRotate(0);
	});
}
 
開發者ID:mikemacharia39,項目名稱:gatepass,代碼行數:21,代碼來源:MainWindow.java

示例11: rotateHer

import javafx.animation.Animation; //導入依賴的package包/類
public void rotateHer(Label labelHer, ImageView iv)
{
	RotateTransition rotation = new RotateTransition(Duration.seconds(2.3), iv);
	rotation.setCycleCount(Animation.INDEFINITE);
	rotation.setByAngle(360);

	iv.setTranslateZ(iv.getBoundsInLocal().getWidth() / 2.0);
	iv.setRotationAxis(Rotate.Y_AXIS);
	
	labelHer.setOnMouseEntered(e ->
	{ 
		rotation.play();
		iv.setRotate(180);
	});
	labelHer.setOnMouseExited(e ->
	{ 
		rotation.pause();
		iv.setRotate(0);
	});
}
 
開發者ID:mikemacharia39,項目名稱:gatepass,代碼行數:21,代碼來源:SysSettings.java

示例12: SpriteAnimation

import javafx.animation.Animation; //導入依賴的package包/類
/**
 * Creates an animation that will run for indefinite time.
 * Use setCycleCount(1) to run animation only once. Remember to remove the imageView afterwards.
 *
 * @param imageView - the imageview of the sprite
 * @param duration - How long should one animation cycle take
 * @param count - Number of frames
 * @param columns - Number of colums the sprite has
 * @param offsetX - Offset x
 * @param offsetY - Offset y
 * @param width - Width of each frame
 * @param height - Height of each frame
 */
public SpriteAnimation(
        ImageView imageView,
        Duration duration,
        int count, int columns,
        int offsetX, int offsetY,
        int width, int height
) {
    this.imageView = imageView;
    this.count = count;
    this.columns = columns;
    this.offsetX = offsetX;
    this.offsetY = offsetY;
    this.width = width;
    this.height = height;
    setCycleDuration(duration);
    setCycleCount(Animation.INDEFINITE);
    setInterpolator(Interpolator.LINEAR);
    this.imageView.setViewport(new Rectangle2D(offsetX, offsetY, width, height));

}
 
開發者ID:INAETICS,項目名稱:Drones-Simulator,代碼行數:34,代碼來源:SpriteAnimation.java

示例13: showLoading

import javafx.animation.Animation; //導入依賴的package包/類
private void showLoading() {
    final KeyFrame oneFrame = new KeyFrame(Duration.millis(750), (ActionEvent evt) -> {
           loading.setText(getNextLoadingText());
           //bms.setText(getNextBmsText());
    });
    Timeline timer = TimelineBuilder.create().cycleCount(Animation.INDEFINITE).keyFrames(oneFrame).build();
    timer.playFromStart();
}
 
開發者ID:de-sach,項目名稱:BatpackJava,代碼行數:9,代碼來源:SplashScreenController.java

示例14: onActionScaleToExpandedMode

import javafx.animation.Animation; //導入依賴的package包/類
private void onActionScaleToExpandedMode() {
    LoggerFacade.getDefault().trace(this.getClass(), "On action scale to expanded mode"); // NOI18N
    
    if (
            scaleTransition != null
            && scaleTransition.getStatus().equals(Animation.Status.RUNNING)
    ) {
        scaleTransition.stop();
    }
    
    scaleTransition.setFromX(this.getScaleX());
    scaleTransition.setFromY(this.getScaleY());
    scaleTransition.setToX(1.015d);
    scaleTransition.setToY(1.01d);
    
    scaleTransition.playFromStart();
}
 
開發者ID:Naoghuman,項目名稱:ABC-List,代碼行數:18,代碼來源:SignFlowPane.java

示例15: onActionScaleToNormalMode

import javafx.animation.Animation; //導入依賴的package包/類
private void onActionScaleToNormalMode() {
    LoggerFacade.getDefault().trace(this.getClass(), "On action scale to normal mode"); // NOI18N
    
    if (
            scaleTransition != null
            && scaleTransition.getStatus().equals(Animation.Status.RUNNING)
    ) {
        scaleTransition.stop();
    }

    scaleTransition.setFromX(this.getScaleX());
    scaleTransition.setFromY(this.getScaleY());
    scaleTransition.setToX(1.0d);
    scaleTransition.setToY(1.0d);
    
    scaleTransition.playFromStart();
}
 
開發者ID:Naoghuman,項目名稱:ABC-List,代碼行數:18,代碼來源:SignFlowPane.java


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