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

static Node distantLight() {
    Light.Distant light = new Light.Distant();
    light.setAzimuth(-135.0f);// w ww. j a  v a2  s  .c  o  m
    light.setElevation(30.0f);

    Lighting l = new Lighting();
    l.setLight(light);
    l.setSurfaceScale(5.0f);

    final Text t = new Text();
    t.setText("Distant Light");
    t.setFill(Color.RED);
    t.setFont(Font.font("null", FontWeight.BOLD, 70));
    t.setX(10.0f);
    t.setY(50.0f);
    t.setTextOrigin(VPos.TOP);

    t.setEffect(l);

    final Rectangle r = new Rectangle();
    r.setFill(Color.BLACK);

    Group g = new Group();
    g.getChildren().add(r);
    g.getChildren().add(t);

    g.setTranslateY(460);

    return g;
}

From source file:Main.java

static Node blendMode() {
    Rectangle r = new Rectangle();
    r.setX(590);//from www  .  j a va  2s. com
    r.setY(50);
    r.setWidth(50);
    r.setHeight(50);
    r.setFill(Color.BLUE);

    Circle c = new Circle();
    c.setFill(Color.rgb(255, 0, 0, 0.5f));
    c.setCenterX(590);
    c.setCenterY(50);
    c.setRadius(25);

    Group g = new Group();
    g.setBlendMode(BlendMode.MULTIPLY);
    g.getChildren().add(r);
    g.getChildren().add(c);
    return g;
}

From source file:Main.java

static Node bloom() {
    Group g = new Group();

    Rectangle r = new Rectangle();
    r.setX(10);/*w  w  w .jav  a  2  s.c  o m*/
    r.setY(10);
    r.setWidth(160);
    r.setHeight(80);
    r.setFill(Color.DARKBLUE);

    Text t = new Text();
    t.setText("Bloom!");
    t.setFill(Color.YELLOW);
    t.setFont(Font.font("null", FontWeight.BOLD, 36));
    t.setX(25);
    t.setY(65);

    g.setCache(true);
    //g.setEffect(new Bloom());
    Bloom bloom = new Bloom();
    bloom.setThreshold(1.0);
    g.setEffect(bloom);
    g.getChildren().add(r);
    g.getChildren().add(t);
    g.setTranslateX(350);
    return g;
}

From source file:Main.java

static Node perspective() {
    Group g = new Group();
    PerspectiveTransform pt = new PerspectiveTransform();
    pt.setUlx(10.0f);/*  ww w  . ja  va  2  s.  c  o m*/
    pt.setUly(10.0f);
    pt.setUrx(210.0f);
    pt.setUry(40.0f);
    pt.setLrx(210.0f);
    pt.setLry(60.0f);
    pt.setLlx(10.0f);
    pt.setLly(90.0f);

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

    Rectangle r = new Rectangle();
    r.setX(10.0f);
    r.setY(10.0f);
    r.setWidth(280.0f);
    r.setHeight(80.0f);
    r.setFill(Color.DARKBLUE);

    Text t = new Text();
    t.setX(20.0f);
    t.setY(65.0f);
    t.setText("Perspective");
    t.setFill(Color.RED);
    t.setFont(Font.font("null", FontWeight.BOLD, 36));

    g.getChildren().add(r);
    g.getChildren().add(t);
    return g;
}

From source file:Main.java

static Node displacementMap() {
    int w = 220;// w  w w .jav  a  2  s  .c  o m
    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 / 50.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);

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

    g.getChildren().add(r);

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

    g.getChildren().add(t);

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

    g.setTranslateX(400);
    g.setTranslateY(200);

    return g;
}

From source file:Main.java

public static void startValueSetAnimation(final Pane parent) {
    final javafx.scene.shape.Rectangle rectangle = new javafx.scene.shape.Rectangle();
    Insets margin = BorderPane.getMargin(parent);
    if (margin == null) {
        margin = new Insets(0);
    }// ww w  . ja v  a2 s. co m
    rectangle.widthProperty().bind(parent.widthProperty().subtract(margin.getLeft() + margin.getRight()));
    rectangle.heightProperty().bind(parent.heightProperty().subtract(margin.getTop() + margin.getBottom()));
    rectangle.setFill(Color.rgb(0, 150, 201));
    parent.getChildren().add(rectangle);

    BoxBlur bb = new BoxBlur();
    bb.setWidth(5);
    bb.setHeight(5);
    bb.setIterations(3);
    rectangle.setEffect(bb);

    FadeTransition ft = new FadeTransition(Duration.millis(250), rectangle);
    ft.setFromValue(0.2);
    ft.setToValue(0.8);
    ft.setCycleCount(2);
    ft.setAutoReverse(true);
    ft.play();
    ft.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            parent.getChildren().remove(rectangle);
        }
    });
}

From source file:Main.java

@Override
public void start(Stage stage) {
    final Group group = new Group();
    Scene scene = new Scene(group, 300, 150);
    stage.setScene(scene);/*from ww w .j a  v  a 2 s  . c o m*/
    stage.setTitle("Sample");

    Stop[] stops = { new Stop(0, Color.WHITE), new Stop(1, Color.BLACK) };
    LinearGradient lg = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);
    Rectangle r = new Rectangle(20, 20, 200, 200);
    r.setFill(lg);

    group.getChildren().add(r);
    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);/*w  ww .  j  a v  a2s .  c o  m*/
    Stop[] stops = new Stop[] { new Stop(0, Color.BLACK), new Stop(1, Color.RED) };
    LinearGradient lg1 = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops);

    Rectangle r1 = new Rectangle(0, 0, 100, 100);
    r1.setFill(lg1);

    box.getChildren().add(r1);

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

From source file:Main.java

@Override
public void start(Stage stage) {
    Button btn = new Button("A big button");

    Rectangle rect = new Rectangle(100, 50);
    rect.setFill(Color.WHITE);
    rect.setStrokeWidth(1);// www  . jav  a  2 s. c  o m
    rect.setStroke(Color.BLACK);

    HBox root = new HBox();
    root.setSpacing(20);
    root.getChildren().addAll(btn, rect);

    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("Resizable Nodes");
    stage.show();

    System.out.println("btn.isResizable(): " + btn.isResizable());
    System.out.println("rect.isResizable(): " + rect.isResizable());
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Group g = new Group();
    final Scene scene = new Scene(g, 300, 250);
    scene.setFill(null);//from   ww w  . j a  va2 s.c o  m

    Light.Spot light = new Light.Spot();
    light.setX(0);
    light.setY(100);
    light.setZ(50);
    light.setPointsAtX(400);
    light.setPointsAtY(0);
    light.setPointsAtZ(0);
    light.setSpecularExponent(2);

    Lighting l = new Lighting();
    l.setLight(light);
    l.setSurfaceScale(5.0);

    Text t = new Text();
    t.setText("Spot");
    t.setFill(Color.RED);
    t.setFont(Font.font(null, FontWeight.BOLD, 90));
    t.setX(10.0);
    t.setY(10.0);
    t.setTextOrigin(VPos.TOP);

    t.setEffect(l);

    Rectangle r = new Rectangle();
    r.setFill(Color.BLACK);

    g.getChildren().add(r);
    g.getChildren().add(t);

    r.setWidth(t.getLayoutBounds().getWidth() + 30);
    r.setHeight(t.getLayoutBounds().getHeight() + 20);

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