Example usage for javafx.scene.shape Rectangle setFill

List of usage examples for javafx.scene.shape Rectangle setFill

Introduction

In this page you can find the example usage for javafx.scene.shape Rectangle setFill.

Prototype

public final void setFill(Paint value) 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    int w = 220;//from w w  w  . j a  v a2 s  .c om
    int h = 100;
    FloatMap map = new FloatMap();
    map.setWidth(w);
    map.setHeight(h);

    for (int i = 0; i < w; i++) {
        double v = (Math.sin(i / 20.0 * Math.PI) - 0.5) / 40.0;
        for (int j = 0; j < h; j++) {
            map.setSamples(i, j, 0.0f, (float) v);
        }
    }

    Group g = new Group();
    DisplacementMap dm = new DisplacementMap();
    dm.setMapData(map);

    g.setEffect(dm);
    g.setCache(true);

    Rectangle r = new Rectangle();
    r.setX(20.0);
    r.setY(20.0);
    r.setWidth(w);
    r.setHeight(h);
    r.setFill(Color.BLUE);

    g.getChildren().add(r);

    Text t = new Text();
    t.setX(40.0);
    t.setY(80.0);
    t.setText("Wavy Text");
    t.setFill(Color.YELLOW);
    t.setFont(Font.font(null, FontWeight.BOLD, 36));

    g.getChildren().add(t);

    root.getChildren().add(g);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 500, 260);

    Rectangle roundRect = new Rectangle(50, 50, 400, 130);

    roundRect.setArcWidth(30);//from www . j a  v a2 s.  c om
    roundRect.setArcHeight(60);

    roundRect.setFill(null);
    roundRect.setStroke(Color.DARKORANGE);
    roundRect.setStrokeWidth(2);
    roundRect.setStrokeLineCap(StrokeLineCap.BUTT);

    root.getChildren().add(roundRect);

    Slider slider = new Slider(30, 150, 30);
    slider.setLayoutX(250 - slider.getWidth() / 2);
    slider.setLayoutY(115 - slider.getHeight() / 2);

    slider.widthProperty().addListener((ov, curVal, newVal) -> {
        slider.setLayoutX(250 - slider.getWidth() / 2);
    });

    slider.heightProperty()
            .addListener((ov, curVal, newVal) -> slider.setLayoutY(115 - slider.getHeight() / 2));

    roundRect.arcWidthProperty().bind(slider.valueProperty());

    root.getChildren().add(slider);

    Slider slider2 = new Slider(10, 120, 50);
    slider2.setLayoutX(50);
    slider2.setLayoutY(230);

    slider2.widthProperty().addListener((ov, curVal, newVal) -> {
        slider2.setLayoutX(250 - slider2.getWidth() / 2);
    });

    roundRect.yProperty().bind(slider2.valueProperty());
    root.getChildren().add(slider2);

    slider2.valueProperty().addListener((ov, curVal, newVal) -> slider
            .setLayoutY(slider.getLayoutY() + newVal.doubleValue() - curVal.doubleValue()));
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

private void addStackPane(HBox hb) {

    StackPane stack = new StackPane();
    Rectangle helpIcon = new Rectangle(30.0, 25.0);
    helpIcon.setFill(new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE,
            new Stop[] { new Stop(0, Color.web("#4977A3")), new Stop(0.5, Color.web("#B0C6DA")),
                    new Stop(1, Color.web("#9CB6CF")), }));
    helpIcon.setStroke(Color.web("#D0E6FA"));
    helpIcon.setArcHeight(3.5);//w  w w  .  j  a  va  2 s . co  m
    helpIcon.setArcWidth(3.5);

    Text helpText = new Text("?");
    helpText.setFont(Font.font("Verdana", FontWeight.BOLD, 18));
    helpText.setFill(Color.WHITE);
    helpText.setStroke(Color.web("#7080A0"));

    stack.getChildren().addAll(helpIcon, helpText);
    stack.setAlignment(Pos.CENTER_RIGHT);
    // Add offset to right for question mark to compensate for RIGHT 
    // alignment of all nodes
    StackPane.setMargin(helpText, new Insets(0, 10, 0, 0));

    hb.getChildren().add(stack);
    HBox.setHgrow(stack, Priority.ALWAYS);

}

From source file:User.java

private Rectangle drawRectangleBackground() {
    Rectangle background = new Rectangle(320, 112);
    background.setX(0);//from   w ww  .j  ava 2s .  co m
    background.setY(0);
    background.setArcHeight(15);
    background.setArcWidth(15);
    background.setFill(Color.rgb(0, 0, 0, 0.55));
    background.setStrokeWidth(1.5);
    background.setStroke(foregroundColor);

    return background;
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Colors");
    Group root = new Group();
    Scene scene = new Scene(root, 350, 300, Color.WHITE);
    Rectangle rectangle = RectangleBuilder.create().x(50).y(50).width(100).height(70).translateY(10).build();

    LinearGradient linearGrad = LinearGradientBuilder.create().startX(50).startY(50).endX(50)
            .endY(50 + rectangle.prefHeight(-1) + 25).proportional(false).cycleMethod(CycleMethod.NO_CYCLE)
            .stops(new Stop(0.1f, Color.rgb(255, 200, 0, .784)), new Stop(1.0f, Color.rgb(0, 0, 0, .784)))
            .build();//from w  ww  . ja  v  a 2  s.co m

    rectangle.setFill(linearGrad);
    root.getChildren().add(rectangle);

    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox box = new VBox();
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);/* w ww  . ja v a2 s .com*/
    // A rectangle filled with a linear gradient with a translucent color.
    Rectangle rectangle = new Rectangle();
    rectangle.setX(50);
    rectangle.setY(50);
    rectangle.setWidth(100);
    rectangle.setHeight(70);

    LinearGradient cycleGrad = new LinearGradient(50, // start X
            50, // start Y
            70, // end X
            70, // end Y
            false, // proportional
            CycleMethod.REFLECT, // cycleMethod
            new Stop(0f, Color.rgb(21, 25, 0, .784)), new Stop(1.0f, Color.rgb(0, 210, 0, .784)));
    rectangle.setFill(cycleGrad);

    box.getChildren().add(rectangle);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    VBox box = new VBox();
    final Scene scene = new Scene(box, 300, 250);
    scene.setFill(null);/* ww w  . j  a va  2s . c o m*/
    // A rectangle filled with a linear gradient with a translucent color.
    Rectangle rectangle = new Rectangle();
    rectangle.setX(50);
    rectangle.setY(50);
    rectangle.setWidth(100);
    rectangle.setHeight(70);

    LinearGradient linearGrad = new LinearGradient(0, // start X 
            0, // start Y
            0, // end X
            1, // end Y
            true, // proportional
            CycleMethod.NO_CYCLE, // cycle colors
            // stops
            new Stop(0.1f, Color.rgb(25, 200, 0, .4)), new Stop(1.0f, Color.rgb(0, 0, 0, .1)));
    rectangle.setFill(linearGrad);

    box.getChildren().add(rectangle);

    stage.setScene(scene);
    stage.show();
}

From source file:deincraftlauncher.InstallController.java

@Override
public void initialize(URL url, ResourceBundle rb) {
    instance = this;

    System.out.println("Starting Installer UI...");

    int saveX = 393;
    int cancelY = 165;
    int saveY = 200;
    int sizeX = 481;

    Rectangle separator = new Rectangle();
    separator.setWidth(sizeX);/*  w  w  w  .j a  va 2  s .  c o m*/
    separator.setHeight(separatorSizeY);
    separator.setLayoutY(separatorY);
    separator.setFill(blueColor);
    mainPanel.getChildren().add(separator);
    mainPanel.setBackground(Background.EMPTY);

    TextButton cancel = new TextButton(saveX, cancelY, "cancel", Color.RED, mainPanel);
    cancel.setOnClick((TextButton tile) -> {
        cancel();
    });

    save = new TextButton(saveX, saveY, "Weiter", Color.GRAY, mainPanel);
    save.setFocusable(false);
    save.setOnClick((TextButton tile) -> {
        Continue();
    });

    login = new TextButton(14, 151, "Login", Color.BLUE, mainPanel);
    login.setOnClick((TextButton tile) -> {
        doLogin(null);
    });

    Label Title = new Label();
    Title.setText("Installer");
    Title.setPrefSize(sizeX, separatorY);
    Title.setTextFill(Color.WHITESMOKE);
    Title.setTextAlignment(TextAlignment.CENTER);
    Title.setFont(DesignHelpers.getFocusFont(42));
    Title.setAlignment(Pos.CENTER);
    mainPanel.getChildren().add(Title);

    pathLabel.setBackground(new Background(new BackgroundFill(Color.rgb(170, 170, 170), radii, insets)));
    //ContinueButton.setBackground(new Background(new BackgroundFill(Color.rgb(100, 190, 100), radii, insets))); //Green Version

    setDefaultPath();
    System.out.println("starting done");
}

From source file:Main.java

private TitledPane getShowBoundsControls() {
    ChangeListener<Boolean> cl = new ChangeListener<Boolean>() {
        @Override/*  w  w  w  .  j  av a  2s .com*/
        public void changed(ObservableValue<? extends Boolean> observableValue, Boolean oldValue,
                Boolean newValue) {
            relayout();
        }
    };

    ChangeListener<Boolean> cl2 = new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observableValue, Boolean oldValue,
                Boolean newValue) {
            animate();
        }
    };

    layoutCbx.selectedProperty().addListener(cl);
    localCbx.selectedProperty().addListener(cl);
    parentCbx.selectedProperty().addListener(cl);
    effectGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) {
            relayout();
        }
    });

    layoutAnimateCbx.selectedProperty().addListener(cl2);
    localAnimateCbx.selectedProperty().addListener(cl2);
    parentAnimateCbx.selectedProperty().addListener(cl2);

    double w = 20.0;
    double h = 10.0;

    Rectangle rLayout = new Rectangle(w, h);
    rLayout.setFill(LAYOUT_BOUNDS_RECT_FILL_COLOR);
    rLayout.setStrokeWidth(BOUNDS_STROKE_WIDTH);
    rLayout.setStroke(LAYOUT_BOUNDS_RECT_STROKE_COLOR);

    Rectangle rLocal = new Rectangle(w, h);
    rLocal.setFill(LOCAL_BOUNDS_RECT_FILL_COLOR);
    rLocal.setStrokeWidth(BOUNDS_STROKE_WIDTH);
    rLocal.setStroke(LOCAL_BOUNDS_RECT_STROKE_COLOR);

    Rectangle rParent = new Rectangle(w, h);
    rParent.setFill(PARENT_BOUNDS_RECT_FILL_COLOR);
    rParent.setStrokeWidth(BOUNDS_STROKE_WIDTH);
    rParent.setStroke(PARENT_BOUNDS_RECT_STROKE_COLOR);

    GridPane gp = new GridPane();
    gp.addRow(1, rLayout, new Text("Layout Bounds:"), layoutCbx, layoutAnimateCbx);
    gp.addRow(2, rLocal, new Text("Local Bounds:"), localCbx, localAnimateCbx);
    gp.addRow(3, rParent, new Text("Parent Bounds:"), parentCbx, parentAnimateCbx);

    TitledPane titledPane = new TitledPane("Show Bounds", gp);

    return titledPane;
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param iLargeur//w w  w  . j av  a2s.  com
 * @param iHauteur
 * @param bMasqueZones
 */
private static void afficheBarrePersonnalisee(int iLargeur, int iHauteur, boolean bMasqueZones) {
    apImgBarrePersonnalisee.getChildren().clear();
    apZoneBarrePersonnalisee.getChildren().clear();
    ImageView ivBarrePersonnalisee = new ImageView(imgBarrePersonnalisee);
    apImgBarrePersonnalisee.getChildren().add(ivBarrePersonnalisee);
    apImgBarrePersonnalisee.setPrefWidth(imgBarrePersonnalisee.getWidth());
    apImgBarrePersonnalisee.setPrefHeight(imgBarrePersonnalisee.getHeight());
    apImgBarrePersonnalisee.setCursor(Cursor.CROSSHAIR);
    apImgBarrePersonnalisee.setLayoutX((iLargeur - 300 - apImgBarrePersonnalisee.getPrefWidth()) / 2.d);
    apImgBarrePersonnalisee.setLayoutY((iHauteur - apImgBarrePersonnalisee.getPrefHeight()) / 2.d);
    if ((iNombreZones > 0) && !bMasqueZones) {
        for (int i = 0; i < iNombreZones; i++) {
            ZoneTelecommande zone = zones[i];
            String[] strPoints = zone.getStrCoordonneesZone().split(",");
            double[] points = new double[strPoints.length];
            for (int ij = 0; ij < strPoints.length; ij++) {
                points[ij] = Double.parseDouble(strPoints[ij]);
            }
            final String strIdZone = zone.getStrTypeZone() + "-" + i;

            switch (zone.getStrTypeZone()) {
            case "circle":
                Circle cercle = new Circle(points[0], points[1], points[2]);
                cercle.setFill(Color.rgb(255, 255, 0, 0.5));
                cercle.setStroke(Color.FORESTGREEN);
                cercle.setCursor(Cursor.DEFAULT);
                apImgBarrePersonnalisee.getChildren().add(cercle);
                cercle.setId(strIdZone);
                cercle.setOnMouseClicked((t) -> {
                    choixZone(iLargeur, iHauteur, bMasqueZones, strIdZone, t);
                    t.consume();
                });
                break;
            case "rect":
                double largRect = points[2] - points[0];
                double hautRect = points[3] - points[1];
                Rectangle rect = new Rectangle(points[0], points[1], largRect, hautRect);
                rect.setFill(Color.rgb(255, 255, 0, 0.5));
                rect.setStroke(Color.FORESTGREEN);
                rect.setCursor(Cursor.DEFAULT);
                apImgBarrePersonnalisee.getChildren().add(rect);
                rect.setId(strIdZone);
                rect.setOnMouseClicked((t) -> {
                    choixZone(iLargeur, iHauteur, bMasqueZones, strIdZone, t);
                    t.consume();
                });
                break;
            case "poly":
                Polygon poly = new Polygon(points);
                poly.setFill(Color.rgb(255, 255, 0, 0.5));
                poly.setStroke(Color.FORESTGREEN);
                poly.setStrokeWidth(3);
                poly.setCursor(Cursor.DEFAULT);
                poly.setStrokeLineCap(StrokeLineCap.ROUND);
                poly.setId(strIdZone);
                apImgBarrePersonnalisee.getChildren().add(poly);
                poly.setOnMouseClicked((t) -> {
                    choixZone(iLargeur, iHauteur, bMasqueZones, strIdZone, t);
                    t.consume();
                });
                break;
            }
        }
    }
}