本文整理汇总了Java中javafx.animation.Interpolator类的典型用法代码示例。如果您正苦于以下问题:Java Interpolator类的具体用法?Java Interpolator怎么用?Java Interpolator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Interpolator类属于javafx.animation包,在下文中一共展示了Interpolator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import javafx.animation.Interpolator; //导入依赖的package包/类
private void init(Stage primaryStage) {
Group root = new Group();
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(root, 250, 90));
//create circles by method createMovingCircle listed below
Circle circle1 = createMovingCircle(Interpolator.LINEAR); //default interpolator
circle1.setOpacity(0.7);
Circle circle2 = createMovingCircle(Interpolator.EASE_BOTH); //circle slows down when reached both ends of trajectory
circle2.setOpacity(0.45);
Circle circle3 = createMovingCircle(Interpolator.EASE_IN);
Circle circle4 = createMovingCircle(Interpolator.EASE_OUT);
Circle circle5 = createMovingCircle(Interpolator.SPLINE(0.5, 0.1, 0.1, 0.5)); //one can define own behaviour of interpolator by spline method
root.getChildren().addAll(
circle1,
circle2,
circle3,
circle4,
circle5
);
}
示例2: startAnimateForm300
import javafx.animation.Interpolator; //导入依赖的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;
}
示例3: startAnimateForm130
import javafx.animation.Interpolator; //导入依赖的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;
}
示例4: createMovingCircle
import javafx.animation.Interpolator; //导入依赖的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;
}
示例5: animateExistingTile
import javafx.animation.Interpolator; //导入依赖的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;
}
示例6: createDataRemoveTimeline
import javafx.animation.Interpolator; //导入依赖的package包/类
private Timeline createDataRemoveTimeline(final Data<X, Y> item, final Node symbol, final Series<X, Y> series) {
Timeline t = new Timeline();
// save data values in case the same data item gets added immediately.
XYValueMap.put(item, ((Number) item.getYValue()).doubleValue());
t.getKeyFrames()
.addAll(new KeyFrame(Duration.ZERO, new KeyValue(item.currentYProperty(), item.getCurrentY()),
new KeyValue(item.currentXProperty(), item.getCurrentX())),
new KeyFrame(Duration.millis(500), actionEvent -> {
if (symbol != null)
getPlotChildren().remove(symbol);
removeDataItemFromDisplay(series, item);
XYValueMap.clear();
}, new KeyValue(item.currentYProperty(), item.getYValue(), Interpolator.EASE_BOTH),
new KeyValue(item.currentXProperty(), item.getXValue(), Interpolator.EASE_BOTH)));
return t;
}
示例7: animateDataAdd
import javafx.animation.Interpolator; //导入依赖的package包/类
private void animateDataAdd(Data<X, Y> item, Node bar) {
double barVal;
if (orientation == Orientation.VERTICAL) {
barVal = ((Number) item.getYValue()).doubleValue();
if (barVal < 0) {
bar.getStyleClass().add(NEGATIVE_STYLE);
}
item.setCurrentY(getY1Axis().toRealValue((barVal < 0) ? -bottomPos : bottomPos));
getPlotChildren().add(bar);
item.setYValue(getY1Axis().toRealValue(barVal));
animate(new KeyFrame(Duration.ZERO, new KeyValue(item.currentYProperty(), item.getCurrentY())),
new KeyFrame(Duration.millis(700),
new KeyValue(item.currentYProperty(), item.getYValue(), Interpolator.EASE_BOTH)));
} else {
barVal = ((Number) item.getXValue()).doubleValue();
if (barVal < 0) {
bar.getStyleClass().add(NEGATIVE_STYLE);
}
item.setCurrentX(getXAxis().toRealValue((barVal < 0) ? -bottomPos : bottomPos));
getPlotChildren().add(bar);
item.setXValue(getXAxis().toRealValue(barVal));
animate(new KeyFrame(Duration.ZERO, new KeyValue(item.currentXProperty(), item.getCurrentX())),
new KeyFrame(Duration.millis(700),
new KeyValue(item.currentXProperty(), item.getXValue(), Interpolator.EASE_BOTH)));
}
}
示例8: moveCircle
import javafx.animation.Interpolator; //导入依赖的package包/类
private void moveCircle(Circle C) {
double centerX = (scene.getWidth() - maxRadius) * Math.random() + maxRadius;
double centerY = scene.getHeight();
C.setCenterX(centerX);
//C.setTranslateY((scene.getHeight() - maxRadius) * Math.random() + maxRadius);
C.setCenterY(centerY);
double radius = (maxRadius - minRadius) * Math.random() + minRadius;
C.setFill(new Color(Math.random(), Math.random(), Math.random(), 1));
C.setRadius(radius);
Timeline timeline = new Timeline();
double timelength = ((maxTimeLength - minTimeLength) * Math.random() + minTimeLength) * 1000;
timeline.getKeyFrames().add(new KeyFrame(new Duration(timelength), new KeyValue(C.centerYProperty(), 0 - maxRadius, Interpolator.EASE_IN)));
/* SequentialTransition sequence = new SequentialTransition();
for(int i = 0; i < 10; i++) {
sequence.getChildren().add(new KeyFrame(new Duration(timelength / 10), new KeyValue(C.centerXProperty(), centerX - 100)));
sequence.getChildren().add(new KeyFrame(new Duration(timelength / 10), new KeyValue(C.centerXProperty(), centerX + 100)));
}*/
timeline.play();
timeline.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
//moveCircle(C);
newCircle();
}
});
}
示例9: FlipTransition
import javafx.animation.Interpolator; //导入依赖的package包/类
/**
* Create new FlipTransition
*
* @param node The node to affect
*/
public FlipTransition(final Node node) {
super(node, new Timeline(
new KeyFrame(Duration.millis(0),
new KeyValue(node.rotateProperty(), 0, Interpolator.EASE_OUT),
new KeyValue(node.translateZProperty(), 0, Interpolator.EASE_OUT)),
new KeyFrame(Duration.millis(400),
new KeyValue(node.translateZProperty(), -150, Interpolator.EASE_OUT),
new KeyValue(node.rotateProperty(), -170, Interpolator.EASE_OUT)),
new KeyFrame(Duration.millis(500),
new KeyValue(node.translateZProperty(), -150, Interpolator.EASE_IN),
new KeyValue(node.rotateProperty(), -190, Interpolator.EASE_IN),
new KeyValue(node.scaleXProperty(), 1, Interpolator.EASE_IN),
new KeyValue(node.scaleYProperty(), 1, Interpolator.EASE_IN)),
new KeyFrame(Duration.millis(800),
new KeyValue(node.translateZProperty(), 0, Interpolator.EASE_IN),
new KeyValue(node.rotateProperty(), -360, Interpolator.EASE_IN),
new KeyValue(node.scaleXProperty(), 0.95, Interpolator.EASE_IN),
new KeyValue(node.scaleYProperty(), 0.95, Interpolator.EASE_IN)),
new KeyFrame(Duration.millis(1000),
new KeyValue(node.scaleXProperty(), 1, Interpolator.EASE_IN),
new KeyValue(node.scaleYProperty(), 1, Interpolator.EASE_IN))));
this.flipNode = node;
setCycleDuration(Duration.seconds(1));
setDelay(Duration.seconds(0.2));
}
示例10: setupShowAnimation
import javafx.animation.Interpolator; //导入依赖的package包/类
@Override
protected Timeline setupShowAnimation() {
Timeline tl = new Timeline();
// Sets the x location of the tray off the screen
double offScreenX = stage.getOffScreenBounds().getX();
KeyValue kvX = new KeyValue(stage.xLocationProperty(), offScreenX);
KeyFrame frame1 = new KeyFrame(Duration.ZERO, kvX);
// Animates the Tray onto the screen and interpolates at a tangent for 300 millis
Interpolator interpolator = Interpolator.TANGENT(Duration.millis(300), 50);
KeyValue kvInter = new KeyValue(stage.xLocationProperty(), stage.getBottomRight().getX(), interpolator);
KeyFrame frame2 = new KeyFrame(Duration.millis(1300), kvInter);
// Sets opacity to 0 instantly
KeyValue kvOpacity = new KeyValue(stage.opacityProperty(), 0.0);
KeyFrame frame3 = new KeyFrame(Duration.ZERO, kvOpacity);
// Increases the opacity to fully visible whilst moving in the space of 1000 millis
KeyValue kvOpacity2 = new KeyValue(stage.opacityProperty(), 1.0);
KeyFrame frame4 = new KeyFrame(Duration.millis(1000), kvOpacity2);
tl.getKeyFrames().addAll(frame1, frame2, frame3, frame4);
tl.setOnFinished(e -> trayIsShowing = true);
return tl;
}
示例11: setupDismissAnimation
import javafx.animation.Interpolator; //导入依赖的package包/类
@Override
protected Timeline setupDismissAnimation() {
Timeline tl = new Timeline();
double offScreenX = stage.getOffScreenBounds().getX();
Interpolator interpolator = Interpolator.TANGENT(Duration.millis(300), 50);
double trayPadding = 3;
// The destination X location for the stage. Which is off the users screen
// Since the tray has some padding, we want to hide that too
KeyValue kvX = new KeyValue(stage.xLocationProperty(), offScreenX + trayPadding, interpolator);
KeyFrame frame1 = new KeyFrame(Duration.millis(1400), kvX);
// Change the opacity level to 0.4 over the duration of 2000 millis
KeyValue kvOpacity = new KeyValue(stage.opacityProperty(), 0.4);
KeyFrame frame2 = new KeyFrame(Duration.millis(2000), kvOpacity);
tl.getKeyFrames().addAll(frame1, frame2);
tl.setOnFinished(e -> {
trayIsShowing = false;
stage.close();
stage.setLocation(stage.getBottomRight());
});
return tl;
}
示例12: SpriteAnimation
import javafx.animation.Interpolator; //导入依赖的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: initializeShakeAnimation
import javafx.animation.Interpolator; //导入依赖的package包/类
private void initializeShakeAnimation() {
final Interpolator interpolator = Interpolator.SPLINE(0.645, 0.045, 0.355, 1);
final double startX = controller.root.getTranslateX();
final KeyValue kv1 = new KeyValue(controller.root.translateXProperty(), startX - 3, interpolator);
final KeyValue kv2 = new KeyValue(controller.root.translateXProperty(), startX + 3, interpolator);
final KeyValue kv3 = new KeyValue(controller.root.translateXProperty(), startX, interpolator);
final KeyFrame kf1 = new KeyFrame(millis(50), kv1);
final KeyFrame kf2 = new KeyFrame(millis(100), kv2);
final KeyFrame kf3 = new KeyFrame(millis(150), kv1);
final KeyFrame kf4 = new KeyFrame(millis(200), kv2);
final KeyFrame kf5 = new KeyFrame(millis(250), kv3);
shakeAnimation.getKeyFrames().addAll(kf1, kf2, kf3, kf4, kf5);
}
示例14: collapseMessagesIfNotCollapsed
import javafx.animation.Interpolator; //导入依赖的package包/类
public void collapseMessagesIfNotCollapsed() {
final Transition collapse = new Transition() {
double height = tabPaneContainer.getMaxHeight();
{
setInterpolator(Interpolator.SPLINE(0.645, 0.045, 0.355, 1));
setCycleDuration(Duration.millis(200));
}
@Override
protected void interpolate(final double frac) {
tabPaneContainer.setMaxHeight(((height - 35) * (1 - frac)) + 35);
}
};
if (tabPaneContainer.getMaxHeight() > 35) {
collapse.play();
}
}
示例15: collapseMessagesClicked
import javafx.animation.Interpolator; //导入依赖的package包/类
@FXML
public void collapseMessagesClicked() {
final Transition collapse = new Transition() {
double height = tabPaneContainer.getMaxHeight();
{
setInterpolator(Interpolator.SPLINE(0.645, 0.045, 0.355, 1));
setCycleDuration(Duration.millis(200));
}
@Override
protected void interpolate(final double frac) {
tabPaneContainer.setMaxHeight(((height - 35) * (1 - frac)) + 35);
}
};
if (tabPaneContainer.getMaxHeight() > 35) {
collapse.play();
} else {
expandMessagesContainer.play();
}
}