下面列出了javafx.scene.AmbientLight#javafx.animation.Interpolator 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private Animation getStatusTransition(TestStatus newStatus) {
return new Transition() {
{
setCycleDuration(Duration.millis(1200));
setInterpolator(Interpolator.EASE_BOTH);
setOnFinished(t -> applyCss());
}
@Override
protected void interpolate(double frac) {
Color vColor = newStatus.getColor().deriveColor(0, 1, 1, clip(map(frac)));
setBackground(new Background(new BackgroundFill(vColor, CornerRadii.EMPTY, Insets.EMPTY)));
}
private double map(double x) {
return -abs(x - 0.5) + 0.5;
}
private double clip(double i) {
return min(1, max(0, i));
}
};
}
/**
* 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) {
var timeline = new Timeline();
var kvX = new KeyValue(tile.layoutXProperty(),
newLocation.getLayoutX(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);
var kvY = new KeyValue(tile.layoutYProperty(),
newLocation.getLayoutY(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);
var kfX = new KeyFrame(ANIMATION_EXISTING_TILE, kvX);
var kfY = new KeyFrame(ANIMATION_EXISTING_TILE, kvY);
timeline.getKeyFrames().add(kfX);
timeline.getKeyFrames().add(kfY);
return timeline;
}
private static void adjustPosition(Node node, Parent parent, double kh) {
if (node == null || node.getScene() == null || node.getScene().getWindow() == null) {
return;
}
double tTot = node.getScene().getHeight();
double ty = node.getLocalToSceneTransform().getTy() + node.getBoundsInParent().getHeight() + 2;
double y = 1;
Parent root = parent == null ? node.getScene().getRoot() : parent;
if (ty > tTot - kh) {
y = tTot - ty - kh;
} else if (kh == 0 && root.getTranslateY() != 0) {
y = 0;
}
if (y <= 0) {
if (debug) {
LOG.log(Level.INFO, String.format("Moving %s %.2f pixels", root, y));
}
final TranslateTransition transition = new TranslateTransition(Duration.millis(100), root);
transition.setFromY(root.getTranslateY());
transition.setToY(y);
transition.setInterpolator(Interpolator.EASE_OUT);
transition.playFromStart();
}
}
void init3D(boolean animate) {
maxDepth = 0;
if (animate) {
initialParallelTransition = new ParallelTransition();
initialParallelTransition.setDelay(Duration.seconds(1));
initialParallelTransition.setInterpolator(Interpolator.EASE_OUT);
} else {
initialParallelTransition = null;
}
from2Dto3D(currentRoot2D, root3D, 0);
slider.setMax(maxDepth);
slider.setValue(maxDepth);
if (animate) {
if (rotateTransition != null) {
initialParallelTransition.getChildren().add(rotateTransition);
}
}
}
private Tile3D nodeToTile3D(SVNode node2D, double factor2d3d, double depth) {
Tile3D tile = new Tile3D(currentRoot2D, factor2d3d, node2D, depth, THICKNESS, this, iThreeDOM);
if (initialParallelTransition != null && depth > 1) {
TranslateTransition translateTransition = new TranslateTransition(Duration.seconds(2));
translateTransition.setInterpolator(Interpolator.EASE_OUT);
translateTransition.setNode(tile);
// Take into account slider's value
translateTransition.setToZ(-depth * spaceSlider.getValue());
initialParallelTransition.getChildren().add(translateTransition);
} else {
tile.setTranslateZ(-depth * spaceSlider.getValue());
}
return tile;
}
private void flipForward() {
timeline.stop();
flap.setCache(true);
flap.setCacheHint(CacheHint.ROTATE);
//flap.setCacheHint(CacheHint.SPEED);
currentSelectionIndex++;
if (currentSelectionIndex >= characters.size()) {
currentSelectionIndex = 0;
}
nextSelectionIndex = currentSelectionIndex + 1;
if (nextSelectionIndex >= characters.size()) {
nextSelectionIndex = 0;
}
KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
//KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.EASE_IN);
KeyFrame keyFrame = new KeyFrame(Duration.millis(tile.getFlipTimeInMS()), keyValueFlap);
timeline.getKeyFrames().setAll(keyFrame);
timeline.play();
}
public void setAffine(final Affine affine, final Duration duration) {
if (duration.toMillis() == 0.0) {
setAffine(affine);
return;
}
final Timeline timeline = new Timeline(60.0);
timeline.setCycleCount(1);
timeline.setAutoReverse(false);
final Affine currentState = new Affine();
getAffine(currentState);
final DoubleProperty progressProperty = new SimpleDoubleProperty(0.0);
final SimilarityTransformInterpolator interpolator = new SimilarityTransformInterpolator(
Transforms.fromTransformFX(currentState),
Transforms.fromTransformFX(affine)
);
progressProperty.addListener((obs, oldv, newv) -> setAffine(Transforms.toTransformFX(interpolator.interpolateAt(newv.doubleValue()))));
final KeyValue kv = new KeyValue(progressProperty, 1.0, Interpolator.EASE_BOTH);
timeline.getKeyFrames().add(new KeyFrame(duration, kv));
timeline.play();
}
public synchronized void setTransform(final AffineTransform3D affine, final Duration duration) {
if (duration.toMillis() == 0.0) {
setTransform(affine);
return;
}
final Timeline timeline = new Timeline(60.0);
timeline.setCycleCount(1);
timeline.setAutoReverse(false);
final AffineTransform3D currentState = this.affine.copy();
final DoubleProperty progressProperty = new SimpleDoubleProperty(0.0);
final SimilarityTransformInterpolator interpolator = new SimilarityTransformInterpolator(currentState, affine.copy());
progressProperty.addListener((obs, oldv, newv) -> setTransform(interpolator.interpolateAt(newv.doubleValue())));
final KeyValue kv = new KeyValue(progressProperty, 1.0, Interpolator.EASE_BOTH);
timeline.getKeyFrames().add(new KeyFrame(duration, kv));
timeline.play();
}
public NotificationPane(int w, int h) {
this.w = w;
this.h = h;
bg = new Rectangle(w, h, Color.color(0.2, 0.2, 0.2, 0.75));
getChildren().add(bg);
tt.setOnFinished(e -> isAnimating = false);
tt.setInterpolator(new Interpolator() {
@Override
protected double curve(double t) {
//return (t == 0.0) ? 0.0 : Math.pow(2.0, 10 * (t - 1));
return (t == 1.0) ? 1.0 : 1 - Math.pow(2.0, -10 * t);
}
});
}
@FXML
private void loadThird(ActionEvent event) throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("/javafx/scene/transition/scene3/scene3.fxml"));
Scene scene = button.getScene();
root.translateXProperty().set(scene.getWidth());
StackPane parentContainer = (StackPane) button.getScene().getRoot();
parentContainer.getChildren().add(root);
Timeline timeline = new Timeline();
KeyValue kv = new KeyValue(root.translateXProperty(), 0, Interpolator.EASE_IN);
KeyFrame kf = new KeyFrame(Duration.seconds(1), kv);
timeline.getKeyFrames().add(kf);
timeline.setOnFinished(t -> {
parentContainer.getChildren().remove(container);
});
timeline.play();
}
@Override
void initTimeline() {
this.setTimeline(new Timeline(
new KeyFrame(Duration.millis(0),
new KeyValue(getNode().opacityProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)),
new KeyValue(getNode().translateYProperty(), -3000, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
),
new KeyFrame(Duration.millis(600),
new KeyValue(getNode().opacityProperty(), 1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)),
new KeyValue(getNode().translateYProperty(), 25, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
),
new KeyFrame(Duration.millis(750),
new KeyValue(getNode().translateYProperty(), -10, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
),
new KeyFrame(Duration.millis(900),
new KeyValue(getNode().translateYProperty(), 5, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
),
new KeyFrame(Duration.millis(1000),
new KeyValue(getNode().translateYProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
)
));
}
@Override
void initTimeline() {
double startX = -getNode().localToScene(0, 0).getX() - getNode().getBoundsInParent().getWidth();
setTimeline(
new Timeline(
new KeyFrame(Duration.millis(0),
new KeyValue(getNode().opacityProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)),
new KeyValue(getNode().translateXProperty(), startX, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
),
new KeyFrame(Duration.millis(600),
new KeyValue(getNode().opacityProperty(), 1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)),
new KeyValue(getNode().translateXProperty(), 25, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
),
new KeyFrame(Duration.millis(750),
new KeyValue(getNode().translateXProperty(), -10, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
),
new KeyFrame(Duration.millis(900),
new KeyValue(getNode().translateXProperty(), 5, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
),
new KeyFrame(Duration.millis(1000),
new KeyValue(getNode().translateXProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
)
));
}
@Override
void initTimeline() {
setTimeline(new Timeline(
new KeyFrame(Duration.millis(0),
new KeyValue(getNode().translateXProperty(), 1000, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().opacityProperty(), 0, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().scaleXProperty(), 0.1, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().scaleYProperty(), 0.1, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().scaleZProperty(), 0.1, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19))
),
new KeyFrame(Duration.millis(400),
new KeyValue(getNode().opacityProperty(), 1, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().translateXProperty(), -10, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleXProperty(), 0.475, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleYProperty(), 0.475, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleZProperty(), 0.475, Interpolator.SPLINE(0.175, 0.885, 0.32, 1))
),
new KeyFrame(Duration.millis(1100),
new KeyValue(getNode().translateXProperty(), 0, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().opacityProperty(), 1, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleXProperty(), 1, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleYProperty(), 1, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleZProperty(), 1, Interpolator.SPLINE(0.175, 0.885, 0.32, 1))
)
));
}
@Override
void initTimeline() {
setTimeline(new Timeline(
new KeyFrame(Duration.millis(0),
new KeyValue(getNode().opacityProperty(), 0, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().translateYProperty(), -600, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().scaleXProperty(), 0.1, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().scaleYProperty(), 0.1, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().scaleZProperty(), 0.1, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19))
),
new KeyFrame(Duration.millis(600),
new KeyValue(getNode().opacityProperty(), 1, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().translateYProperty(), 60, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleXProperty(), 0.475, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleYProperty(), 0.475, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleZProperty(), 0.475, Interpolator.SPLINE(0.175, 0.885, 0.32, 1))
),
new KeyFrame(Duration.millis(1000),
new KeyValue(getNode().translateYProperty(), 0, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().opacityProperty(), 1, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleXProperty(), 1, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleYProperty(), 1, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleZProperty(), 1, Interpolator.SPLINE(0.175, 0.885, 0.32, 1))
)
));
}
@Override
void initTimeline() {
setTimeline(new Timeline(
new KeyFrame(Duration.millis(0),
new KeyValue(getNode().opacityProperty(), 0, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().translateYProperty(), 1000, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().scaleXProperty(), 0.1, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().scaleYProperty(), 0.1, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().scaleZProperty(), 0.1, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19))
),
new KeyFrame(Duration.millis(400),
new KeyValue(getNode().opacityProperty(), 1, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().translateYProperty(), 60, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleXProperty(), 0.475, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleYProperty(), 0.475, Interpolator.SPLINE(0.175, 0.885, 0.32, 1)),
new KeyValue(getNode().scaleZProperty(), 0.475, Interpolator.SPLINE(0.175, 0.885, 0.32, 1))
),
new KeyFrame(Duration.millis(1000),
new KeyValue(getNode().translateYProperty(), 0, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().opacityProperty(), 1, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().scaleXProperty(), 1, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().scaleYProperty(), 1, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19)),
new KeyValue(getNode().scaleZProperty(), 1, Interpolator.SPLINE(0.55, 0.055, 0.675, 0.19))
)
));
}
@Override
protected void animateDisplay() {
if (GlobalSettings.getUseAnimations()) {
double startY = -160;
double duration = getDuration(400);
Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1);
Timeline timeline = new Timeline();
ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();
keyFrames.add(new KeyFrame(Duration.millis(0),
new KeyValue(gridPane.opacityProperty(), 0, interpolator),
new KeyValue(gridPane.translateYProperty(), startY, interpolator)
));
keyFrames.add(new KeyFrame(Duration.millis(duration),
new KeyValue(gridPane.opacityProperty(), 1, interpolator),
new KeyValue(gridPane.translateYProperty(), 0, interpolator)
));
timeline.play();
}
}
@Override
void initTimeline() {
double startY = getNode().getScene().getHeight() - getNode().localToScene(0, 0).getY();
setTimeline( new Timeline(
new KeyFrame(Duration.millis(0),
new KeyValue(getNode().opacityProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)),
new KeyValue(getNode().translateYProperty(), startY, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
),
new KeyFrame(Duration.millis(600),
new KeyValue(getNode().opacityProperty(), 1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)),
new KeyValue(getNode().translateYProperty(), -20, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
),
new KeyFrame(Duration.millis(750),
new KeyValue(getNode().translateYProperty(), 10, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
),
new KeyFrame(Duration.millis(900),
new KeyValue(getNode().translateYProperty(), -5, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
),
new KeyFrame(Duration.millis(1000),
new KeyValue(getNode().translateYProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000))
)
));
}
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
);
}
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;
}
/**
* 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;
}
private void flipForward() {
timeline.stop();
flap.setCache(true);
flap.setCacheHint(CacheHint.ROTATE);
//flap.setCacheHint(CacheHint.SPEED);
currentSelectionIndex++;
if (currentSelectionIndex >= characters.size()) {
currentSelectionIndex = 0;
}
nextSelectionIndex = currentSelectionIndex + 1;
if (nextSelectionIndex >= characters.size()) {
nextSelectionIndex = 0;
}
KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
//KeyValue keyValueFlap = new KeyValue(rotateFlap.angleProperty(), 180, Interpolator.EASE_IN);
KeyFrame keyFrame = new KeyFrame(Duration.millis(tile.getFlipTimeInMS()), keyValueFlap);
timeline.getKeyFrames().setAll(keyFrame);
timeline.play();
}
public void setValue(final double VALUE) {
if (animated) {
oldValue = value;
value = VALUE;
timeline.stop();
KeyValue kv1 = new KeyValue(currentValue, oldValue, Interpolator.EASE_BOTH);
KeyValue kv2 = new KeyValue(currentValue, VALUE, Interpolator.EASE_BOTH);
KeyFrame kf1 = new KeyFrame(Duration.ZERO, kv1);
KeyFrame kf2 = new KeyFrame(Duration.millis(animationDuration), kv2);
timeline.getKeyFrames().setAll(kf1, kf2);
timeline.play();
} else {
oldValue = value;
value = VALUE;
fireChartDataEvent(FINISHED_EVENT);
}
}
public void setDuration(final java.time.Duration DURATION) {
if (animated) {
oldDuration = duration;
duration = DURATION;
timeline.stop();
KeyValue kv1 = new KeyValue(currentDuration, oldDuration, Interpolator.EASE_BOTH);
KeyValue kv2 = new KeyValue(currentDuration, DURATION, Interpolator.EASE_BOTH);
KeyFrame kf1 = new KeyFrame(Duration.ZERO, kv1);
KeyFrame kf2 = new KeyFrame(Duration.millis(animationDuration), kv2);
timeline.getKeyFrames().setAll(kf1, kf2);
timeline.play();
} else {
oldDuration = duration;
duration = DURATION;
fireChartDataEvent(FINISHED_EVENT);
}
}
private void createSlideAnimation(Timeline timeline, double imageWidth) {
Interpolator interpolator = Interpolator.EASE_OUT;
ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();
double endX = -imageWidth;
keyFrames.add(new KeyFrame(Duration.millis(0),
new KeyValue(sectionScreenshot.opacityProperty(), 1, interpolator),
new KeyValue(sectionScreenshot.translateXProperty(), 0, interpolator)));
keyFrames.add(new KeyFrame(Duration.millis(DURATION),
event -> {
sectionDescriptionLabel.setText(selectedSection.description);
sectionScreenshot.setId(selectedSection.imageId);
},
new KeyValue(sectionScreenshot.opacityProperty(), 0, interpolator),
new KeyValue(sectionScreenshot.translateXProperty(), endX, interpolator)));
double startX = imageWidth;
keyFrames.add(new KeyFrame(Duration.millis(DURATION),
new KeyValue(sectionScreenshot.opacityProperty(), 0, interpolator),
new KeyValue(sectionScreenshot.translateXProperty(), startX, interpolator)));
keyFrames.add(new KeyFrame(Duration.millis(DURATION * 2),
new KeyValue(sectionScreenshot.opacityProperty(), 1, interpolator),
new KeyValue(sectionScreenshot.translateXProperty(), 0, interpolator)));
}
BackgroundTransition( Color targetColor ) {
List<BackgroundFill> fills = getBackground().getFills();
if ( !fills.isEmpty() && fills.get( 0 ).getFill() instanceof Color ) {
this.originalColor = ( Color ) fills.get( 0 ).getFill();
} else {
this.originalColor = targetColor.invert();
}
if ( targetColor.equals( originalColor ) ) {
this.targetColor = targetColor.invert();
} else {
this.targetColor = targetColor;
}
setCycleDuration( Duration.millis( 650 ) );
setInterpolator( Interpolator.EASE_OUT );
setCycleCount( 6 );
setAutoReverse( true );
setOnFinished( event -> setBackground( FxUtils.simpleBackground( originalColor ) ) );
}
private KeyFrame[] getKeyFrames(double angle, double duration, Paint color) {
KeyFrame[] frames = new KeyFrame[4];
frames[0] = new KeyFrame(Duration.seconds(duration),
new KeyValue(arc.lengthProperty(), 5, Interpolator.LINEAR),
new KeyValue(arc.startAngleProperty(),
angle + 45 + control.getStartingAngle(),
Interpolator.LINEAR));
frames[1] = new KeyFrame(Duration.seconds(duration + 0.4),
new KeyValue(arc.lengthProperty(), 250, Interpolator.LINEAR),
new KeyValue(arc.startAngleProperty(),
angle + 90 + control.getStartingAngle(),
Interpolator.LINEAR));
frames[2] = new KeyFrame(Duration.seconds(duration + 0.7),
new KeyValue(arc.lengthProperty(), 250, Interpolator.LINEAR),
new KeyValue(arc.startAngleProperty(),
angle + 135 + control.getStartingAngle(),
Interpolator.LINEAR));
frames[3] = new KeyFrame(Duration.seconds(duration + 1.1),
new KeyValue(arc.lengthProperty(), 5, Interpolator.LINEAR),
new KeyValue(arc.startAngleProperty(),
angle + 435 + control.getStartingAngle(),
Interpolator.LINEAR),
new KeyValue(arc.strokeProperty(), color, Interpolator.EASE_BOTH));
return frames;
}
private void rotateNeedle() {
double range = (getSkinnable().getMaxValue() - getSkinnable().getMinValue());
double angleRange = getSkinnable().getAngleRange();
angleStep = angleRange / range;
double targetAngle = needleRotate.getAngle() + (getSkinnable().getValue() - getSkinnable().getOldValue()) * angleStep;
if (getSkinnable().isAnimated()) {
timeline.stop();
//double animationDuration = (getSkinnable().getAnimationDuration() / (getSkinnable().getMaxValue() - getSkinnable().getMinValue())) * Math.abs(getSkinnable().getValue() - getSkinnable().getOldValue());
final KeyValue KEY_VALUE = new KeyValue(needleRotate.angleProperty(), targetAngle, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
final KeyFrame KEY_FRAME = new KeyFrame(Duration.millis(getSkinnable().getAnimationDuration()), KEY_VALUE);
timeline.getKeyFrames().setAll(KEY_FRAME);
timeline.play();
} else {
needleRotate.setAngle(targetAngle);
}
}
public void close() {
if (State.CLOSED == getState()) return;
setState(State.CLOSED);
RotateTransition rotate = new RotateTransition();
rotate.setNode(cross);
rotate.setToAngle(0);
rotate.setDuration(Duration.millis(200));
rotate.setInterpolator(Interpolator.EASE_BOTH);
rotate.play();
closeTimeLines[closeTimeLines.length - 1].setOnFinished(actionEvent -> {
FadeTransition buttonFadeOut = new FadeTransition();
buttonFadeOut.setNode(mainMenuButton);
buttonFadeOut.setDuration(Duration.millis(100));
buttonFadeOut.setToValue(options.getButtonAlpha());
buttonFadeOut.play();
buttonFadeOut.setOnFinished(event -> {
if (options.isButtonHideOnClose()) hide();
fireMenuEvent(new MenuEvent(this, null, MenuEvent.MENU_CLOSE_FINISHED));
});
});
for (int i = 0 ; i < closeTimeLines.length ; i++) {
closeTimeLines[i].play();
}
fireMenuEvent(new MenuEvent(this, null, MenuEvent.MENU_CLOSE_STARTED));
}
CheckBoxTransition(Node mark) {
super(null, new Timeline(
new KeyFrame(
Duration.ZERO,
new KeyValue(mark.opacityProperty(), 0, Interpolator.EASE_OUT),
new KeyValue(mark.scaleXProperty(), 0.5, Interpolator.EASE_OUT),
new KeyValue(mark.scaleYProperty(), 0.5, Interpolator.EASE_OUT)
),
new KeyFrame(Duration.millis(400),
new KeyValue(mark.opacityProperty(), 1, Interpolator.EASE_OUT),
new KeyValue(mark.scaleXProperty(), 0.5, Interpolator.EASE_OUT),
new KeyValue(mark.scaleYProperty(), 0.5, Interpolator.EASE_OUT)
),
new KeyFrame(
Duration.millis(1000),
new KeyValue(mark.scaleXProperty(), 1, Interpolator.EASE_OUT),
new KeyValue(mark.scaleYProperty(), 1, Interpolator.EASE_OUT)
)
)
);
// reduce the number to increase the shifting , increase number to reduce shifting
setCycleDuration(Duration.seconds(0.12));
setDelay(Duration.seconds(0.05));
this.mark = mark;
}
private void hideError() {
if (heightChanged) {
new Timeline(new KeyFrame(Duration.millis(160),
new KeyValue(translateYProperty(), 0, Interpolator.EASE_BOTH))).play();
// reset the height of text field
new Timeline(new KeyFrame(Duration.millis(160),
new KeyValue(minHeightProperty(), initHeight, Interpolator.EASE_BOTH))).play();
heightChanged = false;
}
// clear error label text
errorLabel.setText(null);
oldErrorLabelHeight = errorLabelInitHeight;
// clear error icon
errorIcon.getChildren().clear();
// reset the height of the text field
currentFieldHeight = initHeight;
// hide error container
errorContainer.setVisible(false);
errorShown = false;
}