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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations