Java Code Examples for javafx.animation.RotateTransition

The following are top voted examples for showing how to use javafx.animation.RotateTransition. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: gatepass   File: MainWindow.java   Source Code and License 6 votes vote down vote up
public void rotateHer(Label labelHer, ImageView iv)
{
	RotateTransition rotation = new RotateTransition(Duration.seconds(2), iv);
	rotation.setCycleCount(Animation.INDEFINITE);
	rotation.setByAngle(360);

	iv.setTranslateZ(iv.getBoundsInLocal().getWidth() / 2.0);
	iv.setRotationAxis(Rotate.Y_AXIS);
	
	labelHer.setOnMouseEntered(e ->
	{ 
		rotation.play();
		iv.setRotate(180);
	});
	labelHer.setOnMouseExited(e ->
	{ 
		rotation.pause();
		iv.setRotate(0);
	});
}
 
Example 2
Project: gatepass   File: ExDetails.java   Source Code and License 6 votes vote down vote up
public void rotateHer(Label labelHer, ImageView iv)
{
	RotateTransition rotation = new RotateTransition(Duration.seconds(2), iv);
	rotation.setCycleCount(Animation.INDEFINITE);
	rotation.setByAngle(360);

	iv.setTranslateZ(iv.getBoundsInLocal().getWidth() / 2.0);
	iv.setRotationAxis(Rotate.Y_AXIS);
	
	labelHer.setOnMouseEntered(e ->
	{ 
		rotation.play();
		iv.setRotate(180);
	});
	labelHer.setOnMouseExited(e ->
	{ 
		rotation.pause();
		iv.setRotate(0);
	});
}
 
Example 3
Project: gatepass   File: SysSettings.java   Source Code and License 6 votes vote down vote up
public void rotateHer(Label labelHer, ImageView iv)
{
	RotateTransition rotation = new RotateTransition(Duration.seconds(2.3), iv);
	rotation.setCycleCount(Animation.INDEFINITE);
	rotation.setByAngle(360);

	iv.setTranslateZ(iv.getBoundsInLocal().getWidth() / 2.0);
	iv.setRotationAxis(Rotate.Y_AXIS);
	
	labelHer.setOnMouseEntered(e ->
	{ 
		rotation.play();
		iv.setRotate(180);
	});
	labelHer.setOnMouseExited(e ->
	{ 
		rotation.pause();
		iv.setRotate(0);
	});
}
 
Example 4
Project: tilesfx   File: HighLowTileSkin.java   Source Code and License 6 votes vote down vote up
@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();
}
 
Example 5
Project: programmierpraktikum-abschlussprojekt-amigos   File: ExerciseController.java   Source Code and License 6 votes vote down vote up
private void switchStateAnimation(TDDState newState){
    RotateTransition rotateTransition = new RotateTransition(Duration.millis(800), cycleImage);
    rotateTransition.setFromAngle(0);
    rotateTransition.setToAngle(-180);
    FadeTransition ft = new FadeTransition(Duration.millis(800), cycleImage);
    ft.setFromValue(1);
    ft.setToValue(0);
    RotateTransition rotateTransition2 = new RotateTransition(Duration.millis(800), cycleImageOverlay);
    rotateTransition2.setFromAngle(180);
    rotateTransition2.setToAngle(0);

    Image newImg = getImageOfPhase(newState);
    rotateTransition2.setOnFinished(event -> {
        cycleImage.setImage(newImg);
    });
    FadeTransition ft2 = new FadeTransition(Duration.millis(800), cycleImageOverlay);
    ft2.setFromValue(0);
    ft2.setToValue(1);

    ft.play();
    cycleImageOverlay.setImage(newImg);
    rotateTransition.play();
    ft.play();
    ft2.play();
    rotateTransition2.play();
}
 
Example 6
Project: slogo   File: TurtleView.java   Source Code and License 6 votes vote down vote up
@Override
public void update (Object object) {
    ITurtleState state = (ITurtleState) object;
    
    this.penStyleIndex = state.getPenStyle();
    TranslateTransition tt = new TranslateTransition(Duration.millis(mySpeed), this);

    double currentX = this.getTranslateX(); double currentY = this.getTranslateY();
    tt.setByX(currentX); tt.setByY(currentY); tt.setToX(state.getX()); tt.setToY(state.getY());

    RotateTransition rt = new RotateTransition(Duration.millis(mySpeed), this);

    double currentHeading = this.getRotate();
    rt.setByAngle(currentHeading); rt.setToAngle(state.getHeading());

    ParallelTransition pt = new ParallelTransition();
    pt.getChildren().addAll(tt, rt);

    pt.setOnFinished(e -> {
        updateTurtleState(state);
        System.out.println("myturtle: " + this.toString());
        tooltip.setText(this.toString());
    });

    pt.play();
}
 
Example 7
Project: FXGL   File: TestLoadingScene.java   Source Code and License 6 votes vote down vote up
public TestLoadingScene() {

        getText().setFont(Font.font("Segoe UI", 24));
        getText().setTranslateY(50);

        Circle circle = new Circle(50, 50, 50);

        Shape shape = Shape.subtract(new Rectangle(100, 100), circle);
        shape.setFill(Color.BLUE);
        shape.setStroke(Color.YELLOW);

        RotateTransition rt = new RotateTransition(Duration.seconds(2), shape);
        rt.setByAngle(360);
        rt.setCycleCount(15);
        rt.play();

        shape.setTranslateX(700);
        shape.setTranslateY(500);

        getContentRoot().getChildren().set(1, shape);
    }
 
Example 8
Project: The-Projects   File: Board.java   Source Code and License 6 votes vote down vote up
/**
 * Method to display the movement of a card to a Deck
 * @param card the card to move
 */
private PathTransition moveToDeck(Card card) {
    StackPane deck = ownerToDeck(card.getOwner());
    Path path = new Path(new MoveTo(card.localToParent(0,0).getX() + card.getWidth()/2, card.localToParent(0,0).getY() + card.getHeight()/2),
            new LineTo(deck.localToParent(deck.getWidth()/2.,deck.getHeight()/2.).getX(), deck.localToParent(deck.getWidth()/2.,deck.getHeight()/2.).getY()));

    boolean horizontal = card.getOwner() == Owner.PROJECT_DECK || card.getOwner() == Owner.PROJECT_DISCARD;

    card.toFront();
    if (horizontal) {
        RotateTransition rotateTransition = new RotateTransition(Duration.millis(500), card);
        rotateTransition.setByAngle(-90);
        rotateTransition.play();
    }

    ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(500), card);
    scaleTransition.setToX(horizontal ? deck.getScaleY() : deck.getScaleX());
    scaleTransition.setToY(horizontal ? deck.getScaleX() : deck.getScaleY());
    scaleTransition.play();

    card.setClickable(false, view);

    return new PathTransition(Duration.seconds(.5),path,card);
}
 
Example 9
Project: FXImgurUploader   File: RadialMenu.java   Source Code and License 6 votes vote down vote up
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));
}
 
Example 10
Project: JVx.javafx   File: FXAnimator.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a {@link RotateTransition} that is the second/end part of a flip
 * animation.
 * 
 * @param pNode the {@link Node}.
 * @param pOrientation the {@link Orientation} in which to rotate. Note that
 *            {@link Orientation#HORIZONTAL} means from right to left.
 * @param pRightLeftTopDown {@code true} if the animation should be from
 *            right to left/top to down. {@code false} if it should be left
 *            to right/bottom to up.
 * @return the created {@link RotateTransition}.
 */
public static RotateTransition createFlipEndTransition(Node pNode, Orientation pOrientation, boolean pRightLeftTopDown)
{
	double startingAngle = calculateEdgeAngle(pNode, pOrientation);
	
	RotateTransition endTransition = new RotateTransition(Duration.millis(466), pNode);
	endTransition.setAxis(getAxis(pOrientation));
	if (pRightLeftTopDown)
	{
		endTransition.setFromAngle(startingAngle + 180);
		endTransition.setToAngle(360);
	}
	else
	{
		
		endTransition.setFromAngle(startingAngle);
		endTransition.setToAngle(0);
	}
	endTransition.setInterpolator(Interpolator.EASE_OUT);
	
	return endTransition;
}
 
Example 11
Project: JVx.javafx   File: FXAnimator.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a {@link RotateTransition} that is the first/start part of a flip
 * animation.
 * 
 * @param pNode the {@link Node}.
 * @param pOrientation the {@link Orientation} in which to rotate. Note that
 *            {@link Orientation#HORIZONTAL} means from right to left.
 * @param pRightLeftTopDown {@code true} if the animation should be from
 *            right to left/top to down. {@code false} if it should be left
 *            to right/bottom to up.
 * @return the created {@link RotateTransition}.
 */
public static RotateTransition createFlipStartTransition(Node pNode, Orientation pOrientation, boolean pRightLeftTopDown)
{
	double endingAngle = calculateEdgeAngle(pNode, pOrientation);
	
	RotateTransition transition = new RotateTransition(Duration.millis(466), pNode);
	transition.setAxis(getAxis(pOrientation));
	if (pRightLeftTopDown)
	{
		transition.setFromAngle(0);
		transition.setToAngle(endingAngle);
	}
	else
	{
		transition.setFromAngle(360);
		transition.setToAngle(endingAngle + 180);
	}
	transition.setInterpolator(Interpolator.EASE_IN);
	
	return transition;
}
 
Example 12
Project: FXTutorials   File: Main.java   Source Code and License 6 votes vote down vote up
public LoadingBar() {
    Circle outer = new Circle(50);
    outer.setFill(null);
    outer.setStroke(Color.BLACK);

    Circle inner = new Circle(5);
    inner.setTranslateY(-50);

    rt = new RotateTransition(Duration.seconds(2), this);
    rt.setToAngle(360);
    rt.setInterpolator(Interpolator.LINEAR);
    rt.setCycleCount(RotateTransition.INDEFINITE);

    getChildren().addAll(outer, inner);
    setVisible(false);
}
 
Example 13
Project: FXTutorials   File: FarCry4Loading.java   Source Code and License 6 votes vote down vote up
public LoadingCircle() {
    Circle circle = new Circle(20);
    circle.setFill(null);
    circle.setStroke(Color.WHITE);
    circle.setStrokeWidth(2);

    Rectangle rect = new Rectangle(20, 20);

    Shape shape = Shape.subtract(circle, rect);
    shape.setFill(Color.WHITE);

    getChildren().add(shape);

    animation = new RotateTransition(Duration.seconds(2.5), this);
    animation.setByAngle(-360);
    animation.setInterpolator(Interpolator.LINEAR);
    animation.setCycleCount(Animation.INDEFINITE);
    animation.play();
}
 
Example 14
Project: kelvin-maps   File: ApplicationController.java   Source Code and License 6 votes vote down vote up
/**
 * JavaFX constructor for the ApplicationController.
 */
@FXML
private void initialize() {
  ApplicationController.instance = this;

  ApplicationController.instance.rt = new RotateTransition(
    Duration.millis(10000), this.loadIcon
  );
  ApplicationController.instance.rotateIcon();
  ApplicationController.instance.stackPane.getChildren().remove(
    this.loadIcon
  );

  ApplicationController.addIcon();
  Platform.runLater(() -> {
    MenuController.loadDefault();
  });
}
 
Example 15
Project: javafx-demos   File: DominoSkin.java   Source Code and License 6 votes vote down vote up
private void flipTo180(final Domino.Dot DOT, final String STYLE) {
    final RotateTransition ROT_0_90 = new RotateTransition(FLIP_TIME.divide(2), dotMap.get(DOT));
    ROT_0_90.setAxis(Rotate.Y_AXIS);
    ROT_0_90.setFromAngle(0);
    ROT_0_90.setToAngle(90);
    ROT_0_90.play();
    ROT_0_90.setOnFinished(new EventHandler<ActionEvent>() {
        @Override public void handle(final ActionEvent EVENT) {
            dotMap.get(DOT).getStyleClass().clear();
            dotMap.get(DOT).getStyleClass().add(STYLE);
            final RotateTransition ROT_90_180 = new RotateTransition(FLIP_TIME.divide(2), dotMap.get(DOT));
            ROT_90_180.setAxis(Rotate.Y_AXIS);
            ROT_90_180.setFromAngle(90);
            ROT_90_180.setToAngle(180);
            ROT_90_180.play();
        }
    });
}
 
Example 16
Project: javafx-demos   File: DominoSkin.java   Source Code and License 6 votes vote down vote up
private void flipTo0(final Domino.Dot DOT, final String STYLE) {
    final RotateTransition ROT_180_90 = new RotateTransition(FLIP_TIME.divide(2), dotMap.get(DOT));
    ROT_180_90.setAxis(Rotate.Y_AXIS);
    ROT_180_90.setFromAngle(180);
    ROT_180_90.setToAngle(90);
    ROT_180_90.play();
    ROT_180_90.setOnFinished(new EventHandler<ActionEvent>() {
        @Override public void handle(final ActionEvent EVENT) {
            dotMap.get(DOT).getStyleClass().clear();
            dotMap.get(DOT).getStyleClass().add(STYLE);
            final RotateTransition ROT_90_0 = new RotateTransition(FLIP_TIME.divide(2), dotMap.get(DOT));
            ROT_90_0.setAxis(Rotate.Y_AXIS);
            ROT_90_0.setFromAngle(90);
            ROT_90_0.setToAngle(0);
            ROT_90_0.play();
        }
    });
}
 
Example 17
Project: Enzo   File: RadialMenu.java   Source Code and License 6 votes vote down vote up
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));
}
 
Example 18
Project: Cypher   File: ChatPresenter.java   Source Code and License 5 votes vote down vote up
@FXML
private void initialize() {
	eventBus.register(this);
	messageBox.setDisable(client.getSelectedRoom() == null);

	eventListView.setCellFactory(listView -> {
		EventListItemView memberListItemView = new EventListItemView();
		memberListItemView.getView();
		return (EventListItemPresenter)memberListItemView.getPresenter();
	});

	eventListView.itemsProperty().addListener((observable, oldValue, newValue) -> {

		if(eventListScrollBar != null) {
			eventListScrollBar.valueProperty().removeListener(scrollListener);
		}

		this.eventListScrollBar = getListViewScrollBar(eventListView, Orientation.VERTICAL);

		if(eventListScrollBar != null) {
			eventListScrollBar.valueProperty().addListener(scrollListener);
		}
	});

	// Buffering icon animations
	bufferIconAnimation = new RotateTransition(Duration.millis(1000), bufferingIcon);
	bufferIconAnimation.setCycleCount(Timeline.INDEFINITE);
	bufferIconAnimation.setByAngle(360);
	bufferFadeIn = new FadeTransition(Duration.millis(200), bufferingIcon);
	bufferFadeIn.setFromValue(0.0);
	bufferFadeIn.setToValue(1.0);
	bufferFadeOut = new FadeTransition(Duration.millis(200), bufferingIcon);
	bufferFadeOut.setFromValue(1.0);
	bufferFadeOut.setToValue(0.0);
}
 
Example 19
Project: dynamo   File: GeneratorSkin.java   Source Code and License 5 votes vote down vote up
private void initGraphics() {
    background = new Region();
    background.getStyleClass().setAll("background");

    circleFrame = new Region();
    circleFrame.getStyleClass().setAll("circle-frame");

    circleGears = new Region();
    circleGears.getStyleClass().setAll("circle-gears");
    circleGears.setCache(true);
    circleGears.setCacheHint(CacheHint.SPEED);

    rotateTransition = new RotateTransition(Duration.millis(getSkinnable().getAnimationDuration()), circleGears);
    blinkTimeline = new Timeline(new KeyFrame(Duration.seconds(0.35), event -> circleFrame.setOpacity(circleFrame.getOpacity() == 0 ? 1 : 0)));

    sinCurve = new Region();
    sinCurve.getStyleClass().setAll("sin-curve");

    nameText = new Text(getSkinnable().getName());
    nameText.getStyleClass().setAll("name-text");

    pane = new Pane(background, circleFrame, circleGears, sinCurve, nameText);

    getChildren().add(pane);
    resize();
    updateStateAspect();
    updateAlarmStatus();
}
 
Example 20
Project: wall-t   File: TileView.java   Source Code and License 5 votes vote down vote up
private ImageView queueImageView( final TileViewModel build ) {
    final ImageView queuedIcon = new ImageView( UIUtils.createImage( "icons/queued.png" ) );
    queuedIcon.setFitHeight( 45 );
    queuedIcon.setPreserveRatio( true );
    queuedIcon.visibleProperty( ).bind( build.queuedProperty( ) );

    final RotateTransition transition = new RotateTransition( Duration.seconds( 3 ), queuedIcon );
    transition.setByAngle( 360 );
    transition.setCycleCount( Timeline.INDEFINITE );
    transition.play( );

    return queuedIcon;
}
 
Example 21
Project: voogasalad-ltub   File: GameChooser.java   Source Code and License 5 votes vote down vote up
private void getRotation(Button button){

		RotateTransition rotation = new RotateTransition(Duration.seconds(3), button);
		rotation.setCycleCount(Animation.INDEFINITE);
		rotation.setByAngle(360);
		
		button.setOnMouseEntered(e -> rotation.play());
		button.setOnMouseExited(e -> rotation.pause());
	}
 
Example 22
Project: waterrower-workout   File: IconRotation.java   Source Code and License 5 votes vote down vote up
/**
 * An animation which rotates the icon of a button.
 *
 * @param graphic The graphic on which the icon should be animated, must not be null.
 */
public IconRotation(Node graphic) {
    rotateProperty = graphic.rotateProperty();

    rotation = new RotateTransition(DURATION, graphic);
    rotation.setInterpolator(EASE_BOTH);
    rotation.setCycleCount(INDEFINITE);
    rotation.setFromAngle(0);
    rotation.setToAngle(360);
}
 
Example 23
Project: AnchorFX   File: DockCommandsBox.java   Source Code and License 5 votes vote down vote up
void notifyCloseAction() {
    if (isMenuOpen) {
        isMenuOpen = false;

        RotateTransition rotate = new RotateTransition(Duration.seconds(0.2), menuButton.getGraphic());
        rotate.setToAngle(0);
        rotate.play();

        hideAction.run();
    }
}
 
Example 24
Project: AnchorFX   File: DockCommandsBox.java   Source Code and License 5 votes vote down vote up
void notifyOpenAction() {
    RotateTransition rotate = new RotateTransition(Duration.seconds(0.2), menuButton.getGraphic());
    rotate.setToAngle(90);
    rotate.play();

    openAction.run();
}
 
Example 25
Project: javaFXMDI   File: MyContentController.java   Source Code and License 5 votes vote down vote up
private void btnRotateHandler() {
    btnRotate.setOnAction(event -> {
        MDIWindow myMDI = Utility.getMDIWindow(mainPane);
        RotateTransition rt = new RotateTransition(Duration.millis(1000), myMDI);
        rt.setByAngle(360);
        rt.setCycleCount(1);
        // rt.setAutoReverse(true);
        rt.play();
    });
}
 
Example 26
Project: mars-sim   File: MarsViewer.java   Source Code and License 5 votes vote down vote up
private RotateTransition rotateAroundYAxis(Node node) {
	RotateTransition rotate = new RotateTransition(
			Duration.seconds(ROTATE_SECS),
			node
			);
    rotate.setAxis(Rotate.Y_AXIS);
    rotate.setFromAngle(360);
    rotate.setToAngle(0);
    rotate.setInterpolator(Interpolator.LINEAR);
    rotate.setCycleCount(RotateTransition.INDEFINITE);

    return rotate;
}
 
Example 27
Project: mars-sim   File: SpinningGlobe.java   Source Code and License 5 votes vote down vote up
public void rotateGlobe() {
 rt = new RotateTransition(Duration.seconds(OrbitInfo.SOLAR_DAY/500D), globe.getWorld());
    //rt.setByAngle(360);
    rt.setInterpolator(Interpolator.LINEAR);
    rt.setCycleCount(Animation.INDEFINITE);
    rt.setAxis(Rotate.Y_AXIS);
    rt.setFromAngle(360);
    rt.setToAngle(0);
    rt.play();
}
 
Example 28
Project: FXImgurUploader   File: MenuButton.java   Source Code and License 5 votes vote down vote up
private void initGraphics() {
    setPickOnBounds(false);

    cross = new Region();
    cross.getStyleClass().add("cross");
    cross.setMouseTransparent(true);
    crossRotate = new RotateTransition(Duration.millis(200), cross);
    crossRotate.setInterpolator(Interpolator.EASE_BOTH);

    // Add all nodes
    getChildren().addAll(cross);
}
 
Example 29
Project: JFXMaterial   File: ActionBar.java   Source Code and License 5 votes vote down vote up
public ActionBar(String title) {
    super();
    DoubleProperty heightProperty = new SimpleDoubleProperty();
    hBox = new HBox();
    line = new Line();
    line.setStroke(Color.WHITE);

    line.setStrokeWidth(3);
    rotateTransition = new RotateTransition();
    materialText = new MaterialText("", 17);
    sceneProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            if (!getScene().getStylesheets().contains(getClass().getResource("application.css").toExternalForm())) {
                getScene().getStylesheets().add(getClass().getResource("application.css").toExternalForm());
            }
            newValue.widthProperty().addListener((ob, o, n) -> {
                setPrefSize(n.doubleValue(), 100);
                hBox.setPrefWidth(n.doubleValue());

            });
            heightProperty.bind(newValue.heightProperty());
            hBox.setLayoutY(50);
        }
    });
    line.setTranslateY(97);
    hBox.setFillHeight(true);
    hBox.setAlignment(Pos.CENTER);
    getStyleClass().add("material-toolbar");
    setTitle(title);
    getChildren().addAll(hBox, line);
}
 
Example 30
Project: fr.xs.jtk   File: Planetoid.java   Source Code and License 5 votes vote down vote up
private RotateTransition selfRotation() {
	RotateTransition rotate = new RotateTransition(Duration.seconds(ROTATE_SECS), this);
	rotate.setAxis(Rotate.Y_AXIS);
	rotate.setFromAngle(clockRotate ? 0 : 360);
	rotate.setToAngle(clockRotate ? 360 : 0);
	rotate.setInterpolator(Interpolator.LINEAR);
	rotate.setCycleCount(RotateTransition.INDEFINITE);

	return rotate;
}
 
Example 31
Project: JVx.javafx   File: FXAnimator.java   Source Code and License 5 votes vote down vote up
/**
 * Flips the given {@link Node} in the given direction until it is turned
 * roughly 90 degrees, read it is not visible anymore. Then the first
 * {@link Runnable} {@code pOnTippingPoint} will be executed which allows to
 * swap the content or properties of the {@link Node} without the user
 * seeing it. After that the rotation will continue back into its starting
 * position, where {@code pOnFinished} will be called.
 * <p>
 * If there is a {@link PerspectiveCamera} is set on the {@link Scene}, this
 * function will already choose the correct angle needed for the tipping
 * point so that the user will not see the swap of the content.
 * 
 * @param pNode the {@link Node} to rotate.
 * @param pOrientation the {@link Orientation} in which to rotate. Note that
 *            {@link Orientation#HORIZONTAL} means from right to left.
 * @param pRightLeftTopDown {@code true} if the animation should be from
 *            right to left/top to down. {@code false} if it should be left
 *            to right/bottom to up.
 * @param pOnTippingPoint the {@link Runnable} to execute when the
 *            {@link Node} is exactly edge on with the viewer. Can be
 *            {@code null}.
 * @param pOnFinished the {@link Runnable} to execute when the rotation has
 *            finished. Can be {@code null}.
 */
public static void flip(Node pNode, Orientation pOrientation, boolean pRightLeftTopDown, Runnable pOnTippingPoint, Runnable pOnFinished)
{
	double tippingPoint = calculateEdgeAngle(pNode, pOrientation);
	
	RotateTransition startTransition = createFlipStartTransition(pNode, pOrientation, pRightLeftTopDown);
	RotateTransition endTransition = createFlipEndTransition(pNode, pOrientation, pRightLeftTopDown);
	
	startTransition.setOnFinished(pActionEvent ->
	{
		if (pOnTippingPoint != null)
		{
			pOnTippingPoint.run();
		}
		
		pNode.setRotate(tippingPoint + 180);
		
		endTransition.play();
	});
	
	if (pOnFinished != null)
	{
		endTransition.setOnFinished(pActionEvent -> pOnFinished.run());
	}
	
	startTransition.play();
}
 
Example 32
Project: FXTutorials   File: Dice.java   Source Code and License 5 votes vote down vote up
public void roll() {
    RotateTransition rt = new RotateTransition(Duration.seconds(1), this);
    rt.setFromAngle(0);
    rt.setToAngle(360);
    rt.setOnFinished(event -> {
        valueProperty.set((int)(Math.random() * (MAX_VALUE - MIN_VALUE + 1)) + MIN_VALUE);
    });
    rt.play();
}
 
Example 33
Project: FXTutorials   File: HangmanMain.java   Source Code and License 5 votes vote down vote up
public void show() {
    RotateTransition rt = new RotateTransition(Duration.seconds(1), bg);
    rt.setAxis(Rotate.Y_AXIS);
    rt.setToAngle(180);
    rt.setOnFinished(event -> text.setVisible(true));
    rt.play();
}
 
Example 34
Project: kelvin-maps   File: ApplicationController.java   Source Code and License 5 votes vote down vote up
/**
 * To rotate the load icon.
 */
public static void rotateIcon() {
  ApplicationController.instance.rt.setByAngle(360);
  ApplicationController.instance.rt.setCycleCount(
    RotateTransition.INDEFINITE
  );
  ApplicationController.instance.rt.play();
}
 
Example 35
Project: AnchorFX   File: DockCommandsBox.java   Source Code and License 5 votes vote down vote up
void notifyCloseAction() {
    if (isMenuOpen) {
        isMenuOpen = false;

        RotateTransition rotate = new RotateTransition(Duration.seconds(0.2), menuButton.getGraphic());
        rotate.setToAngle(0);
        rotate.play();

        hideAction.run();
    }
}
 
Example 36
Project: AnchorFX   File: DockCommandsBox.java   Source Code and License 5 votes vote down vote up
void notifyOpenAction() {
    RotateTransition rotate = new RotateTransition(Duration.seconds(0.2), menuButton.getGraphic());
    rotate.setToAngle(90);
    rotate.play();

    openAction.run();
}
 
Example 37
Project: analogclock   File: AnalogClockDrawing.java   Source Code and License 5 votes vote down vote up
@Override
public void start(Stage primaryStage) {

    StackPane root = new StackPane();
    Node clockDial = createClockDial();
    Node hourHand = createHourHand();
    Node minuteHand = createMinuteHand();
    Node secondHand = createSecondHand();
    Node centerPoint = createCenter();

    root.getChildren().addAll(
            clockDial, hourHand, minuteHand, secondHand, centerPoint
    );

    LocalTime time = LocalTime.now();
    RotateTransition secondsTransition = createRotateTransition(Duration.seconds(60), secondHand, getSecondsAngle(time));
    secondsTransition.play();
    RotateTransition minuteTransition = createRotateTransition(Duration.minutes(60), minuteHand, getMinuteAgnel(time));
    minuteTransition.play();
    RotateTransition hourTransition = createRotateTransition(Duration.hours(12), hourHand, getHourAngle(time));
    hourTransition.play();

    Scene scene = new Scene(root);

    primaryStage.setTitle("Clock");
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example 38
Project: analogclock   File: AnalogClockDrawing.java   Source Code and License 5 votes vote down vote up
RotateTransition createRotateTransition(Duration duration, Node node, int startAngle) {
    RotateTransition rt = new RotateTransition(duration, node);
    rt.setFromAngle(startAngle);
    rt.setByAngle(360);
    rt.setCycleCount(Animation.INDEFINITE);
    rt.setInterpolator(Interpolator.LINEAR);
    return rt;
}
 
Example 39
Project: analogclock   File: AnalogClockImaging.java   Source Code and License 5 votes vote down vote up
/**
 * 360度回転を繰り返すアニメーションの設定。
 *
 * @param duration 1回転するのに要する時間
 * @param node 回転するノード
 * @param startAngle 回転開始角度
 * @return 指定下パラメータで初期化したRotateTransitionインスタンス
 */
private RotateTransition createRotateTransition(Duration duration, Node node, double startAngle) {
    RotateTransition rt = new RotateTransition(duration, node);
    rt.setFromAngle(startAngle);
    rt.setByAngle(360);
    rt.setCycleCount(Animation.INDEFINITE);
    rt.setInterpolator(Interpolator.LINEAR);
    return rt;
}
 
Example 40
Project: Enzo   File: MenuButton.java   Source Code and License 5 votes vote down vote up
private void initGraphics() {
    setPickOnBounds(false);

    cross = new Region();
    cross.getStyleClass().add("cross");
    cross.setMouseTransparent(true);
    crossRotate = new RotateTransition(Duration.millis(200), cross);
    crossRotate.setInterpolator(Interpolator.EASE_BOTH);

    // Add all nodes
    getChildren().addAll(cross);
}
 
Example 41
Project: sevenwonders   File: Wonders.java   Source Code and License 5 votes vote down vote up
public void discardCard(int cardID) {
    cardImage = new ImageView(ResManager.getImage(cardID + ".jpg"));
    Rectangle rec = new Rectangle(208, 320);
    rec.setArcHeight(30);
    rec.setArcWidth(30);
    cardImage.setClip(rec);
    cardImage.toFront();
    final Wonders self = this;
    getChildren().add(cardImage);
    // cardImage.toBack();
    cardImage.setScaleX(0.2);
    cardImage.setScaleY(0.2);

    RotateTransition rt = new RotateTransition(Duration.seconds(1.0), cardImage);
    rt.setFromAngle(0);
    rt.setToAngle(390);
    // rt.setCycleCount(RotateTransition.INDEFINITE);
    rt.play();
    Timeline tl = new Timeline(new KeyFrame(Duration.ZERO, new KeyValue(cardImage.layoutXProperty(), 250),
            new KeyValue(cardImage.layoutYProperty(), -80), new KeyValue(cardImage.opacityProperty(), 0),
            new KeyValue(cardImage.scaleXProperty(), 0.2), new KeyValue(cardImage.scaleYProperty(), 0.2)),
            new KeyFrame(Duration.seconds(0.5), new KeyValue(cardImage.layoutXProperty(), 250), new KeyValue(
                    cardImage.layoutYProperty(), -180), new KeyValue(cardImage.opacityProperty(), 1), new KeyValue(
                    cardImage.scaleXProperty(), 0.45), new KeyValue(cardImage.scaleYProperty(), 0.45)),
            // new KeyFrame(Duration.seconds(0.5),act),
            new KeyFrame(Duration.seconds(1.0), new KeyValue(cardImage.layoutXProperty(), 250), new KeyValue(
                    cardImage.layoutYProperty(), -80), new KeyValue(cardImage.opacityProperty(), 1), new KeyValue(
                    cardImage.scaleXProperty(), 0.6), new KeyValue(cardImage.scaleYProperty(), 0.6)), new KeyFrame(
            Duration.seconds(3.0), new KeyValue(cardImage.opacityProperty(), 1), new KeyValue(
            cardImage.layoutXProperty(), 290), new KeyValue(cardImage.layoutYProperty(), 0),
            new KeyValue(rt.rateProperty(), 0.2)), new KeyFrame(Duration.seconds(3.3), new KeyValue(
            cardImage.opacityProperty(), 0), new KeyValue(cardImage.layoutXProperty(), 300), new KeyValue(
            cardImage.layoutYProperty(), 80), new KeyValue(cardImage.visibleProperty(), false)));
    tl.play();
}
 
Example 42
Project: jointry   File: RotateStmnt.java   Source Code and License 5 votes vote down vote up
@Override
public Object eval(Environment env) {
    Object c = ((ASTree) condition()).eval(env);
    if (c instanceof Integer) {
        Sprite sprite = env.getSprite();
        SequentialTransition st = env.getSequentialTransition();
        RotateTransition rt = new RotateTransition(Duration.millis(env.getSpeed()), sprite);
        rt.setByAngle((Integer) c);
        rt.setAutoReverse(true);
        st.getChildren().add(rt);
    }

    return c;
}
 
Example 43
Project: lttng-scope   File: Logo.java   Source Code and License 4 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    if (stage == null) {
        return;
    }

    Rectangle clipRect1 = new Rectangle(-130, -130, 115, 115);
    Rectangle clipRect2 = new Rectangle(15, -130, 115, 115);
    Rectangle clipRect3 = new Rectangle(-130, 15, 115, 115);
    Rectangle clipRect4 = new Rectangle(15, 15, 115, 115);
    Group clip = new Group(clipRect1, clipRect2, clipRect3, clipRect4);

    Circle spinnanCircle = new Circle(100);
    spinnanCircle.setFill(null);
    spinnanCircle.setStrokeWidth(30);
    spinnanCircle.setStroke(LTTNG_PURPLE);
    spinnanCircle.setClip(clip);

    Circle magCircle = new Circle(60);
    magCircle.setFill(null);
    magCircle.setStrokeWidth(25);
    magCircle.setStroke(LTTNG_LIGHT_BLUE);

    Rectangle magHandle = new Rectangle(-12.5, 60, 25, 110);
    magHandle.setFill(LTTNG_LIGHT_BLUE);

    Group mag = new Group(magCircle, magHandle);

    Group root = new Group(spinnanCircle, mag);
    root.setRotate(30);
    root.relocate(0, 0);

    Pane pane = new Pane(root);
    pane.setStyle(BACKGROUND_STYLE);

    RotateTransition spinnan = new RotateTransition(Duration.seconds(4), spinnanCircle);
    spinnan.setByAngle(360);
    spinnan.setCycleCount(Animation.INDEFINITE);
    spinnan.setInterpolator(Interpolator.LINEAR);

    Scene scene = new Scene(pane);
    stage.setScene(scene);
    stage.show();

    spinnan.play();
}
 
Example 44
Project: FamilyFeud   File: AnswerTile.java   Source Code and License 4 votes vote down vote up
private void rotate(double angle, Duration time){
    RotateTransition flip = new RotateTransition(time, this);
    flip.setAxis(Rotate.X_AXIS);
    flip.setByAngle(angle);
    flip.play();
}
 
Example 45
Project: LivroJavaComoProgramar10Edicao   File: TransitionAnimationsController.java   Source Code and License 4 votes vote down vote up
@FXML
private void startButtonPressed(ActionEvent event) 
{
   // transition that changes a shape's fill   
   FillTransition fillTransition = 
      new FillTransition(Duration.seconds(1));
   fillTransition.setToValue(Color.CYAN);
   fillTransition.setCycleCount(2);
   
   // each even cycle plays transition in reverse to restore original
   fillTransition.setAutoReverse(true); 

   // transition that changes a shape's stroke over time  
   StrokeTransition strokeTransition = 
      new StrokeTransition(Duration.seconds(1));
   strokeTransition.setToValue(Color.BLUE);
   strokeTransition.setCycleCount(2);
   strokeTransition.setAutoReverse(true);
   
   // parallelizes multiple transitions  
   ParallelTransition parallelTransition = 
      new ParallelTransition(fillTransition, strokeTransition);

   // transition that changes a node's opacity over time
   FadeTransition fadeTransition = 
      new FadeTransition(Duration.seconds(1));
   fadeTransition.setFromValue(1.0); // opaque
   fadeTransition.setToValue(0.0); // transparent
   fadeTransition.setCycleCount(2);
   fadeTransition.setAutoReverse(true);

   // transition that rotates a node 
   RotateTransition rotateTransition = 
      new RotateTransition(Duration.seconds(1));
   rotateTransition.setByAngle(360.0);
   rotateTransition.setCycleCount(2);
   rotateTransition.setInterpolator(Interpolator.EASE_BOTH);
   rotateTransition.setAutoReverse(true);
   
   // transition that moves a node along a Path  
   Path path = new Path(new MoveTo(45, 45), new LineTo(45, 0), 
      new LineTo(90, 0), new LineTo(90, 90), new LineTo(0, 90));
   PathTransition translateTransition = 
      new PathTransition(Duration.seconds(2), path);
   translateTransition.setCycleCount(2);
   translateTransition.setInterpolator(Interpolator.EASE_IN);
   translateTransition.setAutoReverse(true);
   
   // transition that scales a shape to make it larger or smaller
   ScaleTransition scaleTransition =
      new ScaleTransition(Duration.seconds(1));
   scaleTransition.setByX(0.75);
   scaleTransition.setByY(0.75);
   scaleTransition.setCycleCount(2);
   scaleTransition.setInterpolator(Interpolator.EASE_OUT);
   scaleTransition.setAutoReverse(true);

   // transition that applies a sequence of transitions to a node
   SequentialTransition sequentialTransition = 
      new SequentialTransition (rectangle, parallelTransition, 
         fadeTransition, rotateTransition, translateTransition, 
         scaleTransition);
   sequentialTransition.play(); // play the transition
}
 
Example 46
Project: tilesfx   File: StockTileSkin.java   Source Code and License 4 votes vote down vote up
@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();
}
 
Example 47
Project: livro-javafx-pratico   File: AprendendoTransicoes.java   Source Code and License 4 votes vote down vote up
public static Transition fazerTransicao(Transicoes transicao, double duracaoSegundos, Node alvo) {
	Duration duracao = new Duration(duracaoSegundos * 1000);
	Transition t = null;

	switch (transicao) {
	case FADE:
		FadeTransition fadeTransition = new FadeTransition();
		fadeTransition.setFromValue(1);
		fadeTransition.setToValue(0);
		fadeTransition.setDuration(duracao);
		fadeTransition.setNode(alvo);
		t = fadeTransition;
		break;
	case FILL:
		FillTransition fillTransition = new FillTransition();
		fillTransition.setFromValue(Color.RED);
		fillTransition.setToValue(Color.DARKGREEN);
		fillTransition.setDuration(duracao);
		fillTransition.setShape((Shape) alvo);
		t = fillTransition;
		break;
	case ROTATE:
		RotateTransition rotateTransition = new RotateTransition();
		rotateTransition.setByAngle(360);
		rotateTransition.setDuration(duracao);
		rotateTransition.setNode(alvo);
		t = rotateTransition;
		break;
	case SCALE:
		ScaleTransition scaleTransition = new ScaleTransition();
		scaleTransition.setFromX(1);
		scaleTransition.setFromY(1);
		scaleTransition.setToX(4);
		scaleTransition.setToY(4);
		scaleTransition.setDuration(duracao);
		scaleTransition.setNode(alvo);
		t = scaleTransition;
		break;
	case TRANSLATE:
		TranslateTransition translateTransition = new TranslateTransition();
		translateTransition.setToX(600);
		translateTransition.setToY(250);
		translateTransition.setDuration(duracao);
		translateTransition.setNode(alvo);
		t = translateTransition;
		break;
	default:
		break;
	}
	t.setAutoReverse(true);
	t.setCycleCount(2);
	return t;
}
 
Example 48
Project: CircularProgressIndicator   File: CircularProgressIndicator.java   Source Code and License 4 votes vote down vote up
private void initGraphics() {
    double center = PREFERRED_WIDTH * 0.5;
    double radius = PREFERRED_WIDTH * 0.45;
    circle = new Circle();
    circle.setCenterX(center);
    circle.setCenterY(center);
    circle.setRadius(radius);
    circle.getStyleClass().add("indicator");
    circle.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
    circle.setStrokeWidth(PREFERRED_WIDTH * 0.10526316);
    circle.setStrokeDashOffset(dashOffset.get());
    circle.getStrokeDashArray().setAll(dashArray_0.getValue(), 200d);

    arc = new Arc(center, center, radius, radius, 90, -360.0 * getProgress());
    arc.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
    arc.setStrokeWidth(PREFERRED_WIDTH * 0.1);
    arc.getStyleClass().add("indicator");

    indeterminatePane = new StackPane(circle);
    indeterminatePane.setVisible(false);

    progressPane      = new Pane(arc);
    progressPane.setVisible(Double.compare(getProgress(), 0.0) != 0);

    getChildren().setAll(progressPane, indeterminatePane);

    // Setup timeline animation
    KeyValue kvDashOffset_0    = new KeyValue(dashOffset, 0, Interpolator.EASE_BOTH);
    KeyValue kvDashOffset_50   = new KeyValue(dashOffset, -32, Interpolator.EASE_BOTH);
    KeyValue kvDashOffset_100  = new KeyValue(dashOffset, -64, Interpolator.EASE_BOTH);

    KeyValue kvDashArray_0_0   = new KeyValue(dashArray_0, 5, Interpolator.EASE_BOTH);
    KeyValue kvDashArray_0_50  = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH);
    KeyValue kvDashArray_0_100 = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH);

    KeyValue kvRotate_0        = new KeyValue(circle.rotateProperty(), -10, Interpolator.LINEAR);
    KeyValue kvRotate_100      = new KeyValue(circle.rotateProperty(), 370, Interpolator.LINEAR);

    KeyFrame kf0               = new KeyFrame(Duration.ZERO, kvDashOffset_0, kvDashArray_0_0, kvRotate_0);
    KeyFrame kf1               = new KeyFrame(Duration.millis(1000), kvDashOffset_50, kvDashArray_0_50);
    KeyFrame kf2               = new KeyFrame(Duration.millis(1500), kvDashOffset_100, kvDashArray_0_100, kvRotate_100);

    timeline.setCycleCount(Animation.INDEFINITE);
    timeline.getKeyFrames().setAll(kf0, kf1, kf2);

    // Setup additional pane rotation
    indeterminatePaneRotation = new RotateTransition();
    indeterminatePaneRotation.setNode(indeterminatePane);
    indeterminatePaneRotation.setFromAngle(0);
    indeterminatePaneRotation.setToAngle(-360);
    indeterminatePaneRotation.setInterpolator(Interpolator.LINEAR);
    indeterminatePaneRotation.setCycleCount(Timeline.INDEFINITE);
    indeterminatePaneRotation.setDuration(new Duration(4500));
}
 
Example 49
Project: mars-sim   File: CircularProgressIndicator.java   Source Code and License 4 votes vote down vote up
private void initGraphics() {
    double center = PREFERRED_WIDTH * 0.5;
    double radius = PREFERRED_WIDTH * 0.45;
    circle = new Circle();
    circle.setCenterX(center);
    circle.setCenterY(center);
    circle.setRadius(radius);
    circle.getStyleClass().add("indicator");
    circle.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
    circle.setStrokeWidth(PREFERRED_WIDTH * 0.10526316);
    circle.setStrokeDashOffset(dashOffset.get());
    circle.getStrokeDashArray().setAll(dashArray_0.getValue(), 200d);

    arc = new Arc(center, center, radius, radius, 90, -360.0 * getProgress());
    arc.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
    arc.setStrokeWidth(PREFERRED_WIDTH * 0.1);
    arc.getStyleClass().add("indicator");

    indeterminatePane = new StackPane(circle);
    indeterminatePane.setVisible(false);

    progressPane      = new Pane(arc);
    progressPane.setVisible(Double.compare(getProgress(), 0.0) != 0);

    getChildren().setAll(progressPane, indeterminatePane);

    // Setup timeline animation
    KeyValue kvDashOffset_0    = new KeyValue(dashOffset, 0, Interpolator.EASE_BOTH);
    KeyValue kvDashOffset_50   = new KeyValue(dashOffset, -32, Interpolator.EASE_BOTH);
    KeyValue kvDashOffset_100  = new KeyValue(dashOffset, -64, Interpolator.EASE_BOTH);

    KeyValue kvDashArray_0_0   = new KeyValue(dashArray_0, 5, Interpolator.EASE_BOTH);
    KeyValue kvDashArray_0_50  = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH);
    KeyValue kvDashArray_0_100 = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH);

    KeyValue kvRotate_0        = new KeyValue(circle.rotateProperty(), -10, Interpolator.LINEAR);
    KeyValue kvRotate_100      = new KeyValue(circle.rotateProperty(), 370, Interpolator.LINEAR);

    KeyFrame kf0               = new KeyFrame(Duration.ZERO, kvDashOffset_0, kvDashArray_0_0, kvRotate_0);
    KeyFrame kf1               = new KeyFrame(Duration.millis(1000), kvDashOffset_50, kvDashArray_0_50);
    KeyFrame kf2               = new KeyFrame(Duration.millis(1500), kvDashOffset_100, kvDashArray_0_100, kvRotate_100);

    timeline.setCycleCount(Animation.INDEFINITE);
    timeline.getKeyFrames().setAll(kf0, kf1, kf2);

    // Setup additional pane rotation
    indeterminatePaneRotation = new RotateTransition();
    indeterminatePaneRotation.setNode(indeterminatePane);
    indeterminatePaneRotation.setFromAngle(0);
    indeterminatePaneRotation.setToAngle(-360);
    indeterminatePaneRotation.setInterpolator(Interpolator.LINEAR);
    indeterminatePaneRotation.setCycleCount(Timeline.INDEFINITE);
    indeterminatePaneRotation.setDuration(new Duration(4500));
}
 
Example 50
Project: mars-sim   File: Simple3DSphereApp.java   Source Code and License 4 votes vote down vote up
public Parent createContent() throws Exception {

        Image dImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-d.jpg").toExternalForm());
        Image nImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-n.jpg").toExternalForm());
        Image sImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-s.jpg").toExternalForm());
        Image siImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-l.jpg").toExternalForm());

        material = new PhongMaterial();
        material.setDiffuseColor(Color.WHITE);
        material.diffuseMapProperty().bind(
                Bindings.when(diffuseMap).then(dImage).otherwise((Image) null));
        material.setSpecularColor(Color.TRANSPARENT);
        material.specularMapProperty().bind(
                Bindings.when(specularMap).then(sImage).otherwise((Image) null));
        material.bumpMapProperty().bind(
                Bindings.when(bumpMap).then(nImage).otherwise((Image) null));
        material.selfIlluminationMapProperty().bind(
                Bindings.when(selfIlluminationMap).then(siImage).otherwise((Image) null));

        earth = new Sphere(5);
        earth.setMaterial(material);
        earth.setRotationAxis(Rotate.Y_AXIS);


        // Create and position camera
        PerspectiveCamera camera = new PerspectiveCamera(true);
        camera.getTransforms().addAll(
                new Rotate(-20, Rotate.Y_AXIS),
                new Rotate(-20, Rotate.X_AXIS),
                new Translate(0, 0, -20));

        sun = new PointLight(Color.rgb(255, 243, 234));
        sun.translateXProperty().bind(sunDistance.multiply(-0.82));
        sun.translateYProperty().bind(sunDistance.multiply(-0.41));
        sun.translateZProperty().bind(sunDistance.multiply(-0.41));
        sun.lightOnProperty().bind(sunLight);

        AmbientLight ambient = new AmbientLight(Color.rgb(1, 1, 1));

        // Build the Scene Graph
        Group root = new Group();
        root.getChildren().add(camera);
        root.getChildren().add(earth);
        root.getChildren().add(sun);
        root.getChildren().add(ambient);

        RotateTransition rt = new RotateTransition(Duration.seconds(24), earth);
        rt.setByAngle(360);
        rt.setInterpolator(Interpolator.LINEAR);
        rt.setCycleCount(Animation.INDEFINITE);
        rt.play();

        // Use a SubScene
        SubScene subScene = new SubScene(root, 400, 300, true, SceneAntialiasing.BALANCED);
        subScene.setFill(Color.TRANSPARENT);
        subScene.setCamera(camera);

        return new Group(subScene);
    }
 
Example 51
Project: mars-sim   File: CircularProgressIndicator.java   Source Code and License 4 votes vote down vote up
private void initGraphics() {
    double center = PREFERRED_WIDTH * 0.5;
    double radius = PREFERRED_WIDTH * 0.45;
    circle = new Circle();
    circle.setCenterX(center);
    circle.setCenterY(center);
    circle.setRadius(radius);
    circle.getStyleClass().add("indicator");
    circle.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
    circle.setStrokeWidth(PREFERRED_WIDTH * 0.10526316);
    circle.setStrokeDashOffset(dashOffset.get());
    circle.getStrokeDashArray().setAll(dashArray_0.getValue(), 200d);

    arc = new Arc(center, center, radius, radius, 90, -360.0 * getProgress());
    arc.setStrokeLineCap(isRoundLineCap() ? StrokeLineCap.ROUND : StrokeLineCap.SQUARE);
    arc.setStrokeWidth(PREFERRED_WIDTH * 0.1);
    arc.getStyleClass().add("indicator");

    indeterminatePane = new StackPane(circle);
    indeterminatePane.setVisible(false);

    progressPane      = new Pane(arc);
    progressPane.setVisible(Double.compare(getProgress(), 0.0) != 0);

    getChildren().setAll(progressPane, indeterminatePane);

    // Setup timeline animation
    KeyValue kvDashOffset_0    = new KeyValue(dashOffset, 0, Interpolator.EASE_BOTH);
    KeyValue kvDashOffset_50   = new KeyValue(dashOffset, -32, Interpolator.EASE_BOTH);
    KeyValue kvDashOffset_100  = new KeyValue(dashOffset, -64, Interpolator.EASE_BOTH);

    KeyValue kvDashArray_0_0   = new KeyValue(dashArray_0, 5, Interpolator.EASE_BOTH);
    KeyValue kvDashArray_0_50  = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH);
    KeyValue kvDashArray_0_100 = new KeyValue(dashArray_0, 89, Interpolator.EASE_BOTH);

    KeyValue kvRotate_0        = new KeyValue(circle.rotateProperty(), -10, Interpolator.LINEAR);
    KeyValue kvRotate_100      = new KeyValue(circle.rotateProperty(), 370, Interpolator.LINEAR);

    KeyFrame kf0               = new KeyFrame(Duration.ZERO, kvDashOffset_0, kvDashArray_0_0, kvRotate_0);
    KeyFrame kf1               = new KeyFrame(Duration.millis(1000), kvDashOffset_50, kvDashArray_0_50);
    KeyFrame kf2               = new KeyFrame(Duration.millis(1500), kvDashOffset_100, kvDashArray_0_100, kvRotate_100);

    timeline.setCycleCount(Animation.INDEFINITE);
    timeline.getKeyFrames().setAll(kf0, kf1, kf2);

    // Setup additional pane rotation
    indeterminatePaneRotation = new RotateTransition();
    indeterminatePaneRotation.setNode(indeterminatePane);
    indeterminatePaneRotation.setFromAngle(0);
    indeterminatePaneRotation.setToAngle(-360);
    indeterminatePaneRotation.setInterpolator(Interpolator.LINEAR);
    indeterminatePaneRotation.setCycleCount(Timeline.INDEFINITE);
    indeterminatePaneRotation.setDuration(new Duration(4500));
}
 
Example 52
Project: The-Projects   File: Board.java   Source Code and License 4 votes vote down vote up
/**
 * Method to display the movement of some cards from a Deck
 * @param deck the deck from where the cards come
 * @param cards the cards to move
 */
private void moveFromDeck(boolean clickable, StackPane deck, boolean horizontal, Card... cards) {
    double i = (6 - cards.length)/2., j = 1;
    if (cards.length > 6) {
        i = (6 - cards.length/2)/2.;
    }
    PathTransition lastTransition = new PathTransition();
    for (Card card : cards) {
        Path path;
        if (cards.length < 6) {
            path = new Path(new MoveTo(deck.localToParent(deck.getWidth()/2.,deck.getHeight()/2.).getX(), deck.localToParent(deck.getWidth()/2.,deck.getHeight()/2.).getY()), new LineTo(pane.getWidth() * (++i) / 8, pane.getHeight() / 2));
        }else{
            path = new Path(new MoveTo(deck.localToParent(deck.getWidth()/2.,deck.getHeight()/2.).getX(), deck.localToParent(deck.getWidth()/2.,deck.getHeight()/2.).getY()), new LineTo(pane.getWidth() * (++i) / 8, pane.getHeight()* j / 3));
            if (i == (6 - cards.length/2)/2. + 5) {
                ++j;
                i = (6 - cards.length/2)/2.;
            }
        }
        PathTransition pathTransition = new PathTransition(Duration.millis(500),path,card);
        pathTransition.play();
        lastTransition = pathTransition;

        ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(500), card);
        scaleTransition.setToX(decks.get(2).getScaleX());
        scaleTransition.setToY(decks.get(2).getScaleY());
        scaleTransition.play();

        if (horizontal) {
            card.setRotate(-90);
            RotateTransition rotateTransition = new RotateTransition(Duration.millis(500), card);
            rotateTransition.setByAngle(90);
            rotateTransition.play();
        }

        displayedCards.add(card);
    }

    lastTransition.setOnFinished(event -> view.fireCardToCenterFinished());

    putInFront(clickable, displayedCards.toArray(new Card[displayedCards.size()]));
}
 
Example 53
Project: FXImgurUploader   File: RadialMenu.java   Source Code and License 4 votes vote down vote up
public void click(final MenuItem CLICKED_ITEM) {
    List<Transition> transitions = new ArrayList<>(items.size() * 2);
    for (Parent node : items.keySet()) {
        if (items.get(node).equals(CLICKED_ITEM)) {
            // Add enlarge transition to selected item
            ScaleTransition enlargeItem = new ScaleTransition(Duration.millis(300), node);
            enlargeItem.setToX(5.0);
            enlargeItem.setToY(5.0);
            transitions.add(enlargeItem);
        } else {
            // Add shrink transition to all other items
            ScaleTransition shrinkItem = new ScaleTransition(Duration.millis(300), node);
            shrinkItem.setToX(0.0);
            shrinkItem.setToY(0.0);
            transitions.add(shrinkItem);
        }
        // Add fade out transition to every node
        FadeTransition fadeOutItem = new FadeTransition(Duration.millis(300), node);
        fadeOutItem.setToValue(0.0);
        transitions.add(fadeOutItem);
    }

    // Add rotate and fade transition to main menu button
    if (options.isButtonHideOnSelect()) {
        RotateTransition rotateMainButton = new RotateTransition(Duration.millis(300), mainMenuButton);
        rotateMainButton.setToAngle(225);
        transitions.add(rotateMainButton);
        FadeTransition fadeOutMainButton = new FadeTransition(Duration.millis(300), mainMenuButton);
        fadeOutMainButton.setToValue(0.0);
        transitions.add(fadeOutMainButton);
        ScaleTransition shrinkMainButton = new ScaleTransition(Duration.millis(300), mainMenuButton);
        shrinkMainButton.setToX(0.0);
        shrinkMainButton.setToY(0.0);
        transitions.add(shrinkMainButton);
    } else {
        RotateTransition rotateBackMainButton = new RotateTransition();
        rotateBackMainButton.setNode(cross);
        rotateBackMainButton.setToAngle(0);
        rotateBackMainButton.setDuration(Duration.millis(200));
        rotateBackMainButton.setInterpolator(Interpolator.EASE_BOTH);
        transitions.add(rotateBackMainButton);
        FadeTransition mainButtonFadeOut = new FadeTransition();
        mainButtonFadeOut.setNode(mainMenuButton);
        mainButtonFadeOut.setDuration(Duration.millis(100));
        mainButtonFadeOut.setToValue(options.getButtonAlpha());
        transitions.add(mainButtonFadeOut);
    }

    // Play all transitions in parallel
    ParallelTransition selectTransition = new ParallelTransition();
    selectTransition.getChildren().addAll(transitions);
    selectTransition.play();

    // Set menu state back to closed
    setState(State.CLOSED);
    mainMenuButton.setOpen(false);
}
 
Example 54
Project: Enzo   File: RadialMenu.java   Source Code and License 4 votes vote down vote up
public void click(final MenuItem CLICKED_ITEM) {
    List<Transition> transitions = new ArrayList<>(items.size() * 2);
    for (Parent node : items.keySet()) {
        if (items.get(node).equals(CLICKED_ITEM)) {
            // Add enlarge transition to selected item
            ScaleTransition enlargeItem = new ScaleTransition(Duration.millis(300), node);
            enlargeItem.setToX(5.0);
            enlargeItem.setToY(5.0);
            transitions.add(enlargeItem);
        } else {
            // Add shrink transition to all other items
            ScaleTransition shrinkItem = new ScaleTransition(Duration.millis(300), node);
            shrinkItem.setToX(0.0);
            shrinkItem.setToY(0.0);
            transitions.add(shrinkItem);
        }
        // Add fade out transition to every node
        FadeTransition fadeOutItem = new FadeTransition(Duration.millis(300), node);
        fadeOutItem.setToValue(0.0);
        transitions.add(fadeOutItem);
    }

    // Add rotate and fade transition to main menu button
    if (options.isButtonHideOnSelect()) {
        RotateTransition rotateMainButton = new RotateTransition(Duration.millis(300), mainMenuButton);
        rotateMainButton.setToAngle(225);
        transitions.add(rotateMainButton);
        FadeTransition fadeOutMainButton = new FadeTransition(Duration.millis(300), mainMenuButton);
        fadeOutMainButton.setToValue(0.0);
        transitions.add(fadeOutMainButton);
        ScaleTransition shrinkMainButton = new ScaleTransition(Duration.millis(300), mainMenuButton);
        shrinkMainButton.setToX(0.0);
        shrinkMainButton.setToY(0.0);
        transitions.add(shrinkMainButton);
    } else {
        RotateTransition rotateBackMainButton = new RotateTransition();
        rotateBackMainButton.setNode(cross);
        rotateBackMainButton.setToAngle(0);
        rotateBackMainButton.setDuration(Duration.millis(200));
        rotateBackMainButton.setInterpolator(Interpolator.EASE_BOTH);
        transitions.add(rotateBackMainButton);
        FadeTransition mainButtonFadeOut = new FadeTransition();
        mainButtonFadeOut.setNode(mainMenuButton);
        mainButtonFadeOut.setDuration(Duration.millis(100));
        mainButtonFadeOut.setToValue(options.getButtonAlpha());
        transitions.add(mainButtonFadeOut);
    }

    // Play all transitions in parallel
    ParallelTransition selectTransition = new ParallelTransition();
    selectTransition.getChildren().addAll(transitions);
    selectTransition.play();

    // Set menu state back to closed
    setState(State.CLOSED);
    mainMenuButton.setOpen(false);
}
 
Example 55
Project: bco.bcozy   File: AnimationProvider.java   Source Code and License 3 votes vote down vote up
/**
 * Method to create a RotateTransition with several parameters.
 *
 * @param node the node to which the transition should be applied.
 * @param fromAngle the rotation angle where the transition should start.
 * @param toAngle the rotation angle where the transition should end.
 * @param cycleCount the number of times the animation should be played (use Animation.INDEFINITE for endless).
 * @param duration the duration which one animation cycle should take.
 * @param interpolator defines the rotation value interpolation between {@code fromAngle} and {@code toAngle}.
 * @param autoReverse defines if the animation should be reversed at the end.
 * @return an instance of the created FadeTransition.
 */
public static RotateTransition createRotateTransition(final Node node, final double fromAngle, final double toAngle, final int cycleCount, final double duration, final Interpolator interpolator, final boolean autoReverse) {
    assert node != null;
    
    final RotateTransition rotateTransition = new RotateTransition(Duration.millis(duration), node);
    rotateTransition.setFromAngle(fromAngle);
    rotateTransition.setToAngle(toAngle);
    rotateTransition.setCycleCount(cycleCount);
    rotateTransition.setAutoReverse(autoReverse);
    rotateTransition.setInterpolator(interpolator);
    return rotateTransition;
}