本文整理汇总了Java中javafx.animation.KeyValue类的典型用法代码示例。如果您正苦于以下问题:Java KeyValue类的具体用法?Java KeyValue怎么用?Java KeyValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyValue类属于javafx.animation包,在下文中一共展示了KeyValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playCrossfade
import javafx.animation.KeyValue; //导入依赖的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();
}
示例2: animiereRechteck
import javafx.animation.KeyValue; //导入依赖的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;
}
示例3: createLetter
import javafx.animation.KeyValue; //导入依赖的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();
}
示例4: handleStateChangeNotification
import javafx.animation.KeyValue; //导入依赖的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();
}
}
示例5: setupDismissAnimation
import javafx.animation.KeyValue; //导入依赖的package包/类
@Override
protected Timeline setupDismissAnimation() {
Timeline tl = new Timeline();
KeyValue kv1 = new KeyValue(stage.yLocationProperty(), stage.getY() + stage.getWidth());
KeyFrame kf1 = new KeyFrame(Duration.millis(2000), kv1);
KeyValue kv2 = new KeyValue(stage.opacityProperty(), 0.0);
KeyFrame kf2 = new KeyFrame(Duration.millis(2000), kv2);
tl.getKeyFrames().addAll(kf1, kf2);
tl.setOnFinished(e -> {
trayIsShowing = false;
stage.close();
stage.setLocation(stage.getBottomRight());
});
return tl;
}
示例6: makeText
import javafx.animation.KeyValue; //导入依赖的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();
}
示例7: ensureVisible
import javafx.animation.KeyValue; //导入依赖的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);
}
示例8: ShakeTransition
import javafx.animation.KeyValue; //导入依赖的package包/类
/**
* Create new ShakeTransition
*
* @param node The node to affect
*/
public ShakeTransition(final Node node) {
super(
node,
new Timeline(
new KeyFrame(Duration.millis(0), new KeyValue(node.translateXProperty(), 0, WEB_EASE)),
new KeyFrame(Duration.millis(100), new KeyValue(node.translateXProperty(), -10, WEB_EASE)),
new KeyFrame(Duration.millis(200), new KeyValue(node.translateXProperty(), 10, WEB_EASE)),
new KeyFrame(Duration.millis(300), new KeyValue(node.translateXProperty(), -10, WEB_EASE)),
new KeyFrame(Duration.millis(400), new KeyValue(node.translateXProperty(), 10, WEB_EASE)),
new KeyFrame(Duration.millis(500), new KeyValue(node.translateXProperty(), -10, WEB_EASE)),
new KeyFrame(Duration.millis(600), new KeyValue(node.translateXProperty(), 10, WEB_EASE)),
new KeyFrame(Duration.millis(700), new KeyValue(node.translateXProperty(), -10, WEB_EASE)),
new KeyFrame(Duration.millis(800), new KeyValue(node.translateXProperty(), 10, WEB_EASE)),
new KeyFrame(Duration.millis(900), new KeyValue(node.translateXProperty(), -10, WEB_EASE)),
new KeyFrame(Duration.millis(1000), new KeyValue(node.translateXProperty(), 0, WEB_EASE))
)
);
setCycleDuration(Duration.seconds(1));
setDelay(Duration.seconds(0.2));
}
示例9: startAnimateForm300
import javafx.animation.KeyValue; //导入依赖的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;
}
示例10: createMovingCircle
import javafx.animation.KeyValue; //导入依赖的package包/类
private Circle createMovingCircle(Interpolator interpolator) {
//create a transparent circle
Circle circle = new Circle(45,45, 40, Color.web("1c89f4"));
circle.setOpacity(0);
//add effect
circle.setEffect(new Lighting());
//create a timeline for moving the circle
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.setAutoReverse(true);
//create a keyValue for horizontal translation of circle to the position 155px with given interpolator
KeyValue keyValue = new KeyValue(circle.translateXProperty(), 155, interpolator);
//create a keyFrame with duration 4s
KeyFrame keyFrame = new KeyFrame(Duration.seconds(4), keyValue);
//add the keyframe to the timeline
timeline.getKeyFrames().add(keyFrame);
return circle;
}
示例11: start
import javafx.animation.KeyValue; //导入依赖的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();
}
}
示例12: TimelineSample
import javafx.animation.KeyValue; //导入依赖的package包/类
public TimelineSample() {
super(280,120);
//create a circle
final Circle circle = new Circle(25,25, 20, Color.web("1c89f4"));
circle.setEffect(new Lighting());
//create a timeline for moving the circle
timeline = new Timeline();
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.setAutoReverse(true);
//one can start/pause/stop/play animation by
//timeline.play();
//timeline.pause();
//timeline.stop();
//timeline.playFromStart();
//add the following keyframes to the timeline
timeline.getKeyFrames().addAll
(new KeyFrame(Duration.ZERO,
new KeyValue(circle.translateXProperty(), 0)),
new KeyFrame(new Duration(4000),
new KeyValue(circle.translateXProperty(), 205)));
getChildren().add(createNavigation());
getChildren().add(circle);
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Timeline rate", timeline.rateProperty(), -4d, 4d)
//TODO it is possible to do it for integer?
);
// END REMOVE ME
}
示例13: create3dContent
import javafx.animation.KeyValue; //导入依赖的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);
}
示例14: animateScore
import javafx.animation.KeyValue; //导入依赖的package包/类
public void animateScore() {
if(gameMovePoints.get()==0){
return;
}
final Timeline timeline = new Timeline();
lblPoints.setText("+" + gameMovePoints.getValue().toString());
lblPoints.setOpacity(1);
double posX=vScore.localToScene(vScore.getWidth()/2d,0).getX();
lblPoints.setTranslateX(0);
lblPoints.setTranslateX(lblPoints.sceneToLocal(posX, 0).getX()-lblPoints.getWidth()/2d);
lblPoints.setLayoutY(20);
final KeyValue kvO = new KeyValue(lblPoints.opacityProperty(), 0);
final KeyValue kvY = new KeyValue(lblPoints.layoutYProperty(), 100);
Duration animationDuration = Duration.millis(600);
final KeyFrame kfO = new KeyFrame(animationDuration, kvO);
final KeyFrame kfY = new KeyFrame(animationDuration, kvY);
timeline.getKeyFrames().add(kfO);
timeline.getKeyFrames().add(kfY);
timeline.play();
}
示例15: animateExistingTile
import javafx.animation.KeyValue; //导入依赖的package包/类
/**
* Animation that moves the tile from its previous location to a new location
* @param tile to be animated
* @param newLocation new location of the tile
* @return a timeline
*/
private Timeline animateExistingTile(Tile tile, Location newLocation) {
Timeline timeline = new Timeline();
KeyValue kvX = new KeyValue(tile.layoutXProperty(),
newLocation.getLayoutX(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);
KeyValue kvY = new KeyValue(tile.layoutYProperty(),
newLocation.getLayoutY(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);
KeyFrame kfX = new KeyFrame(ANIMATION_EXISTING_TILE, kvX);
KeyFrame kfY = new KeyFrame(ANIMATION_EXISTING_TILE, kvY);
timeline.getKeyFrames().add(kfX);
timeline.getKeyFrames().add(kfY);
return timeline;
}