public ScaleTransitionSample() { super(150,150); Rectangle rect = new Rectangle(50, 50, 50, 50); rect.setArcHeight(15); rect.setArcWidth(15); rect.setFill(Color.ORANGE); getChildren().add(rect); scaleTransition = ScaleTransitionBuilder.create() .node(rect) .duration(Duration.seconds(4)) .toX(3) .toY(3) .cycleCount(Timeline.INDEFINITE) .autoReverse(true) .build(); }
/** * Builds the text part animation. * * @param textNode the text node * @return the animation */ private Animation buildTextPartAnimation(final Text textNode) { return ParallelTransitionBuilder.create() .node(textNode) .children( ScaleTransitionBuilder.create() .duration(Duration.millis(300)) // SHOULD BE CONFIGURABLE (Game Speed) .fromX(0.0).toX(1.0) .fromY(0.0).toY(1.0) .build()) .build(); }
/** * Gets the expression resolved. * * @return the expression resolved */ private Animation buildExpressionResolved() { return ParallelTransitionBuilder.create() .delay(Duration.millis(400)) .children( ScaleTransitionBuilder.create() .node(this.result) .fromX(1).toX(4.0) .fromY(1).toY(4.0) .build(), ScaleTransitionBuilder.create() .node(getLeftOperand()) .fromX(1).toX(0) .fromY(1).toY(0) .build(), ScaleTransitionBuilder.create() .node(getOperator()) .fromX(1).toX(0) .fromY(1).toY(0) .build(), ScaleTransitionBuilder.create() .node(getRightOperand()) .fromX(1).toX(0) .fromY(1).toY(0) .build(), ScaleTransitionBuilder.create() .node(getEquality()) .fromX(1).toX(0) .fromY(1).toY(0) .build()) .build(); }
/** * Gets the expression failure. * * @return the expression failure */ private Animation buildExpressionFailure() { return ScaleTransitionBuilder.create() .delay(Duration.millis(500)) .node(getResult()) .fromX(1).toX(0.0) .fromY(1).toY(0.0) .duration(Duration.millis(400)) .build(); }
/** * Build a bean animation. * * @param label the attached label * @param shape the shape to show * @param fillColor the color to use to paint the shape * * @return the bean animation */ private Animation buildBeanAnimation(final Label label, final Shape shape, final Color fillColor) { return ParallelTransitionBuilder.create() .children( ScaleTransitionBuilder.create().node(label).delay(Duration.millis(50)).duration(Duration.millis(300)) .fromX(0).fromY(0).toX(1).toY(1).build(), FillTransitionBuilder.create().shape(shape) .fromValue(Color.LIGHTGREY).toValue(fillColor) .build()) .build(); }
public void handle(ActionEvent t) { double parentRot = slide.getParent().getParent().getRotate(); double parentScale = slide.getParent().getParent().getScaleX(); if (parentScale != PresentationController.SCALE) { ScaleTransitionBuilder.create() .node(slide.getParent().getParent()) .toX(PresentationController.SCALE) .toY(PresentationController.SCALE) .duration(Duration.millis(600)) .onFinished(this) .build().play(); } else if (parentRot != PresentationController.getRotation(slide.getRotate())) { RotateTransitionBuilder.create() .toAngle(PresentationController.getRotation(slide.getRotate())) .node(slide.getParent().getParent()) .onFinished(this) .duration(Duration.millis(600)).build().play(); } else { Bounds point = slide.localToScene(slide.getBoundsInLocal()); double nowX = point.getMinX(); double nowY = point.getMinY(); TranslateTransitionBuilder.create() .node(slide.getParent().getParent()) .byX(-nowX) .byY(-nowY) .interpolator(Interpolator.EASE_OUT) .duration(Duration.millis(600)) .onFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { slide.toFront(); onFinished.handle(arg0); } }) .build().play(); } }
/** * Activate dock feedback on screen's bounds * * @param x * @param y */ public void setDockFeedbackVisible(double x, double y, double width, double height) { dockFeedback.setVisible(true); dockFeedback.setLayoutX(x); dockFeedback.setLayoutY(y); dockFeedback.setWidth(width); dockFeedback.setHeight(height); FadeTransition fadeTransition = FadeTransitionBuilder.create() .duration(Duration.millis(100)) .node(dockFeedback) .fromValue(0) .toValue(1) .autoReverse(true) .cycleCount(4) .build(); ScaleTransition scaleTransition = ScaleTransitionBuilder.create() .duration(Duration.millis(400)) .node(dockFeedback) .fromX(0.4) .fromY(0.4) .toX(1) .toY(1) .build(); parallelTransition = new ParallelTransition(dockFeedback); parallelTransition.getChildren().addAll(fadeTransition, scaleTransition); parallelTransition.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { dockFeedback.setVisible(false); } }); parallelTransition.play(); }