Java 类javafx.scene.shape.LineBuilder 实例源码

项目:openjfx-8u-dev-tests    文件:FSTestApp.java   
/**
 * Create scene with grid.
 * @return new scene
 */
private Scene createTestGridScene(){
    double height = getMaxScreenHeight();
    double width = getMaxScreenWidth();


    Pane root  = PaneBuilder.create()
            .minHeight(height)
            .minWidth(width)
            .build();

    for (int x = 0; x < width; x+=10) {
        root.getChildren().add(
                LineBuilder.create()
                    .startX(x)
                    .endX(x)
                    .startY(0)
                    .endY(height)
                    .build());
    }

    for (int y = 0; y < height; y+=10) {
        root.getChildren().add(
                LineBuilder.create()
                    .startX(0)
                    .endX(width)
                    .startY(y)
                    .endY(y)
                    .build());
    }

    return new Scene(root, 200, 200);
}
项目:JavaFXTutorials    文件:JUNGAndJavaFX.java   
/**
 * Render a graph to a particular <code>Group</code>
 * @param graph
 * @param layout
 * @param viz 
 */
private void renderGraph(Graph<String, Number> graph, Layout<String, Number> layout, Group viz) {
    // draw the vertices in the graph
    for (String v : graph.getVertices()) {
        // Get the position of the vertex
        Point2D p = layout.transform(v);

        // draw the vertex as a circle
        Circle circle = CircleBuilder.create()
                .centerX(p.getX())
                .centerY(p.getY())
                .radius(CIRCLE_SIZE)
                .build();

        // add it to the group, so it is shown on screen
        viz.getChildren().add(circle);
    }

    // draw the edges
    for (Number n : graph.getEdges()) {
        // get the end points of the edge
        Pair<String> endpoints = graph.getEndpoints(n);

        // Get the end points as Point2D objects so we can use them in the 
        // builder
        Point2D pStart = layout.transform(endpoints.getFirst());
        Point2D pEnd = layout.transform(endpoints.getSecond());

        // Draw the line
        Line line = LineBuilder.create()
                .startX(pStart.getX())
                .startY(pStart.getY())
                .endX(pEnd.getX())
                .endY(pEnd.getY())
                .build();
        // add the edges to the screen
        viz.getChildren().add(line);
    }
}
项目: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);
}
项目: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();
}