Search in sources :

Example 16 with Group

use of javafx.scene.Group in project org.csstudio.display.builder by kasemir.

the class PointsEditorDemo method start.

@Override
public void start(final Stage stage) throws Exception {
    poly.setStroke(Color.BLUE);
    poly.setStrokeWidth(4);
    poly.setStrokeLineCap(StrokeLineCap.ROUND);
    poly.setStrokeLineJoin(StrokeLineJoin.ROUND);
    poly.setFill(Color.CORNSILK);
    final Group root = new Group();
    root.getChildren().add(poly);
    final Scene scene = new Scene(root, 400, 400);
    stage.setScene(scene);
    stage.show();
    EditorUtil.setSceneStyle(scene);
    editor = new PointsEditor(root, points, new PointsEditorListener() {

        @Override
        public void pointsChanged(final Points points) {
            updatePoly();
        }

        @Override
        public void done() {
            editor.dispose();
        }
    });
    updatePoly();
}
Also used : Group(javafx.scene.Group) Points(org.csstudio.display.builder.model.properties.Points) Scene(javafx.scene.Scene)

Example 17 with Group

use of javafx.scene.Group in project org.csstudio.display.builder by kasemir.

the class GroupVsPaneDemo method start.

@Override
public void start(Stage primaryStage) {
    Pane pane = new Pane();
    Group group = new Group();
    VBox.setVgrow(group, Priority.NEVER);
    VBox.setVgrow(pane, Priority.NEVER);
    VBox vbox = new VBox(group, pane);
    Rectangle rect1 = new Rectangle(100, 100, 100, 100);
    Rectangle rect2 = new Rectangle(100, 100, 100, 100);
    Rectangle rect3 = new Rectangle(200, 200, 100, 100);
    Rectangle rect4 = new Rectangle(200, 200, 100, 100);
    rect1.setFill(Color.BLUE);
    rect2.setFill(Color.BLUE);
    rect3.setFill(Color.GREEN);
    rect4.setFill(Color.GREEN);
    group.getChildren().addAll(rect1, rect3);
    pane.getChildren().addAll(rect2, rect4);
    Scene scene = new Scene(vbox, 800, 800);
    scene.addEventHandler(KeyEvent.KEY_PRESSED, e -> {
        double deltaX;
        switch(e.getCode()) {
            case LEFT:
                deltaX = -10;
                break;
            case RIGHT:
                deltaX = 10;
                break;
            default:
                deltaX = 0;
        }
        rect3.setX(rect3.getX() + deltaX);
        rect4.setX(rect4.getX() + deltaX);
    });
    primaryStage.setScene(scene);
    primaryStage.show();
}
Also used : Group(javafx.scene.Group) Rectangle(javafx.scene.shape.Rectangle) Scene(javafx.scene.Scene) Pane(javafx.scene.layout.Pane) VBox(javafx.scene.layout.VBox)

Example 18 with Group

use of javafx.scene.Group in project FinalCrypt by ron-from-nl.

the class GUIFX method introAlert.

public Alert introAlert(AlertType type, String title, String headerText, String message, String optOutMessage, Consumer<Boolean> optOutAction, ButtonType... buttonTypes) {
    Alert alert = new Alert(type);
    alert.getDialogPane().applyCss();
    Node graphic = alert.getDialogPane().getGraphic();
    DialogPane dialogPane = new DialogPane() {

        @Override
        protected Node createDetailsButton() {
            CheckBox checkbox = new CheckBox();
            checkbox.setText(optOutMessage);
            checkbox.setOnAction(e -> optOutAction.accept(checkbox.isSelected()));
            return checkbox;
        }
    };
    dialogPane.getStylesheets().add(getClass().getResource("myInfoAlerts.css").toExternalForm());
    dialogPane.getStyleClass().add("myDialog");
    alert.setDialogPane(dialogPane);
    alert.getDialogPane().getButtonTypes().addAll(buttonTypes);
    alert.getDialogPane().setContentText(message);
    alert.getDialogPane().setExpandableContent(new Group());
    alert.getDialogPane().setExpanded(true);
    alert.getDialogPane().setGraphic(graphic);
    alert.setTitle(title);
    alert.setHeaderText(headerText);
    return alert;
}
Also used : DialogPane(javafx.scene.control.DialogPane) Group(javafx.scene.Group) CheckBox(javafx.scene.control.CheckBox) Node(javafx.scene.Node) SwingNode(javafx.embed.swing.SwingNode) Alert(javafx.scene.control.Alert)

Example 19 with Group

use of javafx.scene.Group in project contentment by GeePawHill.

the class JfxUtilityTest method before.

@Before
public void before() {
    calls = new ArrayList<>();
    root = new Group();
    parentWithChildren = new Group();
    parentWithoutChildren = new Group();
    leafOffRoot = new Text();
    root.getChildren().addAll(parentWithChildren, parentWithoutChildren, leafOffRoot);
    leaf2 = new Text();
    leaf3 = new Text();
    parentWithChildren.getChildren().addAll(leaf2, leaf3);
}
Also used : Group(javafx.scene.Group) Text(javafx.scene.text.Text) Before(org.junit.Before)

Example 20 with Group

use of javafx.scene.Group in project contentment by GeePawHill.

the class AnimationTimerExperiment method start.

@Override
public void start(final Stage primaryStage) {
    for (int i = 0; i < STAR_COUNT; i++) {
        nodes[i] = new Rectangle(1, 1, Color.WHITE);
        angles[i] = 2.0 * Math.PI * random.nextDouble();
        start[i] = random.nextInt(2000000000);
    }
    final Scene scene = new Scene(new Group(nodes), 800, 600, Color.BLACK);
    primaryStage.setScene(scene);
    primaryStage.show();
    new AnimationTimer() {

        @Override
        public void handle(long now) {
            final double width = 0.5 * primaryStage.getWidth();
            final double height = 0.5 * primaryStage.getHeight();
            final double radius = Math.sqrt(2) * Math.max(width, height);
            for (int i = 0; i < STAR_COUNT; i++) {
                final Node node = nodes[i];
                final double angle = angles[i];
                final long t = (now - start[i]) % 2000000000;
                final double d = t * radius / 2000000000.0;
                node.setTranslateX(Math.cos(angle) * d + width);
                node.setTranslateY(Math.sin(angle) * d + height);
            }
        }
    }.start();
}
Also used : Group(javafx.scene.Group) AnimationTimer(javafx.animation.AnimationTimer) Node(javafx.scene.Node) Rectangle(javafx.scene.shape.Rectangle) Scene(javafx.scene.Scene)

Aggregations

Group (javafx.scene.Group)121 Scene (javafx.scene.Scene)64 Rotate (javafx.scene.transform.Rotate)41 KeyCode (javafx.scene.input.KeyCode)32 PerspectiveCamera (javafx.scene.PerspectiveCamera)31 MouseEvent (javafx.scene.input.MouseEvent)28 Text (javafx.scene.text.Text)25 PointLight (javafx.scene.PointLight)24 Color (javafx.scene.paint.Color)24 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16 Pane (javafx.scene.layout.Pane)16 AnimationTimer (javafx.animation.AnimationTimer)15 ArrayList (java.util.ArrayList)14 Node (javafx.scene.Node)14 Label (javafx.scene.control.Label)14 Rectangle (javafx.scene.shape.Rectangle)13 Translate (javafx.scene.transform.Translate)13 Canvas (javafx.scene.canvas.Canvas)11 Stage (javafx.stage.Stage)11 Point3D (org.fxyz.geometry.Point3D)11