use of javafx.animation.KeyValue in project JFoenix by jfoenixadmin.
the class JFXTabPaneSkin method layoutChildren.
@Override
protected void layoutChildren(final double x, final double y, final double w, final double h) {
double headerHeight = snapSize(headerContainer.prefHeight(-1));
headerContainer.resize(w, headerHeight);
headerContainer.relocate(x, y);
headerContainerClip.setX(0);
headerContainerClip.setY(0);
headerContainerClip.setWidth(w);
// 10 is the height of the shadow effect
headerContainerClip.setHeight(headerHeight + 10);
// position the tab content for the selected tab only
double contentStartX = 0;
double contentStartY = 0;
contentStartX = x;
contentStartY = y + headerHeight;
double contentWidth = w - (0);
double contentHeight = h - (headerHeight);
Rectangle clip = new Rectangle(contentWidth, contentHeight);
tabsContainerHolder.setClip(clip);
tabsContainerHolder.resize(contentWidth, contentHeight);
tabsContainerHolder.relocate(contentStartX, contentStartY);
tabsContainer.resize(contentWidth * tabContentHolders.size(), contentHeight);
for (int i = 0, max = tabContentHolders.size(); i < max; i++) {
TabContentHolder tabContentHolder = tabContentHolders.get(i);
tabContentHolder.setVisible(true);
tabContentHolder.setTranslateX(contentWidth * i);
if (tabContentHolder.getClip() != null) {
((Rectangle) tabContentHolder.getClip()).setWidth(contentWidth);
((Rectangle) tabContentHolder.getClip()).setHeight(contentHeight);
}
if (tabContentHolder.tab == selectedTab) {
int index = getSkinnable().getTabs().indexOf(selectedTab);
if (index != i) {
tabsContainer.setTranslateX(-contentWidth * i);
diffTabsIndices = i - index;
} else {
// fix X translation after changing the tabs
if (diffTabsIndices != 0) {
tabsContainer.setTranslateX(tabsContainer.getTranslateX() + contentWidth * diffTabsIndices);
diffTabsIndices = 0;
}
// animate upon tab selection only otherwise just translate the selected tab
if (isSelectingTab) {
new CachedTransition(tabsContainer, new Timeline(new KeyFrame(Duration.millis(1000), new KeyValue(tabsContainer.translateXProperty(), -contentWidth * index, Interpolator.EASE_BOTH)))) {
{
setCycleDuration(Duration.seconds(0.320));
setDelay(Duration.seconds(0));
}
}.play();
} else
tabsContainer.setTranslateX(-contentWidth * index);
}
}
tabContentHolder.resize(contentWidth, contentHeight);
}
}
use of javafx.animation.KeyValue in project JFoenix by jfoenixadmin.
the class JFXCustomColorPicker method preAnimate.
public void preAnimate() {
double x = curves.get(0).getStartX();
double y = curves.get(0).getStartY();
curves.get(0).setStartX(centerX);
curves.get(0).setStartY(centerY);
double x1 = curves.get(1).getStartX();
double y1 = curves.get(1).getStartY();
curves.get(1).setStartX(centerX);
curves.get(1).setStartY(centerY);
double cx1 = curves.get(0).getControlX1();
double cy1 = curves.get(0).getControlY1();
curves.get(0).setControlX1(centerX + radius);
curves.get(0).setControlY1(centerY + radius / 2);
showAnimation = new CachedTransition(this, new Timeline(new KeyFrame(Duration.millis(1000), new KeyValue(curves.get(0).startXProperty(), x, Interpolator.EASE_BOTH), new KeyValue(curves.get(0).startYProperty(), y, Interpolator.EASE_BOTH), new KeyValue(curves.get(1).startXProperty(), x1, Interpolator.EASE_BOTH), new KeyValue(curves.get(1).startYProperty(), y1, Interpolator.EASE_BOTH), new KeyValue(curves.get(0).controlX1Property(), cx1, Interpolator.EASE_BOTH), new KeyValue(curves.get(0).controlY1Property(), cy1, Interpolator.EASE_BOTH)))) {
{
setCycleDuration(Duration.millis(240));
setDelay(Duration.millis(0));
}
};
}
use of javafx.animation.KeyValue in project JFoenix by jfoenixadmin.
the class JFXColorPickerSkin method updateColor.
private void updateColor() {
final ColorPicker colorPicker = (ColorPicker) getSkinnable();
// update picker box color
Circle ColorCircle = new Circle();
ColorCircle.setFill(colorPicker.getValue());
ColorCircle.setLayoutX(pickerColorBox.getWidth() / 4);
ColorCircle.setLayoutY(pickerColorBox.getHeight() / 2);
pickerColorBox.getChildren().add(ColorCircle);
Timeline animateColor = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(ColorCircle.radiusProperty(), 200, Interpolator.EASE_BOTH)));
animateColor.setOnFinished((finish) -> {
pickerColorBox.setBackground(new Background(new BackgroundFill(ColorCircle.getFill(), pickerColorBox.getBackground().getFills().get(0).getRadii(), pickerColorBox.getBackground().getFills().get(0).getInsets())));
pickerColorBox.getChildren().remove(ColorCircle);
});
animateColor.play();
// update label color
displayNode.setTextFill(colorPicker.getValue().grayscale().getRed() < 0.5 ? Color.valueOf("rgba(255, 255, 255, 0.87)") : Color.valueOf("rgba(0, 0, 0, 0.87)"));
if (colorLabelVisible.get())
displayNode.setText(colorDisplayName(colorPicker.getValue()));
else
displayNode.setText("");
}
use of javafx.animation.KeyValue in project JFoenix by jfoenixadmin.
the class JFXSpinner method layoutChildren.
/**
* {@inheritDoc}
*/
@Override
protected void layoutChildren() {
if (!initialized) {
super.layoutChildren();
initialColor = (Color) arc.getStroke();
if (initialColor == null) {
arc.setStroke(blueColor);
}
KeyFrame[] blueFrame = getKeyFrames(0, 0, initialColor == null ? blueColor : initialColor);
KeyFrame[] redFrame = getKeyFrames(450, 1.4, initialColor == null ? redColor : initialColor);
KeyFrame[] yellowFrame = getKeyFrames(900, 2.8, initialColor == null ? yellowColor : initialColor);
KeyFrame[] greenFrame = getKeyFrames(1350, 4.2, initialColor == null ? greenColor : initialColor);
KeyFrame endingFrame = new KeyFrame(Duration.seconds(5.6), new KeyValue(arc.lengthProperty(), 5, Interpolator.LINEAR), new KeyValue(arc.startAngleProperty(), 1845 + getStartingAngle(), Interpolator.LINEAR));
if (timeline != null)
timeline.stop();
timeline = new Timeline(blueFrame[0], blueFrame[1], blueFrame[2], blueFrame[3], redFrame[0], redFrame[1], redFrame[2], redFrame[3], yellowFrame[0], yellowFrame[1], yellowFrame[2], yellowFrame[3], greenFrame[0], greenFrame[1], greenFrame[2], greenFrame[3], endingFrame);
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.setRate(1);
timeline.play();
initialized = true;
}
}
use of javafx.animation.KeyValue in project fxexperience2 by EricCanull.
the class BounceInDownTransition method starting.
@Override
protected void starting() {
double startY = -node.localToScene(0, 0).getY() - node.getBoundsInParent().getHeight();
timeline = new Timeline();
timeline.getKeyFrames().add(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(node.translateYProperty(), startY, WEB_EASE)));
timeline.getKeyFrames().add(new KeyFrame(Duration.millis(600), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(node.translateYProperty(), 30, WEB_EASE)));
timeline.getKeyFrames().add(new KeyFrame(Duration.millis(800), new KeyValue(node.translateYProperty(), -10, WEB_EASE)));
timeline.getKeyFrames().add(new KeyFrame(Duration.millis(1000), new KeyValue(node.translateYProperty(), 0, WEB_EASE)));
super.starting();
}
Aggregations