本文整理匯總了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();
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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));
}
示例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");
}
示例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);
}
}
示例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);
});
}
示例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);
});
}
示例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));
}
示例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();
}
示例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();
}
示例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();
}