use of javafx.scene.Group in project JFoenix by jfoenixadmin.
the class JFXTextAreaOldSkin method createFloatingLabel.
private void createFloatingLabel() {
if (((JFXTextArea) getSkinnable()).isLabelFloat()) {
if (promptText == null) {
// get the prompt text node or create it
boolean triggerFloatLabel = false;
if (((Region) scrollPane.getContent()).getChildrenUnmodifiable().get(0) instanceof Text)
promptText = (Text) ((Region) scrollPane.getContent()).getChildrenUnmodifiable().get(0);
else {
Field field;
try {
field = TextAreaSkin.class.getDeclaredField("promptNode");
field.setAccessible(true);
createPromptNode();
field.set(this, promptText);
// position the prompt node in its position
triggerFloatLabel = true;
oldPromptTextFill = promptTextFill.get();
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
promptTextGroup = new Group(promptText);
promptContainer.getChildren().add(promptTextGroup);
StackPane.setAlignment(promptTextGroup, Pos.TOP_LEFT);
// MUST KEEP: having transparent border fix the blurring effect on focus
promptContainer.setStyle("-fx-border-color:TRANSPARENT");
if (triggerFloatLabel) {
promptContainer.setTranslateY(-promptText.getLayoutBounds().getHeight() - 5);
promptText.setScaleX(0.85);
promptText.setScaleY(0.85);
}
}
// create prompt animations
promptTextUpTransition = new CachedTransition(promptContainer, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptContainer.translateYProperty(), -promptText.getLayoutBounds().getHeight() - 5, Interpolator.EASE_BOTH), // new KeyValue(promptText.translateXProperty(), - promptText.getLayoutBounds().getWidth()*0.15/2, Interpolator.EASE_BOTH),
new KeyValue(promptText.scaleXProperty(), 0.85, Interpolator.EASE_BOTH), new KeyValue(promptText.scaleYProperty(), 0.85, Interpolator.EASE_BOTH)))) {
{
setDelay(Duration.millis(0));
setCycleDuration(Duration.millis(300));
}
};
promptTextColorTransition = new CachedTransition(promptContainer, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptTextFill, focusedLine.getStroke(), Interpolator.EASE_BOTH)))) {
{
setDelay(Duration.millis(0));
setCycleDuration(Duration.millis(300));
}
protected void starting() {
super.starting();
oldPromptTextFill = promptTextFill.get();
}
;
};
promptTextDownTransition = new CachedTransition(promptContainer, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptContainer.translateYProperty(), 0, Interpolator.EASE_BOTH), // new KeyValue(promptText.translateXProperty(), 0, Interpolator.EASE_BOTH),
new KeyValue(promptText.scaleXProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(promptText.scaleYProperty(), 1, Interpolator.EASE_BOTH)))) {
{
setDelay(Duration.millis(0));
setCycleDuration(Duration.millis(300));
}
};
promptTextDownTransition.setOnFinished((finish) -> {
promptContainer.setTranslateY(0);
promptText.setScaleX(1);
promptText.setScaleY(1);
});
promptText.visibleProperty().unbind();
promptText.visibleProperty().set(true);
}
}
use of javafx.scene.Group 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.Group in project OTP2_R6_svaap by JNuutinen.
the class GameMain method pause.
@Override
public void pause() {
PauseMenu pauseMenu = new PauseMenu();
Group pauseMenuGroup = pauseMenu.getGroup();
pauseMenu.continueButton.setOnAction(event -> {
gameRoot.setCenter(null);
controller.continueGame();
});
pauseMenu.quitButton.setOnAction(event -> {
pauseMenu.quitButton.setDisable(true);
controller.returnToMain();
});
gameRoot.setCenter(pauseMenuGroup);
}
use of javafx.scene.Group in project chuidiang-ejemplos by chuidiang.
the class JavaFX3DExample method initFx.
public static void initFx(JFXPanel fxPanel) {
sphere = new Sphere(100);
sphere.setLayoutX(200);
sphere.setLayoutY(200);
Group root = new Group(sphere);
Scene scene = new Scene(root, 900, 600);
fxPanel.setScene(scene);
fxPanel.setSize(900, 600);
}
use of javafx.scene.Group in project Gargoyle by callakrsos.
the class SVNViewer method setDataNode.
private void setDataNode(SVNLogEntry entry, Data<String, String> data) {
Group group = new Group();
group.setManaged(false);
Text value = new Text(entry.getRevision() + "");
value.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
value.translateYProperty().set(-15);
Circle circle = new Circle(4, Color.WHITE);
circle.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
circle.setStroke(Color.web("#f3622d"));
StackPane stackPane = new StackPane(value, circle);
stackPane.setPrefSize(30, 60);
group.getChildren().add(stackPane);
data.setNode(group);
}
Aggregations