Example usage for javafx.scene.text Text setTextOrigin

List of usage examples for javafx.scene.text Text setTextOrigin

Introduction

In this page you can find the example usage for javafx.scene.text Text setTextOrigin.

Prototype

public final void setTextOrigin(VPos value) 

Source Link

Usage

From source file:Main.java

static Node lighting() {
    Light.Distant light = new Light.Distant();
    light.setAzimuth(-135.0f);/*ww  w  .j  a v  a 2 s.c  o  m*/

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

    Text t = new Text();
    t.setText("JavaFX\nLighting!");
    t.setFill(Color.RED);
    t.setFont(Font.font("null", FontWeight.BOLD, 70));
    t.setX(500.0f);
    t.setY(100.0f);
    t.setTextOrigin(VPos.TOP);

    t.setEffect(l);

    t.setTranslateX(0);
    t.setTranslateY(320);

    return t;
}

From source file:Main.java

static Node distantLight() {
    Light.Distant light = new Light.Distant();
    light.setAzimuth(-135.0f);// ww w .j  av  a  2s  .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

@Override
public void start(Stage stage) {
    Text msg = new Text("java2s.com");
    msg.setTextOrigin(VPos.TOP);
    msg.setFont(Font.font(24));//  w ww.j a v a  2  s.c o  m

    Pane root = new Pane(msg);
    root.setPrefSize(500, 70);
    Scene scene = new Scene(root);

    stage.setScene(scene);
    stage.setTitle("Scrolling Text");
    stage.show();

    double sceneWidth = scene.getWidth();
    double msgWidth = msg.getLayoutBounds().getWidth();

    KeyValue initKeyValue = new KeyValue(msg.translateXProperty(), sceneWidth);
    KeyFrame initFrame = new KeyFrame(Duration.ZERO, initKeyValue);

    KeyValue endKeyValue = new KeyValue(msg.translateXProperty(), -1.0 * msgWidth);
    KeyFrame endFrame = new KeyFrame(Duration.seconds(3), endKeyValue);

    Timeline timeline = new Timeline(initFrame, endFrame);

    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.play();
}

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);//from   w  ww.  j  a  va  2s  .  c o m

    Light.Distant light = new Light.Distant();
    light.setAzimuth(-135.0);

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

    Text t = new Text();
    t.setText("JavaFX!");
    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);

    box.getChildren().add(t);

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

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 w  w  w . ja  v a  2s  .  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();
}