Java 类javafx.scene.text.TextBuilder 实例源码

项目:javafx-demos    文件:JavaFX_DartBoard.java   
private void paintNumbers(Pane root) {
    TextBuilder textBuilder = TextBuilder.create()
            .font(Font.font("Verdana", FontWeight.BOLD, FONT_SIZE * FACTOR_SIZE))
            .styleClass("text-surround");

    for (int i = 0; i < DARTBOARD_NUMBERS.length; i++) {
        double degreeStart = i * ROTATE_ANGLE_DEGREES;
        double angleAlpha = degreeStart * (Math.PI / 180);

        double pointX1 = CENTER_X + POSITION_NUMBERS * Math.sin(angleAlpha)
                - calculateTextOffsetX(DARTBOARD_NUMBERS[i], FONT_SIZE);
        double pointY1 = CENTER_Y - POSITION_NUMBERS * Math.cos(angleAlpha)
                + calculateTextOffsetY(FONT_SIZE);

        root.getChildren().add(
            textBuilder
                 .x(pointX1)
                 .y(pointY1)
                 .text(DARTBOARD_NUMBERS[i])
                 .build()
                );
    }
}
项目:javafx-demos    文件:SearchSlideDemo.java   
/**
 * Method to configure the table.
 * @param root
 */
private void configureTable(StackPane root) {
    VBox vb = new VBox();
    vb.setSpacing(8);
    table = new TableView<Employee>();
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    TableColumn<Employee,String> firstNameColumn = new TableColumn<Employee,String>("First Name");
    firstNameColumn.setCellValueFactory(new PropertyValueFactory<Employee,String>("firstName"));

    TableColumn<Employee,String> lastNameCol = new TableColumn<Employee,String>("Last Name");
    lastNameCol.setCellValueFactory(new PropertyValueFactory<Employee,String>("lastName"));

    TableColumn<Employee,String> countryCol = new TableColumn<Employee,String>("Country");
    countryCol.setCellValueFactory(new PropertyValueFactory<Employee,String>("country"));

    table.getColumns().addAll(firstNameColumn,lastNameCol,countryCol);
    table.getItems().addAll(list);

    vb.getChildren().addAll(TextBuilder.create().text("Employee Table").font(Font.font("Arial", 22)).build(),table);
    root.getChildren().add(vb);
}
项目:javafx-demos    文件:ScrollPaneDisplacementDemo.java   
@Override
public void start(Stage stage) throws Exception {
    this.stage = stage;
    configureScene();
    configureStage();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < 150; i++) {
        sb.append("test ");
    }
    // Logic starts
    VBox vb = new VBox();
    vb.setStyle("-fx-border-width:1px;-fx-border-color:red;");
    vb.setPadding(new Insets(30));
    Text lbl = TextBuilder.create().text(sb.toString()).wrappingWidth(150).build();
    ScrollPane scroll = ScrollPaneBuilder.create().maxWidth(width).maxHeight(height).minWidth(width).minHeight(height)
            .content(StackPaneBuilder.create().alignment(Pos.TOP_LEFT).minHeight(400).children(lbl).build()).build();
    // vb.getChildren().addAll(scroll);
    root.getChildren().add(
            GroupBuilder.create()
                    .children(StackPaneBuilder.create().style("-fx-border-width:1px;-fx-border-color:red;").children(scroll).build())
                    .build());
    // applySineWaveEffect(scroll);
    // applyCosWaveEffect(scroll);
    applyEffect(scroll);

}
项目:javafx-demos    文件:DisplacementMapBannerDemo.java   
public Banner(String message) {
    Rectangle rectangle = RectangleBuilder
            .create()
            .x(0)
            .y(0)
            .width(W)
            .height(H)
            .fill(LinearGradientBuilder
                    .create()
                    .startX(0.0)
                    .startY(0.0)
                    .endX(10.0)
                    .endY(0.0)
                    .proportional(false)
                    .cycleMethod(CycleMethod.REFLECT)
                    .stops(StopBuilder.create().offset(0.0).color(Color.BLUE).build(),
                            StopBuilder.create().offset(1.0).color(Color.LIGHTBLUE).build()).build()).build();
    Text text = TextBuilder.create().x(25).y(H / 16).text(message).fill(Color.YELLOW).font(Font.font(null, FontWeight.BOLD, 36))
            .build();
    getChildren().addAll(rectangle, text);
}
项目:openjfx-8u-dev-tests    文件:LcdAPITestApp.java   
@Override
protected Scene getScene() {
    VBox root = VBoxBuilder.create()
            .padding(new Insets(10))
            .spacing(10)
            .children(
                TextBuilder.create()
                    .id("GrayGray")
                    .text("Text")
                    .fontSmoothingType(FontSmoothingType.GRAY)
                    .style("-fx-font-size: 16;-fx-font-smoothing-type: gray; ")
                    .build(),
                TextBuilder.create()
                    .id("LCDGray")
                    .text("Text")
                    .fontSmoothingType(FontSmoothingType.LCD)
                    .style("-fx-font-size: 16;-fx-font-smoothing-type: gray; ")
                    .build(),
                TextBuilder.create()
                    .id("GrayLCD")
                    .text("Text")
                    .fontSmoothingType(FontSmoothingType.GRAY)
                    .style("-fx-font-size: 16;-fx-font-smoothing-type: lcd; ")
                    .build(),
                TextBuilder.create()
                    .id("LCDLCD")
                    .text("Text")
                    .fontSmoothingType(FontSmoothingType.LCD)
                    .style("-fx-font-size: 16;-fx-font-smoothing-type: lcd;")
                    .build()
                )
            .build();

    return new Scene(root, 200, 200);
}
项目:stage-monitor    文件:MonitorView.java   
public DisplayUnit( MonitorModel model, double displayWidth, boolean isPrimary )
{
    super();
    BorderPaneBuilder.create()
        .top(
            northPanel = HBoxBuilder.create()
                .children(
                    pieChart = PieChartBuilder.create().id("pie-chart").animated(true).labelsVisible(false).legendVisible(false).clockwise(true).build()
                ).id("north-panel").alignment(Pos.CENTER).build()
        )
        .center(
            centerPanel = VBoxBuilder.create()
                .children(
                    clockPane = HBoxBuilder.create()
                        .children(
                            timeText = TextBuilder.create().id("time-text").text("10:11:24").build(),
                            ampmText = TextBuilder.create().id("ampm-text").text("AM").build()
                        ).id("time-pane").styleClass("panes").spacing(20.0).alignment(Pos.CENTER).build(),
                    datePane = HBoxBuilder.create()
                        .children(
                            dateText = TextBuilder.create().id("date-text").text("SUNDAY, JANUARY 5, 2014").build()
                        ).id("date-pane").styleClass("panes").alignment(Pos.CENTER).build(),
                    pingPane = HBoxBuilder.create()
                        .children(
                            pingText = TextBuilder.create().id("ping-text").text("PLEASE HURRY UP!").build()
                        ).id("ping-pane").styleClass("panes").alignment(Pos.CENTER).build()
                ).id("center-panel").spacing(20.0).alignment(Pos.TOP_CENTER).build()
        ).id("monitor").applyTo(this);

    this.isPrimary = isPrimary;
    this.displayWidth = displayWidth;
    pieData = new SimpleObjectProperty<ObservableList<PieChart.Data>>(FXCollections.observableArrayList(new PieChart.Data("",90),new PieChart.Data("",270)));
    bind();
    arrange(model.clockTopProperty().get());
    winBounds = new BoundingBox(pingPane.getBoundsInParent().getMinX(),pingPane.getBoundsInParent().getMinY(),displayWidth-20,0);
}
项目:mars-sim    文件:SlideDemo.java   
/**
 * Generate RMOUG text string with appropriate fill, font, and effect.
 * 
 * @return "RMOUG" text string with fill, font, and effect.
 */
private Text generateTitleText()
{
   return TextBuilder.create().text("Mars Simulation Project").x(20).y(20).fill(Color.DARKGRAY)
                     .font(Font.font(java.awt.Font.SERIF, 75))
                     .effect(new Glow(0.25)).build();
}
项目:mars-sim    文件:SlideDemo.java   
/**
 * Generate a text string with appropriate position, fill,
 * and font.
 * 
 * @return text string with specified font, fill, and position.
 */
private Text generateDaysText()
{
   return TextBuilder.create().text("Settlement Founding Day, 15-Adios-01")
                     .x(380).y(240).fill(Color.DARKOLIVEGREEN)
                     .font(Font.font(java.awt.Font.SERIF, 50)).build();
}
项目:mars-sim    文件:SlideDemo.java   
/**
 * Location String with specified effect, font, and position.
 * 
 * @return Location String with specified effect, font, and position.
 */
private Text generateLocationText()
{
   final Reflection reflection = new Reflection();
   reflection.setFraction(1.0);
   return TextBuilder.create()
                     .text("Schiaparelli Point, Mars").x(20).y(20)
                     .font(Font.font(java.awt.Font.SANS_SERIF, 25))
                     .effect(reflection)
                     .build();
}
项目:fx-jumpman    文件:View.java   
public void initializeView() {
    root = new AnchorPane();
    view = new Group();

    Scale viewScale = Transform.scale(1, 1, 0, 0);
    viewScale.xProperty().bind(root.widthProperty().divide(View.WIDTH));
    viewScale.yProperty().bind(root.heightProperty().divide(View.HEIGHT));
    view.getTransforms().add(viewScale);

    view.setFocusTraversable(true);
    view.addEventHandler(KeyEvent.ANY, new Controller());

    root.getChildren().add(view);

    Text info = TextBuilder.create()
            .text("Esc: Help\nR: Reset")
            .font(Font.font("Arial", FontWeight.BOLD, 16))
            .fill(Color.WHITE)
            .build();
    AnchorPane.setTopAnchor(info, 20.0);
    AnchorPane.setRightAnchor(info, 20.0);

    root.getChildren().add(info);

    Text time = TextBuilder.create()
            .font(Font.font("Arial", FontWeight.BOLD, 16))
            .fill(Color.WHITE)
            .build();
    time.textProperty().bind(Bindings.concat("Time: ", Bindings.format("%.2f", World.getInstance().levelTimeProperty()), " seconds"));

    AnchorPane.setTopAnchor(time, 20.0);
    AnchorPane.setLeftAnchor(time, 20.0);

    root.getChildren().add(time);

    help = new Help();
    root.getChildren().add(help);
}
项目:fx-jumpman    文件:Help.java   
public Help() {
    Rectangle background = RectangleBuilder.create()
            .width(460)
            .height(300)
            .arcWidth(20)
            .arcHeight(20)
            .fill(Color.rgb(0, 0, 0, 0.5))
            .build();
    Text text = TextBuilder.create()
            .text("Welcome to Jumpman !\n" + 
                    "Avoid the fireballs and make it to the goal as fast as possible.\n" +
                    "You can afford getting hit once, but not twice !\n\n" +
                    "Jumpman has the following skills:\n\n" +
                    " * Walk: by pressing the left or right arrow keys.\n" +
                    " * Run: by holding the F key while walking.\n" +
                    " * Brake: by pressing the opposite arrow key while moving.\n" +
                    " * Duck: by pressing the down arrow key.\n" +
                    " * Jump: by pressing the space key.\n\n" +
                    "Holding space longer will make Jumpman jump higher.\n" +
                    "Pressing more than one arrow key at the same time will not work.\n\n" +
                    "Press the escape key to close this window and start playing.")
            .font(Font.font("Arial", FontWeight.NORMAL, 14))
            .fill(Color.WHITE)
            .build();

    getChildren().addAll(background, text);
    setOpacity(0);

    AnchorPane root = View.getInstance().getRoot();
    translateXProperty().bind(root.widthProperty().divide(2).subtract(widthProperty().divide(2)));
    translateYProperty().bind(root.heightProperty().divide(2).subtract(heightProperty().divide(2)));
}
项目:javafx-demos    文件:SlideEffectDemo.java   
private void configureBox(VBox root) {
    StackPane container = new StackPane();
    container.setPrefHeight(250);
    container.setPrefSize(boxBounds.getWidth(), boxBounds.getHeight());
    container.setStyle("-fx-border-width:1px;-fx-border-style:solid;-fx-border-color:#999999;");

    /* BOTTOM PANE */
    Stop[] stops = new Stop[] { new Stop(0, Color.web("#F89C8C")), new Stop(1, Color.web("#BE250A"))};
    LinearGradient lg = new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, stops);
    bottomPane = new StackPane();
    bottomPane.getChildren().addAll(RectangleBuilder.create().width(boxBounds.getWidth()).height(boxBounds.getHeight()).fill(lg).build(), 
             TextBuilder.create().text("Click the above \"Slide Down\" button to see the top pane content...").wrappingWidth(200).font(Font.font("Arial", 22)).build());

    /* TOP PANE */
    Stop[] stops2 = new Stop[] { new Stop(0, Color.web("#FFFFFF")), new Stop(1, Color.web("#50AABC"))};
    LinearGradient lg2 = new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, stops2);
    StackPane sp1 = new StackPane();
    sp1.getChildren().add(TextBuilder.create().text("Click the below \"Slide Up\" button to see the bottom pane content...").wrappingWidth(200).font(Font.font("Arial", 22)).build());

    topPane = new StackPane();
    topPane.getChildren().addAll(RectangleBuilder.create().width(boxBounds.getWidth()).height(boxBounds.getHeight()).fill(lg2).build(), sp1);
    container.getChildren().addAll(bottomPane,topPane);

    setAnimation();

    Group gp = new Group();
    gp.getChildren().add(container);
    root.getChildren().addAll(getActionPane(),gp);
}
项目:MasteringTables    文件:ExpressionView.java   
/**
 * Return the text builder used for expression part.
 *
 * @return the text builder
 */
private TextBuilder<?> getExpressionTextBuilder() {
    return TextBuilder.create()
                      .scaleX(0).scaleY(0)
                      .textAlignment(TextAlignment.CENTER)
                      .font(MTFonts.EXPRESSION.get());
}
项目:JRebirth-Tour    文件:PlaceView.java   
private HBox buildGroup() {
    final HBox group = new HBox();

    group.getChildren().addAll(
                               TextBuilder.create().text("{{").font(JpFonts.CONF_TITLE.get()).fill(JpColors.SOFT_BLUE.get()).build(),
                               TextBuilder.create().text("soft").font(JpFonts.CONF_TITLE.get()).fill(JpColors.SOFT_BLACK.get()).build(),
                               TextBuilder.create().text("shake").font(JpFonts.CONF_TITLE.get()).fill(JpColors.SOFT_BLUE.get()).build(),
                               TextBuilder.create().text("}}").font(JpFonts.CONF_TITLE.get()).fill(JpColors.SOFT_BLACK.get()).build()

         );

    return group;
}
项目:marathonv5    文件:RaceTrack.java   
public RaceTrack() {
    ImageView carImageView = new ImageView(new Image(
            DataAppPreloader.class.getResourceAsStream("images/car.png")));
    road = SVGPathBuilder.create()
            .content(trackPath).fill(null).stroke(Color.gray(0.4))
            .strokeWidth(50)
            .effect(DropShadowBuilder.create().radius(20).blurType(BlurType.ONE_PASS_BOX).build())
            .build();
    SVGPath trackLine = SVGPathBuilder.create()
            .content(trackPath).fill(null).stroke(Color.WHITE)
            .strokeDashArray(8d,6d).build();
    Line startLine = LineBuilder.create()
            .startX(610.312).startY(401.055).endX(610.312).endY(450.838)
            .stroke(Color.WHITE).strokeDashArray(2d,2d).build();
    Text startFinish = TextBuilder.create().text("START/FINISH").fill(Color.WHITE)
            .x(570).y(475).build();
    percentage = TextBuilder.create().text("0%")
            .x(390).y(170).font(Font.font("System", 60))
            .fill(Color.web("#ddf3ff"))
            .stroke(Color.web("#73c0f7"))
            .effect(DropShadowBuilder.create().radius(15).color(Color.web("#3382ba")).blurType(BlurType.ONE_PASS_BOX).build())
            .build();
    ImageView raceCarImg = new ImageView(new Image(
            DataAppPreloader.class.getResourceAsStream("images/Mini-red-and-white.png")));
    raceCarImg.setX(raceCarImg.getImage().getWidth()/2);
    raceCarImg.setY(raceCarImg.getImage().getHeight()/2);
    raceCarImg.setRotate(90);
    raceCar = new Group(raceCarImg);

    track = new Group(road, trackLine, startLine, startFinish);
    track.setCache(true);
    // add children
    getChildren().addAll(track, raceCar, percentage);

    // Create path animation that we will use to drive the car along the track
    race = new PathTransition(Duration.seconds(1), road, raceCar);
    race.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
    race.play();
    race.pause();

    // center our content and set our size
    setTranslateX(-road.getBoundsInLocal().getMinX());
    setTranslateY(-road.getBoundsInLocal().getMinY());
    setPrefSize(road.getBoundsInLocal().getWidth(), road.getBoundsInLocal().getHeight());
    setMaxSize(USE_PREF_SIZE, USE_PREF_SIZE);
}
项目:marathonv5    文件:RaceTrack.java   
public RaceTrack() {
    ImageView carImageView = new ImageView(new Image(
            DataAppPreloader.class.getResourceAsStream("images/car.png")));
    road = SVGPathBuilder.create()
            .content(trackPath).fill(null).stroke(Color.gray(0.4))
            .strokeWidth(50)
            .effect(DropShadowBuilder.create().radius(20).blurType(BlurType.ONE_PASS_BOX).build())
            .build();
    SVGPath trackLine = SVGPathBuilder.create()
            .content(trackPath).fill(null).stroke(Color.WHITE)
            .strokeDashArray(8d,6d).build();
    Line startLine = LineBuilder.create()
            .startX(610.312).startY(401.055).endX(610.312).endY(450.838)
            .stroke(Color.WHITE).strokeDashArray(2d,2d).build();
    Text startFinish = TextBuilder.create().text("START/FINISH").fill(Color.WHITE)
            .x(570).y(475).build();
    percentage = TextBuilder.create().text("0%")
            .x(390).y(170).font(Font.font("System", 60))
            .fill(Color.web("#ddf3ff"))
            .stroke(Color.web("#73c0f7"))
            .effect(DropShadowBuilder.create().radius(15).color(Color.web("#3382ba")).blurType(BlurType.ONE_PASS_BOX).build())
            .build();
    ImageView raceCarImg = new ImageView(new Image(
            DataAppPreloader.class.getResourceAsStream("images/Mini-red-and-white.png")));
    raceCarImg.setX(raceCarImg.getImage().getWidth()/2);
    raceCarImg.setY(raceCarImg.getImage().getHeight()/2);
    raceCarImg.setRotate(90);
    raceCar = new Group(raceCarImg);

    track = new Group(road, trackLine, startLine, startFinish);
    track.setCache(true);
    // add children
    getChildren().addAll(track, raceCar, percentage);

    // Create path animation that we will use to drive the car along the track
    race = new PathTransition(Duration.seconds(1), road, raceCar);
    race.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
    race.play();
    race.pause();

    // center our content and set our size
    setTranslateX(-road.getBoundsInLocal().getMinX());
    setTranslateY(-road.getBoundsInLocal().getMinY());
    setPrefSize(road.getBoundsInLocal().getWidth(), road.getBoundsInLocal().getHeight());
    setMaxSize(USE_PREF_SIZE, USE_PREF_SIZE);
}
项目:openjfx-8u-dev-tests    文件:AnimationLCDTextTestApp.java   
@Override
public void start(Stage primaryStage) {


    final TextArea testText = TextAreaBuilder.create()
            .text("Test")
            .prefHeight(50)
            .prefWidth(500)
            .build();

    final ChoiceBox<Interpolator> interpolatorChoiceBox = new ChoiceBox<Interpolator>();
    interpolatorChoiceBox.getItems().addAll(FXCollections.observableArrayList(
                Interpolator.LINEAR,
                Interpolator.DISCRETE,
                Interpolator.EASE_BOTH,
                Interpolator.EASE_IN,
                Interpolator.EASE_OUT
                ));
    interpolatorChoiceBox.setPrefHeight(25);
    interpolatorChoiceBox.setPrefWidth(500);

    interpolatorChoiceBox.getSelectionModel().selectFirst();


    final Text lcdText = TextBuilder.create()
            .x(100)
            .y(100)
            .fontSmoothingType(FontSmoothingType.LCD)
            .build();

    lcdText.textProperty().bind(testText.textProperty());

    final Circle point = CircleBuilder.create()
            .centerX(100)
            .centerY(100)
            .radius(2)
            .fill(Color.RED)
            .build();

    Pane root = VBoxBuilder.create()
            .children(
                PaneBuilder.create()
                .minWidth(500)
                .minHeight(500)
                .children(
                    lcdText,
                    point)
                .onMouseClicked(new EventHandler<MouseEvent>() {

                    @Override
                    public void handle(MouseEvent event) {
                        point.setCenterX(event.getX());
                        point.setCenterY(event.getY());

                        TimelineBuilder.create()
                            .keyFrames(
                                new KeyFrame(Duration.seconds(5),
                                    new KeyValue(lcdText.xProperty(), event.getX(),
                                        interpolatorChoiceBox.getSelectionModel().getSelectedItem())),
                                new KeyFrame(Duration.seconds(5),
                                    new KeyValue(lcdText.yProperty(), event.getY(),
                                        interpolatorChoiceBox.getSelectionModel().getSelectedItem()))
                                )
                            .build()
                            .play();
                    }
                })
                .build(),
                testText,
                interpolatorChoiceBox)
            .build();



    Scene scene = new Scene(root, 500, 575);

    primaryStage.setTitle("Test Animnation LCD Text");
    primaryStage.setResizable(false);
    primaryStage.setScene(scene);
    primaryStage.show();
}
项目:stage-monitor    文件:MonitorView.java   
public ControlPanel(MonitorModel model)
{
    super();
    setSpacing(20);
    HBoxBuilder.create()
        .children(
            statusCPanel = HBoxBuilder.create()
                .children(
                    okRadio = RadioButtonBuilder.create().id("ok-radio").userData("ok").text("OK").maxWidth(Double.MAX_VALUE).maxHeight(Double.MAX_VALUE).build(),
                    readyRadio = RadioButtonBuilder.create().id("ready-radio").userData("ready").text("Ready").maxWidth(Double.MAX_VALUE).maxHeight(Double.MAX_VALUE).build(),
                    criticalRadio = RadioButtonBuilder.create().id("critical-radio").userData("critical").text("Critical").maxWidth(Double.MAX_VALUE).maxHeight(Double.MAX_VALUE).build()
                ).styleClass("cpanel").spacing(7.0).fillHeight(true).alignment(Pos.CENTER).build(),
            pingCPanel = HBoxBuilder.create()
                .children(
                    pingField = TextFieldBuilder.create().promptText("  Ping goes here!").build(),
                    fwdButton = new Button("FWD"),
                    clsButton = new Button("CLS")
                ).styleClass("cpanel").spacing(7.0).fillHeight(true).alignment(Pos.CENTER).build(),
            clockinCPanel = HBoxBuilder.create()
                .children(
                    clockinButton = new Button("CLK"),
                    clockinText = TextBuilder.create().id("clockin-text").build(),
                    updateText = TextBuilder.create().id("update-text").build(),
                    clockinUpdateButton = new Button("UPD")
                ).styleClass("cpanel").spacing(7.0).fillHeight(true).alignment(Pos.CENTER).build(),
            controlCPanel = HBoxBuilder.create()
                .children(
                    extSignalButton = ButtonBuilder.create().id("ext-signal").minWidth(2).minHeight(2).maxWidth(25).maxHeight(25).build()
                ).styleClass("cpanel").spacing(7.0).fillHeight(true).alignment(Pos.CENTER).build()
        ).id("control-panel").spacing(30.0).fillHeight(true).alignment(Pos.CENTER).applyTo(this);

    statusToggle = ToggleGroupBuilder.create().toggles(okRadio,readyRadio,criticalRadio).build();
    statusToggle.selectToggle(okRadio);
    HBox.setHgrow(pingField,Priority.ALWAYS);
    HBox.setHgrow(clockinText,Priority.NEVER);
    HBox.setHgrow(updateText,Priority.NEVER);

    HBox.setHgrow(statusCPanel,Priority.NEVER);
    HBox.setHgrow(pingCPanel,Priority.ALWAYS);
    HBox.setHgrow(clockinCPanel,Priority.NEVER);

    bind();
}
项目:mars-sim    文件:Scroll2.java   
@Override
public void start(Stage stage) {

  String message = 
    "Earthrise at Christmas: " +
    "[Forty] years ago this Christmas, a turbulent world " +
    "looked to the heavens for a unique view of our home "  +
    "planet. This photo of Earthrise over the lunar horizon " +
    "was taken by the Apollo 8 crew in December 1968, showing " +
    "Earth for the first time as it appears from deep space. " +
    "Astronauts Frank Borman, Jim Lovell and William Anders " +
    "had become the first humans to leave Earth orbit, " +
    "entering lunar orbit on Christmas Eve. In a historic live " +
    "broadcast that night, the crew took turns reading from " +
    "the Book of Genesis, closing with a holiday wish from " +
    "Commander Borman: \"We close with good night, good luck, " +
    "a Merry Christmas, and God bless all of you -- all of " +
    "you on the good Earth.\"";

  // Reference to the Text
  Text textRef = TextBuilder.create()
    .layoutY(100)
    .textOrigin(VPos.TOP)
    .textAlignment(TextAlignment.JUSTIFY)
    .wrappingWidth(400)
    .text(message)
    .fill(Color.rgb(187, 195, 107))
    .font(Font.font("SansSerif", FontWeight.BOLD, 24))
    .build();

   // Provides the animated scrolling behavior for the text
  TranslateTransition transTransition = TranslateTransitionBuilder.create()
    .duration(new Duration(75000))
    .node(textRef)
    .toY(-820)
    .interpolator(Interpolator.LINEAR)
    .cycleCount(Timeline.INDEFINITE)
    .build();

  Scene scene  = SceneBuilder.create()
    .width(516)
    .height(387)
    .root(
      GroupBuilder.create()
        .children(
          ImageViewBuilder.create()
            .image(new Image("http://projavafx.com/images/earthrise.jpg"))
            .build(),
          ScrollPaneBuilder.create()
            .layoutX(50)
            .layoutY(100)
            .prefWidth(440)
            .prefHeight(200)
            .hbarPolicy(ScrollBarPolicy.NEVER)
            .vbarPolicy(ScrollBarPolicy.NEVER)
            .pannable(true)
            .content(textRef)
            .style("-fx-background-color: transparent;")
            .build()
        )
        .build()
    )
    .build();

  stage.setScene(scene);
  stage.setTitle("Hello Earthrise");
  stage.show();

  // Start the text animation
  transTransition.play();
}
项目:JacpFX-misc    文件:ContactWorkbench.java   
private Text createInfoText() {
    return TextBuilder.create().layoutY(100).textOrigin(VPos.TOP).textAlignment(TextAlignment.JUSTIFY).wrappingWidth(400).text(this.message).fill(Color.WHITE).build();
}
项目:Pruebas    文件:JavaFX_SaveText.java   
@Override
public void start(final Stage primaryStage) {
    primaryStage.setTitle("java-buddy.blogspot.com");
    Group root = new Group();

    final String Santa_Claus_Is_Coming_To_Town =
            "You better watch out\n"
            + "You better not cry\n"
            + "Better not pout\n"
            + "I'm telling you why\n"
            + "Santa Claus is coming to town\n"
            + "\n"
            + "He's making a list\n"
            + "And checking it twice;\n"
            + "Gonna find out Who's naughty and nice\n"
            + "Santa Claus is coming to town\n"
            + "\n"
            + "He sees you when you're sleeping\n"
            + "He knows when you're awake\n"
            + "He knows if you've been bad or good\n"
            + "So be good for goodness sake!\n"
            + "\n"
            + "O! You better watch out!\n"
            + "You better not cry\n"
            + "Better not pout\n"
            + "I'm telling you why\n"
            + "Santa Claus is coming to town\n"
            + "Santa Claus is coming to town\n";

    Text textSong = TextBuilder.create()
            .text(Santa_Claus_Is_Coming_To_Town)
            .build();               

    Button buttonSave = ButtonBuilder.create()
            .text("Save")
            .build();

    buttonSave.setOnAction(new EventHandler<ActionEvent>() {

      @Override
      public void handle(ActionEvent event) {
          FileChooser fileChooser = new FileChooser();

          //Set extension filter
          FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("TXT files (*.txt)", "*.txt");
          fileChooser.getExtensionFilters().add(extFilter);

          //Show save file dialog
          File file = fileChooser.showSaveDialog(primaryStage);

          if(file != null){
              SaveFile(Santa_Claus_Is_Coming_To_Town, file);
          }
      }
  });

    VBox vBox = VBoxBuilder.create()
            .children(textSong, buttonSave)
            .build();

    root.getChildren().add(vBox);

    primaryStage.setScene(new Scene(root, 500, 400));
    primaryStage.show();

}
项目:RadialFx    文件:DemoUtil.java   
public void addGraphicControl(final String title,
    final ObjectProperty<Node> graphicProperty) {

final Node circle  = CircleBuilder.create().radius(4).fill(Color.ORANGE).build();
final Node square  = RectangleBuilder.create().width(8).height(8).build();
final Node text  = TextBuilder.create().text("test").build();

final ComboBox<Node> choices = new ComboBox<Node>(FXCollections.observableArrayList(circle, square, text));
choices.setCellFactory(new Callback<ListView<Node>, ListCell<Node>>() {
    @Override
    public ListCell<Node> call(final ListView<Node> param) {
    final ListCell<Node> cell = new ListCell<Node>() {
        @Override
        public void updateItem(final Node item, final boolean empty) {
        super.updateItem(item, empty);
        if (item != null) {
            setText(item.getClass().getSimpleName());
        } else {
            setText(null);
        }
        }
    };
    return cell;
    }
});
choices.getSelectionModel().select(0);
graphicProperty.bind(choices.valueProperty());

final VBox box = new VBox();
final Text titleText = new Text(title);

titleText.textProperty().bind(new StringBinding() {
    {
    super.bind(choices.selectionModelProperty());
    }

    @Override
    protected String computeValue() {
    return title + " : "
        + String.valueOf(choices.selectionModelProperty().get().getSelectedItem().getClass().getSimpleName());
    }

});
box.getChildren().addAll(titleText, choices);
getChildren().add(box);

   }