use of javafx.animation.ParallelTransition in project JFoenix by jfoenixadmin.
the class JFXMasonryPane method layoutChildren.
/**
* {@inheritDoc}
*/
@Override
protected void layoutChildren() {
performingLayout = true;
int col, row;
col = (int) Math.floor((getWidth() + getHSpacing() - snappedLeftInset() - snappedRightInset()) / (getCellWidth() + getHSpacing()));
col = getLimitColumn() != -1 && col > getLimitColumn() ? getLimitColumn() : col;
if (matrix != null && col == matrix[0].length) {
performingLayout = false;
return;
}
// (int) Math.floor(this.getHeight() / (cellH + 2*vSpacing));
row = getLimitRow();
matrix = new int[row][col];
double minWidth = -1;
double minHeight = -1;
List<BoundingBox> newBoxes;
List<Region> managedChildren = getManagedChildren();
// filter Region nodes
for (int i = 0; i < managedChildren.size(); i++) {
if (!(managedChildren.get(i) instanceof Region)) {
managedChildren.remove(i);
i--;
}
}
// get bounding boxes layout
newBoxes = layoutMode.get().fillGrid(matrix, managedChildren, getCellWidth(), getCellHeight(), row, col, getHSpacing(), getVSpacing());
if (newBoxes == null) {
performingLayout = false;
return;
}
HashMap<Node, BoundingBox> oldBoxes = boundingBoxes;
if (dirtyBoxes) {
boundingBoxes = new HashMap<>();
}
for (int i = 0; i < managedChildren.size() && i < newBoxes.size(); i++) {
final Region child = managedChildren.get(i);
final BoundingBox boundingBox = newBoxes.get(i);
if (!(child instanceof GridPane)) {
double blockX;
double blockY;
double blockWidth;
double blockHeight;
if (boundingBox != null) {
blockX = boundingBox.getMinY() * getCellWidth() + boundingBox.getMinY() * getHSpacing() + snappedLeftInset();
blockY = boundingBox.getMinX() * getCellHeight() + boundingBox.getMinX() * getVSpacing() + snappedTopInset();
blockWidth = boundingBox.getWidth() * getCellWidth() + (boundingBox.getWidth() - 1) * getHSpacing();
blockHeight = boundingBox.getHeight() * getCellHeight() + (boundingBox.getHeight() - 1) * getVSpacing();
} else {
blockX = child.getLayoutX();
blockY = child.getLayoutY();
blockWidth = -1;
blockHeight = -1;
}
if (animationMap == null) {
// init static children
child.setPrefSize(blockWidth, blockHeight);
child.resizeRelocate(blockX, blockY, blockWidth, blockHeight);
} else {
BoundingBox oldBoundingBox = oldBoxes.get(child);
if (oldBoundingBox == null || (!oldBoundingBox.equals(boundingBox) && dirtyBoxes)) {
// handle new children
child.setOpacity(0);
child.setPrefSize(blockWidth, blockHeight);
child.resizeRelocate(blockX, blockY, blockWidth, blockHeight);
}
if (boundingBox != null) {
// handle children repositioning
if (child.getWidth() != blockWidth || child.getHeight() != blockHeight) {
child.setOpacity(0);
child.setPrefSize(blockWidth, blockHeight);
child.resizeRelocate(blockX, blockY, blockWidth, blockHeight);
}
final KeyFrame keyFrame = new KeyFrame(Duration.millis(2000), new KeyValue(child.opacityProperty(), 1, Interpolator.LINEAR), new KeyValue(child.layoutXProperty(), blockX, Interpolator.LINEAR), new KeyValue(child.layoutYProperty(), blockY, Interpolator.LINEAR));
animationMap.put(child, new CachedTransition(child, new Timeline(keyFrame)) {
{
setCycleDuration(Duration.seconds(0.320));
setDelay(Duration.seconds(0));
setOnFinished((finish) -> {
child.setLayoutX(blockX);
child.setLayoutY(blockY);
child.setOpacity(1);
});
}
});
} else {
// handle children is being hidden ( cause it can't fit in the pane )
final KeyFrame keyFrame = new KeyFrame(Duration.millis(2000), new KeyValue(child.opacityProperty(), 0, Interpolator.LINEAR), new KeyValue(child.layoutXProperty(), blockX, Interpolator.LINEAR), new KeyValue(child.layoutYProperty(), blockY, Interpolator.LINEAR));
animationMap.put(child, new CachedTransition(child, new Timeline(keyFrame)) {
{
setCycleDuration(Duration.seconds(0.320));
setDelay(Duration.seconds(0));
setOnFinished((finish) -> {
child.setLayoutX(blockX);
child.setLayoutY(blockY);
child.setOpacity(0);
});
}
});
}
}
// update bounding box
boundingBoxes.put(child, boundingBox);
if (boundingBox != null) {
if (blockX + blockWidth > minWidth) {
minWidth = blockX + blockWidth;
}
if (blockY + blockHeight > minHeight) {
minHeight = blockY + blockHeight;
}
}
}
}
if (minHeight != -1) {
minHeight += snappedBottomInset();
setPrefHeight(minHeight);
}
if (animationMap == null) {
animationMap = new HashMap<>();
}
trans.stop();
ParallelTransition newTransition = new ParallelTransition();
newTransition.getChildren().addAll(animationMap.values());
newTransition.play();
trans = newTransition;
dirtyBoxes = false;
performingLayout = false;
}
use of javafx.animation.ParallelTransition in project JFoenix by jfoenixadmin.
the class JFXAutoCompletePopupSkin method animate.
public void animate() {
updateListHeight();
if (showTransition == null || showTransition.getStatus().equals(Status.STOPPED)) {
if (scale == null) {
scale = new Scale(1, 0);
pane.getTransforms().add(scale);
}
scale.setY(0);
suggestionList.setOpacity(0);
scale.setPivotX(pane.getLayoutBounds().getWidth() / 2);
showTransition = new Timeline(new KeyFrame(Duration.millis(120), new KeyValue(scale.yProperty(), 1, Interpolator.EASE_BOTH)));
showTransition.setOnFinished((finish) -> {
Group vf = (Group) suggestionList.lookup(".sheet");
ParallelTransition trans = new ParallelTransition();
for (int i = 0; i < vf.getChildren().size(); i++) {
ListCell<T> cell = (ListCell<T>) vf.getChildren().get(i);
int index = cell.getIndex();
if (index > -1) {
cell.setOpacity(0);
cell.setTranslateY(-suggestionList.getFixedCellSize() / 8);
Timeline f = new Timeline(new KeyFrame(Duration.millis(120), end -> {
cell.setOpacity(1);
cell.setTranslateY(0);
}, new KeyValue(cell.opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(cell.translateYProperty(), 0, Interpolator.EASE_BOTH)));
f.setDelay(Duration.millis(index * 20));
trans.getChildren().add(f);
}
}
suggestionList.setOpacity(1);
trans.play();
});
showTransition.play();
}
}
use of javafx.animation.ParallelTransition in project Malai by arnobl.
the class DnDHelpAnimation method createTransition.
@Override
public Transition createTransition() {
ell = new Ellipse(x1, y1, size, size);
text = new Text(textPress);
text.xProperty().bind(ell.centerXProperty().add(ell.getRadiusX()));
text.yProperty().bind(ell.centerYProperty().subtract(ell.getRadiusY()));
ell.setFill(Color.LIGHTGRAY);
ell.setEffect(new DropShadow(20d, Color.BLACK));
helpPane.getChildren().add(ell);
helpPane.getChildren().add(text);
ell.setVisible(false);
text.setVisible(false);
ell.setFocusTraversable(false);
ell.setMouseTransparent(true);
text.setFocusTraversable(false);
text.setMouseTransparent(true);
final SequentialTransition mainTrans = new SequentialTransition();
final ParallelTransition parallelTransition = new ParallelTransition(new Timeline(new KeyFrame(duration, new KeyValue(ell.centerXProperty(), x2))), new Timeline(new KeyFrame(duration, new KeyValue(ell.centerYProperty(), y2))));
mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(text.visibleProperty(), Boolean.TRUE))));
mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(ell.visibleProperty(), Boolean.TRUE))));
mainTrans.getChildren().add(new PauseTransition(Duration.seconds(1.5)));
mainTrans.getChildren().add(new ParallelTransition(new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusXProperty(), size / 2d))), new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusYProperty(), size / 2d)))));
mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(100d), new KeyValue(text.textProperty(), textDrag))));
mainTrans.getChildren().add(parallelTransition);
mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(100d), new KeyValue(text.textProperty(), textRelease))));
mainTrans.getChildren().add(new ParallelTransition(new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusXProperty(), size))), new Timeline(new KeyFrame(Duration.millis(400d), new KeyValue(ell.radiusYProperty(), size)))));
mainTrans.getChildren().add(new PauseTransition(Duration.seconds(1.5)));
mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(text.visibleProperty(), Boolean.FALSE))));
mainTrans.getChildren().add(new Timeline(new KeyFrame(Duration.millis(10), new KeyValue(ell.visibleProperty(), Boolean.FALSE))));
transition = mainTrans;
return transition;
}
use of javafx.animation.ParallelTransition in project tilesfx by HanSolo.
the class StockTileSkin method handleCurrentValue.
@Override
protected void handleCurrentValue(final double VALUE) {
low = Statistics.getMin(dataList);
high = Statistics.getMax(dataList);
if (Helper.equals(low, high)) {
low = minValue;
high = maxValue;
}
range = high - low;
double minX = graphBounds.getX();
double maxX = minX + graphBounds.getWidth();
double minY = graphBounds.getY();
double maxY = minY + graphBounds.getHeight();
double stepX = graphBounds.getWidth() / (noOfDatapoints - 1);
double stepY = graphBounds.getHeight() / range;
double referenceValue = tile.getReferenceValue();
if (!dataList.isEmpty()) {
MoveTo begin = (MoveTo) pathElements.get(0);
begin.setX(minX);
begin.setY(maxY - Math.abs(low - dataList.get(0)) * stepY);
for (int i = 1; i < (noOfDatapoints - 1); i++) {
LineTo lineTo = (LineTo) pathElements.get(i);
lineTo.setX(minX + i * stepX);
lineTo.setY(maxY - Math.abs(low - dataList.get(i)) * stepY);
}
LineTo end = (LineTo) pathElements.get(noOfDatapoints - 1);
end.setX(maxX);
end.setY(maxY - Math.abs(low - dataList.get(noOfDatapoints - 1)) * stepY);
dot.setCenterX(maxX);
dot.setCenterY(end.getY());
updateState(VALUE, referenceValue);
referenceLine.setStartY(maxY - Math.abs(low - referenceValue) * stepY);
referenceLine.setEndY(maxY - Math.abs(low - referenceValue) * stepY);
changeText.setText(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (VALUE - referenceValue)));
changePercentageText.setText(new StringBuilder().append(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (VALUE / referenceValue * 100.0) - 100.0)).append("\u0025").toString());
RotateTransition rotateTransition = new RotateTransition(Duration.millis(200), triangle);
rotateTransition.setFromAngle(triangle.getRotate());
rotateTransition.setToAngle(state.angle);
FillTransition fillIndicatorTransition = new FillTransition(Duration.millis(200), triangle);
fillIndicatorTransition.setFromValue((Color) triangle.getFill());
fillIndicatorTransition.setToValue(state.color);
FillTransition fillReferenceTransition = new FillTransition(Duration.millis(200), changePercentageText);
fillReferenceTransition.setFromValue((Color) triangle.getFill());
fillReferenceTransition.setToValue(state.color);
ParallelTransition parallelTransition = new ParallelTransition(rotateTransition, fillIndicatorTransition, fillReferenceTransition);
parallelTransition.play();
}
valueText.setText(String.format(locale, formatString, VALUE));
highText.setText(String.format(locale, formatString, high));
lowText.setText(String.format(locale, formatString, low));
if (!tile.isTextVisible() && null != movingAverage.getTimeSpan()) {
timeSpanText.setText(createTimeSpanText());
text.setText(timeFormatter.format(movingAverage.getLastEntry().getTimestampAsDateTime(tile.getZoneId())));
}
resizeDynamicText();
}
use of javafx.animation.ParallelTransition in project tilesfx by HanSolo.
the class HighLowTileSkin method handleCurrentValue.
@Override
protected void handleCurrentValue(final double VALUE) {
double deviation = calculateDeviation(VALUE);
updateState(deviation);
valueText.setText(String.format(locale, formatString, VALUE));
deviationText.setText(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", deviation));
RotateTransition rotateTransition = new RotateTransition(Duration.millis(200), triangle);
rotateTransition.setFromAngle(triangle.getRotate());
rotateTransition.setToAngle(state.angle);
FillTransition fillIndicatorTransition = new FillTransition(Duration.millis(200), triangle);
fillIndicatorTransition.setFromValue((Color) triangle.getFill());
fillIndicatorTransition.setToValue(state.color);
FillTransition fillReferenceTransition = new FillTransition(Duration.millis(200), deviationText);
fillReferenceTransition.setFromValue((Color) triangle.getFill());
fillReferenceTransition.setToValue(state.color);
FillTransition fillReferenceUnitTransition = new FillTransition(Duration.millis(200), deviationUnitText);
fillReferenceUnitTransition.setFromValue((Color) triangle.getFill());
fillReferenceUnitTransition.setToValue(state.color);
ParallelTransition parallelTransition = new ParallelTransition(rotateTransition, fillIndicatorTransition, fillReferenceTransition, fillReferenceUnitTransition);
parallelTransition.play();
}
Aggregations