Example usage for javafx.scene.shape Rectangle setWidth

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

Introduction

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

Prototype

public final void setWidth(double value) 

Source Link

Usage

From source file:Main.java

static Node blendMode() {
    Rectangle r = new Rectangle();
    r.setX(590);/* ww w  .j  av a  2 s  .  c o m*/
    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);//from   w  w  w.j ava2s  . co 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);//from  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;//from  w w w .  j  a v a2  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

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");

    Group rectangleGroup = new Group();
    Scene scene = new Scene(rectangleGroup, 550, 250);

    Rectangle rect = new Rectangle();
    rect.setWidth(100);
    rect.setHeight(100);/*from  w  w  w  . ja va 2 s.  c  o m*/

    rect.setScaleY(2);
    rectangleGroup.getChildren().add(rect);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");

    Group rectangleGroup = new Group();
    Scene scene = new Scene(rectangleGroup, 550, 250);

    Rectangle rect = new Rectangle();
    rect.setWidth(100);
    rect.setHeight(100);//from  w  w w  . j  a  v  a2s .  c  om
    rect.setTranslateX(135);
    rect.setTranslateY(11.0);

    rectangleGroup.getChildren().add(rect);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");

    Group rectangleGroup = new Group();
    Scene scene = new Scene(rectangleGroup, 550, 250);

    Rectangle rect = new Rectangle();
    rect.setWidth(100);
    rect.setHeight(100);// ww w  . j  a  va  2  s  .  c  o  m

    Shear sh = new Shear();
    sh.setY(0.4);
    rect.getTransforms().add(sh);

    rectangleGroup.getChildren().add(rect);

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

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

    Rectangle r = new Rectangle();
    r.setX(50);//from   ww  w . j  a  v a  2s.  c  o  m
    r.setY(50);
    r.setWidth(200);
    r.setHeight(100);

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

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

    Rectangle r = new Rectangle();
    r.setX(50);/*  w  ww.ja  v  a 2s.  c o m*/
    r.setY(50);
    r.setWidth(200);
    r.setHeight(100);
    r.setArcWidth(20);
    r.setArcHeight(20);

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

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Text Fonts");

    Group g = new Group();
    Scene scene = new Scene(g, 550, 250);

    Rectangle r = new Rectangle();
    r.setX(10);//from ww  w . ja v  a  2s .  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());
    g.getChildren().add(r);
    g.getChildren().add(t);

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