Example usage for javafx.scene Group setCache

List of usage examples for javafx.scene Group setCache

Introduction

In this page you can find the example usage for javafx.scene Group setCache.

Prototype

public final void setCache(boolean value) 

Source Link

Usage

From source file:Main.java

static Node perspective() {
    Group g = new Group();
    PerspectiveTransform pt = new PerspectiveTransform();
    pt.setUlx(10.0f);/* w w  w. j a v a  2 s  .  c  om*/
    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 bloom() {
    Group g = new Group();

    Rectangle r = new Rectangle();
    r.setX(10);/* www  .j  a  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());
    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 displacementMap() {
    int w = 220;//from   ww w  . j a v  a  2s  .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("");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    int w = 220;//from   w  ww . j a  v  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 / 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 stage) {
    Group root = new Group();
    Scene scene = new Scene(root, 260, 80);
    stage.setScene(scene);/*from  w  w w .ja  va2 s. c  om*/

    Group g = new Group();
    PerspectiveTransform pt = new PerspectiveTransform();
    pt.setUlx(10.0);
    pt.setUly(10.0);
    pt.setUrx(310.0);
    pt.setUry(40.0);
    pt.setLrx(310.0);
    pt.setLry(60.0);
    pt.setLlx(10.0);
    pt.setLly(90.0);

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

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

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

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

    scene.setRoot(g);
    stage.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);/* w  ww  . ja v  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());
    g.getChildren().add(r);
    g.getChildren().add(t);

    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, Color.web("0x0000FF", 1.0));

    Rectangle r = new Rectangle();
    r.setX(10);//from  ww w.j  av  a2 s .c  om
    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();
}