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

项目:javafx-demos    文件:ShapesDemo.java   
private void createMinus() {
    Path minus = PathBuilder.create()
            .elements(new MoveTo(0, 0),
                    new LineTo(0, 5),
                    new LineTo(15, 5),
                    new LineTo(15, 0),
                    new LineTo(0, 0))
            .stroke(Color.web("#000000"))
            .fill(Color.web("#FFFFFF"))
            .strokeWidth(1)
            .cursor(Cursor.HAND)
            .build();
    Circle c = CircleBuilder.create().radius(13).style("-fx-fill:-fx-base;").build() ;
    StackPane sp = StackPaneBuilder.create().styleClass("close-btn")
                                   .maxHeight(26).maxWidth(26)
                                   .prefHeight(26).prefWidth(26)
                                   .children(c,minus).build();

    root.getChildren().add(sp);
}
项目:incubator-netbeans    文件:TransitionPath.java   
private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setResizable(false);
    primaryStage.setScene(new Scene(root, 400,260));
    Rectangle rect = new Rectangle (0, 0, 40, 40);
    rect.setArcHeight(10);
    rect.setArcWidth(10);
    rect.setFill(Color.ORANGE);
    root.getChildren().add(rect);
    Path path = PathBuilder.create()
            .elements(
                new MoveTo(20,20),
                new CubicCurveTo(380, 0, 380, 120, 200, 120),
                new CubicCurveTo(0, 120, 0, 240, 380, 240)
            )
            .build();
    path.setStroke(Color.DODGERBLUE);
    path.getStrokeDashArray().setAll(5d,5d);
    root.getChildren().add(path);

    pathTransition = PathTransitionBuilder.create()
            .duration(Duration.seconds(4))
            .path(path)
            .node(rect)
            .orientation(OrientationType.ORTHOGONAL_TO_TANGENT)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(true)
            .build();
}
项目:javafx-demos    文件:SlideToLeftDemo.java   
public Path getArrow(){
    Path arrow = PathBuilder.create()
                      .elements(new MoveTo(0, 0),
                                new LineTo(6, 6),
                                new LineTo(12, 0),
                                new MoveTo(0, 6),
                                new LineTo(6, 12),
                                new LineTo(12, 6))
                      .stroke(Color.web("#5D5D5D"))
                      .strokeWidth(2)
                      .build();
    arrow.rotateProperty().bind(arrowRotate);
    return arrow;
}
项目:javafx-demos    文件:ShapesDemo.java   
private void createPlus() {
    Path plus = PathBuilder.create()
            .elements(new MoveTo(5, 0),
                    new LineTo(5, 5),
                    new LineTo(0, 5),
                    new LineTo(0, 10),
                    new LineTo(5, 10),
                    new LineTo(5, 15),
                    new LineTo(10, 15),
                    new LineTo(10, 10),
                    new LineTo(15, 10),
                    new LineTo(15, 5),
                    new LineTo(10, 5),
                    new LineTo(10, 0),
                    new LineTo(5, 0))
            .stroke(Color.web("#000000"))
            .fill(Color.web("#FFFFFF"))
            .strokeWidth(1)
            .rotate(45)
            .cursor(Cursor.HAND)
            .build();

    Circle c = CircleBuilder.create().radius(13).style("-fx-fill:-fx-base;").build() ;
    StackPane sp = StackPaneBuilder.create()
                                   .maxHeight(26).maxWidth(26)
                                   .prefHeight(26).prefWidth(26)
                                   .children(c,plus).build();
    root.getChildren().add(sp);
}
项目:javafx-demos    文件:JavaFX_DartBoard.java   
private Path createDartboardField(double degreeStart, double degreeEnd, double innerRadius, double outerRadius, String style) {
    double angleAlpha = degreeStart * (Math.PI / 180);
    double angleAlphaNext = degreeEnd * (Math.PI / 180);

    //Point 1
    double pointX1 = CENTER_X + innerRadius * Math.sin(angleAlpha);
    double pointY1 = CENTER_Y - innerRadius * Math.cos(angleAlpha);

    //Point 2
    double pointX2 = CENTER_X + outerRadius * Math.sin(angleAlpha);
    double pointY2 = CENTER_Y - outerRadius * Math.cos(angleAlpha);

    //Point 3
    double pointX3 = CENTER_X + outerRadius * Math.sin(angleAlphaNext);
    double pointY3 = CENTER_Y - outerRadius * Math.cos(angleAlphaNext);

    //Point 4
    double pointX4 = CENTER_X + innerRadius * Math.sin(angleAlphaNext);
    double pointY4 = CENTER_Y - innerRadius * Math.cos(angleAlphaNext);

    Path path = PathBuilder.create()
            .styleClass(style)
            .elements(
            new MoveTo(pointX1, pointY1),
            new LineTo(pointX2, pointY2),
            ArcToBuilder
                     .create()
                     .radiusX(outerRadius)
                     .radiusY(outerRadius)
                     .x(pointX3)
                     .y(pointY3)
                     .sweepFlag(true)
                     .build(),
            new LineTo(pointX4, pointY4),
            ArcToBuilder
                     .create()
                     .radiusX(innerRadius)
                     .radiusY(innerRadius)
                     .x(pointX1)
                     .y(pointY1)
                     .sweepFlag(false)
                     .build())
            .build();
    return path;
}
项目:RadialFx    文件:RadialColorMenu.java   
private void addColorItem(final Color color, final double startAngle,
    final double length) {

final RadialMenuItem colorItem = RadialMenuItemBuilder.create()
    .startAngle(startAngle).length(length).backgroundFill(color)
    .backgroundMouseOnFill(color).strokeVisible(false).offset(minOffset)
    .innerRadius(60).radius(140).build();
getChildren().add(colorItem);

final Path extGraphic = PathBuilder
    .create()
    .elements(MoveToBuilder.create().x(-2.5).y(0).build(),
        LineToBuilder.create().x(-2.5).y(5).build(),
        LineToBuilder.create().x(2.5).y(0).build(),
        LineToBuilder.create().x(-2.5).y(-5).build(),
        LineToBuilder.create().x(-2.5).y(0).build())
    .fill(Color.WHITE)
    .stroke(null)
    .rotate(-colorItem.startAngleProperty().get()
        - colorItem.lengthProperty().get() / 2.0)

    .build();
final RadialMenuItem colorItemExt = RadialMenuItemBuilder.create()
    .startAngle(startAngle).length(length).backgroundFill(color)
    .backgroundMouseOnFill(color).strokeVisible(false)
    .innerRadius(142).radius(180).graphic(extGraphic).offset(minOffset)
    .build();

getChildren().add(colorItemExt);
colorItemExt.setOnMouseClicked(itemExtMouseHandler);

final Paint selectColor = Color.GRAY;
final double colorOffset = 6;
final RadialMenuItem colorItemSel = RadialMenuItemBuilder.create()
    .startAngle(startAngle + colorOffset).offset(minOffset)
    .length(length - colorOffset * 2).backgroundFill(selectColor)
    .strokeVisible(false).innerRadius(132).radius(134).build();
colorItemSel.setOpacity(0.0);
getChildren().add(colorItemSel);

final EventHandler<MouseEvent> mouseHandler = new ItemOnEventHandler(
    colorItemSel, colorItem, colorItemExt);
colorItem.setOnMouseEntered(mouseHandler);
colorItem.setOnMouseExited(mouseHandler);
colorItem.setOnMouseMoved(mouseHandler);
   }