Search in sources :

Example 1 with Rotate

use of javafx.scene.transform.Rotate in project JFoenix by jfoenixadmin.

the class JFXTimePickerContent method createHoursContent.

private StackPane createHoursContent(LocalTime time) {
    // create hours content
    StackPane hoursPointer = new StackPane();
    Circle selectionCircle = new Circle(contentCircleRadius / 6);
    selectionCircle.fillProperty().bind(timePicker.defaultColorProperty());
    double shift = 9;
    Line line = new Line(shift, 0, contentCircleRadius, 0);
    line.fillProperty().bind(timePicker.defaultColorProperty());
    line.strokeProperty().bind(line.fillProperty());
    line.setStrokeWidth(1.5);
    hoursPointer.getChildren().addAll(line, selectionCircle);
    StackPane.setAlignment(selectionCircle, Pos.CENTER_LEFT);
    Group pointerGroup = new Group();
    pointerGroup.getChildren().add(hoursPointer);
    pointerGroup.setTranslateX((-contentCircleRadius + shift) / 2);
    hoursPointerRotate = new Rotate(0, contentCircleRadius - shift, selectionCircle.getRadius());
    pointerRotate.set(hoursPointerRotate);
    pointerGroup.getTransforms().add(hoursPointerRotate);
    Pane clockLabelsContainer = new Pane();
    // inner circle radius
    double radius = contentCircleRadius - shift - selectionCircle.getRadius();
    for (int i = 0; i < 12; i++) {
        // create the label and its container
        int val = (i + 3) % 12 == 0 ? 12 : (i + 3) % 12;
        Label label = new Label(val + "");
        label.setFont(Font.font("Roboto", FontWeight.BOLD, 12));
        // init color 
        if (val == time.getHour() % 12 || (val == 12 && time.getHour() % 12 == 0))
            label.setTextFill(Color.rgb(255, 255, 255, 0.87));
        else
            label.setTextFill(Color.rgb(0, 0, 0, 0.87));
        selectedHourLabel.textProperty().addListener((o, oldVal, newVal) -> {
            if (Integer.parseInt(newVal) == Integer.parseInt(label.getText())) {
                label.setTextFill(Color.rgb(255, 255, 255, 0.87));
            } else {
                label.setTextFill(Color.rgb(0, 0, 0, 0.87));
            }
        });
        // create label container 
        StackPane labelContainer = new StackPane();
        labelContainer.getChildren().add(label);
        double labelSize = (selectionCircle.getRadius() / Math.sqrt(2)) * 2;
        labelContainer.setMinSize(labelSize, labelSize);
        // position the label on the circle
        double angle = 2 * i * Math.PI / 12;
        double xOffset = radius * Math.cos(angle);
        double yOffset = radius * Math.sin(angle);
        final double startx = contentCircleRadius + xOffset;
        final double starty = contentCircleRadius + yOffset;
        labelContainer.setLayoutX(startx - labelContainer.getMinWidth() / 2);
        labelContainer.setLayoutY(starty - labelContainer.getMinHeight() / 2);
        // add label to the parent node
        clockLabelsContainer.getChildren().add(labelContainer);
        // init pointer angle
        if (val == time.getHour() % 12 || (val == 12 && time.getHour() % 12 == 0))
            hoursPointerRotate.setAngle(180 + Math.toDegrees(angle));
    }
    return new StackPane(pointerGroup, clockLabelsContainer);
}
Also used : Line(javafx.scene.shape.Line) Circle(javafx.scene.shape.Circle) Group(javafx.scene.Group) Rotate(javafx.scene.transform.Rotate) Label(javafx.scene.control.Label) Paint(javafx.scene.paint.Paint)

Example 2 with Rotate

use of javafx.scene.transform.Rotate in project fxexperience2 by EricCanull.

the class RotateOutUpRightTransition method starting.

@Override
protected void starting() {
    super.starting();
    rotate = new Rotate(0, node.getBoundsInLocal().getWidth(), node.getBoundsInLocal().getHeight());
    timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(rotate.angleProperty(), 0, WEB_EASE)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(rotate.angleProperty(), 90, WEB_EASE)));
    node.getTransforms().add(rotate);
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) Rotate(javafx.scene.transform.Rotate) KeyFrame(javafx.animation.KeyFrame)

Example 3 with Rotate

use of javafx.scene.transform.Rotate in project fxexperience2 by EricCanull.

the class HingeTransition method starting.

@Override
protected void starting() {
    super.starting();
    double endY = node.getScene().getHeight() - node.localToScene(0, 0).getY();
    rotate = new Rotate(0, 0, 0);
    timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(rotate.angleProperty(), 0, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(200), new KeyValue(rotate.angleProperty(), 80, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(400), new KeyValue(rotate.angleProperty(), 60, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(600), new KeyValue(rotate.angleProperty(), 80, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(800), new KeyValue(node.opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(node.translateYProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(rotate.angleProperty(), 60, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(node.translateYProperty(), endY, Interpolator.EASE_BOTH), new KeyValue(rotate.angleProperty(), 60, Interpolator.EASE_BOTH)));
    node.getTransforms().add(rotate);
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) Rotate(javafx.scene.transform.Rotate) KeyFrame(javafx.animation.KeyFrame)

Example 4 with Rotate

use of javafx.scene.transform.Rotate in project fxexperience2 by EricCanull.

the class RotateInDownLeftTransition method starting.

@Override
protected void starting() {
    super.starting();
    rotate = new Rotate(0, 0, node.getBoundsInLocal().getHeight());
    timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(rotate.angleProperty(), -90, WEB_EASE)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(rotate.angleProperty(), 0, WEB_EASE)));
    node.getTransforms().add(rotate);
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) Rotate(javafx.scene.transform.Rotate) KeyFrame(javafx.animation.KeyFrame)

Example 5 with Rotate

use of javafx.scene.transform.Rotate in project fxexperience2 by EricCanull.

the class RotateInUpRightTransition method starting.

@Override
protected void starting() {
    super.starting();
    rotate = new Rotate(0, node.getBoundsInLocal().getWidth(), node.getBoundsInLocal().getHeight());
    timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(rotate.angleProperty(), -90, WEB_EASE)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(rotate.angleProperty(), 0, WEB_EASE)));
    node.getTransforms().add(rotate);
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) Rotate(javafx.scene.transform.Rotate) KeyFrame(javafx.animation.KeyFrame)

Aggregations

Rotate (javafx.scene.transform.Rotate)96 Group (javafx.scene.Group)39 KeyFrame (javafx.animation.KeyFrame)27 KeyValue (javafx.animation.KeyValue)27 Scene (javafx.scene.Scene)27 Translate (javafx.scene.transform.Translate)27 PerspectiveCamera (javafx.scene.PerspectiveCamera)25 KeyCode (javafx.scene.input.KeyCode)23 MouseEvent (javafx.scene.input.MouseEvent)20 PointLight (javafx.scene.PointLight)18 Color (javafx.scene.paint.Color)18 Timeline (javafx.animation.Timeline)16 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)15 Pane (javafx.scene.layout.Pane)13 Text (javafx.scene.text.Text)13 AnimationTimer (javafx.animation.AnimationTimer)11 Canvas (javafx.scene.canvas.Canvas)11 Point3D (org.fxyz.geometry.Point3D)11 Random (java.util.Random)10 InnerShadow (javafx.scene.effect.InnerShadow)9