Java 类javafx.scene.GroupBuilder 实例源码

项目: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);

}
项目: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();
}
项目:javafx-demos    文件:Arrow.java   
@Override
public void start(Stage stage) throws Exception {
    this.stage = stage;
    configureScene();
    configureStage();

    // Rendering the arrow shape
            Path arrow = new Path();
            arrow.getElements().add(new MoveTo(40, 20));
            arrow.getElements().add(new LineTo(27, 20));
            arrow.getElements().add(new LineTo(27, 50));
            arrow.getElements().add(new LineTo(34, 40));
            arrow.getElements().add(new LineTo(27, 50));
            arrow.getElements().add(new LineTo(20, 40));
            arrow.setStrokeWidth(1);
            arrow.setStroke(Color.BLACK);

            Path arrow1 = new Path();
            arrow1.getElements().add(new MoveTo(0, 60)); //M 0 60
            arrow1.getElements().add(new LineTo(0, 70)); //V 70
            arrow1.getElements().add(new LineTo(60, 130)); // L 60 130
            arrow1.getElements().add(new LineTo(80, 110)); // L 80 110
            arrow1.getElements().add(new LineTo(40, 70)); // L 40 70
            arrow1.getElements().add(new LineTo(40, 60)); // V 60
            arrow1.getElements().add(new LineTo(80, 20)); // L 80 20
            arrow1.getElements().add(new LineTo(60, 0));  // L 60 0
            arrow1.getElements().add(new LineTo(0, 60)); // L 0 60 Z
            arrow1.getElements().add(new LineTo(0, 70));
            arrow1.setStrokeWidth(1);
            arrow1.setStroke(Color.BLACK);
            arrow1.setFill(Color.WHITE);

            Path arrow2 = new Path();
            arrow2.getElements().add(new MoveTo(0, 6));
            arrow2.getElements().add(new LineTo(0, 7));
            arrow2.getElements().add(new LineTo(6, 13));
            arrow2.getElements().add(new LineTo(8, 11));
            arrow2.getElements().add(new LineTo(4, 7));
            arrow2.getElements().add(new LineTo(4, 6));
            arrow2.getElements().add(new LineTo(8, 2));
            arrow2.getElements().add(new LineTo(6, 0));
            arrow2.getElements().add(new LineTo(0, 6));
            arrow2.getElements().add(new LineTo(0, 7));
            arrow2.setStrokeWidth(1);
            arrow2.setStroke(Color.BLACK);
            arrow2.setFill(Color.WHITE);

            StackPane leftSide = new StackPane();
            leftSide.setPrefSize(8, 13);
            leftSide.getStyleClass().add("small-bended-arrow");

            Rectangle p = new Rectangle();
            p.getStyleClass().add("small-bended-arrow-rect");

            Path downArrow = new Path();
            downArrow.getElements().add(new MoveTo(0, 0));
            downArrow.getElements().add(new LineTo(0, 1));
            downArrow.getElements().add(new LineTo(5, 6));
            downArrow.getElements().add(new LineTo(6, 6));
            downArrow.getElements().add(new LineTo(11, 1));
            downArrow.getElements().add(new LineTo(11, 0));
            downArrow.getElements().add(new LineTo(0, 0));
            downArrow.setStrokeWidth(.9);
            downArrow.setStroke(Color.BLACK);
            downArrow.setFill(Color.WHITE);

            root.getChildren().addAll(GroupBuilder.create().children(leftSide).build(),arrow1,downArrow);
}
项目:javafx-demos    文件:TriangleArea.java   
@Override public void start(Stage stage) {
  final Group root;
  Scene scene = SceneBuilder.create()
    .width(500).height(500)
    .fill(Color.WHITE)
    .root(root = GroupBuilder.create()
      .children(RectangleBuilder.create()
        .layoutX(5).layoutY(5)
        .width(490).height(490)
        .fill(Color.LIGHTSKYBLUE)
        .onMouseClicked(new EventHandler<MouseEvent>() {
          // Eventhandler for mouse click event
          @Override public void handle(MouseEvent e) {
            if (clickcount > 2) { initialize(); }
            for (int j = clickcount; j < 3; j++) {
              org_x[j].set(e.getSceneX());
              org_y[j].set(e.getSceneY());
            }
            clickcount++;
          }
        }).build(),
      // line for x-axis through the Origin
      LineBuilder.create()
        .startX(5).startY(490)
        .endX(495).endY(490)
        .build(),
      // Line for y-axis through the Origin
      LineBuilder.create()
        .startX(10).startY(5)
        .endX(10).endY(495)
        .build(),
      // grid horizontal lines which interval is of 1cm
      a_x_l[0], a_x_l[1], a_x_l[2], a_x_l[3],
      a_x_l[4], a_x_l[5], a_x_l[6], a_x_l[7],
      a_x_l[8], a_x_l[9], a_x_l[10], a_x_l[11],
      // grid vertical lines which interval is of 1cm
      a_y_l[0], a_y_l[1], a_y_l[2], a_y_l[3],
      a_y_l[4], a_y_l[5], a_y_l[6], a_y_l[7],
      a_y_l[8], a_y_l[9], a_y_l[10], a_y_l[11],
      // Sides
      l[0], l[1], l[2],
      // Vertices
      c[0], c[1], c[2],
      // the printing space of the coordinates and
      // the area of triangle
      HBoxBuilder.create()
        .layoutX(10)
        .padding(new Insets(10, 10, 10, 10)).spacing(3)
        .alignment(Pos.BOTTOM_CENTER)
        .children(
          LabelBuilder.create().text("A(").build(),
          tx[0],
          LabelBuilder.create().text(",").build(),
          ty[0],
          LabelBuilder.create().text("),").build(),
          LabelBuilder.create().text("B(").build(),
          tx[1],
           LabelBuilder.create().text(",").build(),
          ty[1],
          LabelBuilder.create().text("),").build(),
          LabelBuilder.create().text("C(").build(),
          tx[2],
          LabelBuilder.create().text(",").build(),
          ty[2],
          LabelBuilder.create().text(") ⇒ ").build(),
          area_Label
        ).build()
    ).build()
  ).build();

  stage.setTitle("Triangle Area");
  stage.setScene(scene);
  stage.show();
}
项目:javafx-demos    文件:DisplacementMapBannerDemo.java   
@Override
public void start(Stage stage) throws Exception {
    this.stage = stage;
    configureScene();
    configureStage();
    // Logic starts
    for (int i = 0; i < BANNER_NB; i++) {
        maps[i] = new FloatMap(W, H);
    }

    for (int x = 0; x < W/2; x++) {
        double angle = Math.PI * x / 50.0;
        float v = (float) (Math.sin(angle) / 20.0);
        float scaledX = x / W;
        System.out.println(x + " : " + angle + " : " + v);
        for (int y = 0; y < H; y++) {
            float scaledY = y / H;
            float scaledV = (float) (v - (1.0 - scaledY) / 20.0);
            maps[0].setSamples(x, y, 0, 0);
            maps[1].setSamples(x, y, v);
            maps[2].setSamples(x, y, 0, scaledV);
            maps[3].setSamples(x, y, v, scaledV);
            double sq = Math.sqrt(x * x + y * y);
            maps[4].setSamples(x, y, (float) ((115 - sq) / 115.0));
            maps[5].setSamples(x, y, 0, (float) (scaledX * scaledY * 4.7));
            maps[6].setSamples(x, y, 0, (float) (scaledX * 0.5));
            maps[7].setSamples(x, y, (float) (scaledY * 0.5));
        }
    }

    String[] messages = { "Reference", "Accordion", "Wavy Text", "Dizzy Text", "OxoXoxO", "XoxOxoX", "13463463", "2346346436" };
    VBox vb = new VBox();
    vb.setSpacing(15);
    for (int k = 0; k < messages.length; k++) {
        vb.getChildren().add(
                GroupBuilder.create().effect(DisplacementMapBuilder.create().mapData(maps[k]).wrap(bTestWrap).build()).cache(true)
                        .children(new Banner(messages[k])).build());
    }
    root.getChildren().add(
            ScrollPaneBuilder.create().fitToHeight(true).fitToWidth(true).style("-fx-background-color:transparent;").content(vb)
                    .build());
}
项目:javafx-demos    文件:ScrollFreeTextArea1.java   
public void requestToLayout(){
    System.out.println("in request layout");
    getChildren().clear();
    grp = GroupBuilder.create().children(lblContainer).build();
    getChildren().addAll(grp,textArea);
}