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

项目:openjfx-8u-dev-tests    文件:LocalTo_TransformsApp.java   
public LocalTo_TransformsScene()
{
    super(hBox, 150, 150, true);
    setCamera(new PerspectiveCamera());

    StackPane firstPane = new StackPane();
    StackPane secondPane = new StackPane();
    StackPane thirdPane = new StackPane();
    StackPane nestedPane = new StackPane();
    StackPane doubleNestedPane = new StackPane();
    StackPane forthPane = new StackPane();

    Circle circle1 = CircleBuilder.create().radius(20).id("circle_one").build();
    Circle circle2 = CircleBuilder.create().radius(20).id("circle_two").build();
    Circle circle3 = CircleBuilder.create().radius(20).id("circle_three").build();
    Circle circle4 = CircleBuilder.create().radius(20).id("circle_four").translateZ(-50).build();

    forthPane.getChildren().add(circle4);
    doubleNestedPane.getChildren().add(circle3);
    nestedPane.getChildren().add(doubleNestedPane);
    thirdPane.getChildren().add(nestedPane);
    secondPane.getChildren().add(circle2);
    firstPane.getChildren().add(circle1);
    hBox.getChildren().addAll(firstPane, secondPane, thirdPane, forthPane);
}
项目:enders_game    文件:Bullet.java   
/**
* The constructor for a bullet.
* 
* @param radius - the radius of the bullet
* @param fill - the color of the bullet highlight
*/
  public Bullet(double radius, Color fill) {
      sphere = CircleBuilder.create()
              .centerX(radius)
              .centerY(radius)
              .radius(radius)
              .cache(true)
              .build();

      RadialGradient rgrad = RadialGradientBuilder.create()
                  .centerX(sphere.getCenterX() - sphere.getRadius() / 3)
                  .centerY(sphere.getCenterY() - sphere.getRadius() / 3)
                  .radius(sphere.getRadius())
                  .proportional(false)
                  .stops(new Stop(0.0, fill), new Stop(1.0, Settings.BULLET_PRIMARY_COLOR))
                  .build();

      sphere.setFill(rgrad);
  }
项目: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);
}
项目:Fishification    文件:BubbleEntity.java   
private Circle createBubbleCircle(double radius) {
    CircleBuilder<?> circleBuilder = CircleBuilder.create();
    circleBuilder.radius(radius);
    circleBuilder.cache(true);
    Circle sphere = circleBuilder.build();
    sphere.setOpacity(BUBBLE_OPACITY);

    RadialGradientBuilder gradientBuilder = RadialGradientBuilder.create();
    gradientBuilder.centerX(sphere.getCenterX() - sphere.getRadius() / 3);
    gradientBuilder.centerY(sphere.getCenterY() - sphere.getRadius() / 3);
    gradientBuilder.radius(sphere.getRadius());
    gradientBuilder.proportional(false);
    gradientBuilder.stops(new Stop(0.0, Color.BLUE), new Stop(1.0, Color.BLACK));
    RadialGradient gradient = gradientBuilder.build();

    sphere.setFill(gradient);
    return sphere;
}
项目: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    文件:SineWaveDemo.java   
private Node getBottom() {
    StackPane sp = new StackPane();
    sp.setMinHeight(25);
    sp.setAlignment(Pos.TOP_RIGHT);
    Circle c = CircleBuilder.create().fill(Color.RED).translateX(-5).translateY(3).radius(8).cursor(Cursor.HAND).build();
    c.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent paramT) {
            ScenicView.show(scene);
        }
    });
    sp.getChildren().addAll(new Separator(), c);
    return sp;
}
项目:javafx-demos    文件:ToggleButtonGraphicStylingDemo.java   
private Node buildDiseaseStatusIcon(boolean item) {
    // TODO : Increased verbosity of the code. Here only the color code is changed. you can set the color code in if condition and build
    // a circle with the color code variable.
    Circle circle = null;
    if (item) {
        circle = CircleBuilder.create().radius(5).fill(Color.web("#D9D900")).styleClass("yellowEffect").stroke(Color.web("#D9D900")).build();
    } else {
        circle = CircleBuilder.create().radius(5).fill(Color.web("#5FD095")).styleClass("redEffect").stroke(Color.web("#5FD095")).build();
    }
    return circle;
}
项目:javafx-demos    文件:RadioCheckBoxDemo.java   
private Node getBottom() {
    StackPane sp = new StackPane();
    sp.setMinHeight(25);
    sp.setAlignment(Pos.TOP_RIGHT);
    Circle c = CircleBuilder.create().fill(Color.RED).translateX(-5).translateY(3).radius(8).cursor(Cursor.HAND).build();
    c.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent paramT) {
            ScenicView.show(scene);
        }
    });
    sp.getChildren().addAll(new Separator(), c);
    return sp;
}
项目:javafx-demos    文件:DemoTemplate.java   
private Node getBottom() {
    StackPane sp = new StackPane();
    sp.setMinHeight(25);
    sp.setAlignment(Pos.TOP_RIGHT);
    Circle c = CircleBuilder.create().fill(Color.RED).translateX(-5).translateY(3).radius(8).cursor(Cursor.HAND).build();
    c.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent paramT) {
            ScenicView.show(scene);
        }
    });
    sp.getChildren().addAll(new Separator(), c);
    return sp;
}
项目:javafx-demos    文件:ScrollPaneDisplacementDemo.java   
private Node getBottom() {
    StackPane sp = new StackPane();
    sp.setMinHeight(25);
    sp.setAlignment(Pos.TOP_RIGHT);
    Circle c = CircleBuilder.create().fill(Color.RED).translateX(-5).translateY(3).radius(8).cursor(Cursor.HAND).build();
    c.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent paramT) {
            ScenicView.show(scene);
        }
    });
    sp.getChildren().addAll(new Separator(), c);
    return sp;
}
项目:javafx-demos    文件:DisplacementMapBannerDemo.java   
private Node getBottom() {
    StackPane sp = new StackPane();
    sp.setMinHeight(25);
    sp.setAlignment(Pos.TOP_RIGHT);
    Circle c = CircleBuilder.create().fill(Color.RED).translateX(-5).translateY(3).radius(8).cursor(Cursor.HAND).build();
    c.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent paramT) {
            ScenicView.show(scene);
        }
    });
    sp.getChildren().addAll(new Separator(), c);
    return sp;
}
项目:javafx-demos    文件:DisplacementMapDemo.java   
private Node getBottom() {
    StackPane sp = new StackPane();
    sp.setMinHeight(25);
    sp.setAlignment(Pos.TOP_RIGHT);
    Circle c = CircleBuilder.create().fill(Color.RED).translateX(-5).translateY(3).radius(8).cursor(Cursor.HAND).build();
    c.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent paramT) {
            ScenicView.show(scene);
        }
    });
    sp.getChildren().addAll(new Separator(), c);
    return sp;
}
项目:javafx-demos    文件:DynamicTextAreaDemo.java   
private Node getBottom() {
    StackPane sp = new StackPane();
    sp.setMinHeight(25);
    sp.setAlignment(Pos.TOP_RIGHT);
    Circle c = CircleBuilder.create().fill(Color.RED).translateX(-5).translateY(3).radius(8).cursor(Cursor.HAND).build();
    c.setOnMouseClicked(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent paramT) {
            ScenicView.show(scene);
        }
    });
    sp.getChildren().addAll(new Separator(), c);
    return sp;
}
项目:Fishification    文件:FoodItemEntity.java   
private Circle createFoodCircle(double radius) {
    CircleBuilder<?> circleBuilder = CircleBuilder.create();
    circleBuilder.radius(radius);
    circleBuilder.cache(true);
    Circle sphere = circleBuilder.build();
    sphere.setOpacity(FOOD_OPACITY);

    RadialGradientBuilder gradientBuilder = RadialGradientBuilder.create();
    gradientBuilder.centerX(sphere.getCenterX() - sphere.getRadius() / 3);
    gradientBuilder.centerY(sphere.getCenterY() - sphere.getRadius() / 3);
    gradientBuilder.radius(sphere.getRadius());
    gradientBuilder.proportional(false);

    if (m_foodSource.equalsIgnoreCase("twitter")) {
        gradientBuilder.stops(new Stop(0.0, Color.LIGHTCYAN), new Stop(1.0, Color.DARKCYAN));
    } else if (m_foodSource.equalsIgnoreCase("sociotech")) {
        gradientBuilder.stops(new Stop(0.0, Color.GRAY), new Stop(1.0, Color.DARKGRAY));
    } else if (m_foodSource.equalsIgnoreCase("cscm")) {
        gradientBuilder.stops(new Stop(0.4, Color.ORANGE), new Stop(1.0, Color.BLACK));
    } else if (m_foodSource.equalsIgnoreCase("unibwm")) {
        gradientBuilder.stops(new Stop(0.0, Color.DARKORANGE), new Stop(1.0, Color.BLACK));
    } else if (m_foodSource.equalsIgnoreCase("mendeley")) {
        gradientBuilder.stops(new Stop(0.0, Color.RED), new Stop(1.0, Color.BLACK));
    } else if (m_foodSource.equalsIgnoreCase("studiendekan")) {
        gradientBuilder.stops(new Stop(0.0, Color.SANDYBROWN), new Stop(1.0, Color.BLACK));
    } else {
        gradientBuilder.stops(new Stop(0.0, Color.YELLOW), new Stop(1.0, Color.BLACK));
    }
    RadialGradient gradient = gradientBuilder.build();

    sphere.setFill(gradient);
    return sphere;
}
项目:JavaFXTutorials    文件:PositioningNodesAbsolutely.java   
@Override
public void start(Stage stage) throws Exception {
    // Create a pane as the scene root
    Pane root = new Pane();

    // position a rectangle absolutely
    // NOTE: A rectangle is drawn from the upper left hand corner
    Rectangle r = RectangleBuilder.create()
            .x(100) // absolute position in container
            .y(100) // absolute position in container
            .fill(Color.AQUA)
            .width(50)
            .height(50)
            .build();

    // NOTE: A circle is drawn from the center
    Circle c = CircleBuilder.create()
            .centerX(200)
            .centerY(200)
            .radius(50)
            .fill(Color.ORANGERED)
            .build();

    root.getChildren().addAll(r,c);

    Scene scene = new Scene(root, 400, 400);
    stage.setScene(scene);
    stage.setTitle("Position Nodes Aboslutely");
    stage.show();

    ScenicView.show(scene);
    /*
     * If you inspect the rectangle and circle with SceniceView, you'll
     * that they don't have a layoutX/Y. When you position nodes absolutely
     * layoutX/Y is never set. This isn't a problem, just be aware that it 
     * happens. It can effect the way you do custom layouts.
     */
}
项目: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);
    }
}
项目:ewidgetfx    文件:Abacus_6_Styled.java   
private Circle makeCircle(int y, int x) {
    final Circle ball = CircleBuilder.create().radius(RADIUS - 1).centerX(x).centerY(y).build();
    ball.setOnMouseClicked((MouseEvent mouseEvent) -> {
        double newX = MOVE_WAY;
        if (ball.getTranslateX() > 1) {
            newX = 0;
        }
        TranslateTransition move = TranslateTransitionBuilder.create().node(ball).toX(newX).duration(millis(200)).build();
        move.playFromStart();
    });
    return ball;
}
项目: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();
}
项目: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);

   }
项目:JavaFXTutorials    文件:PositioningNodesWithRelocate.java   
@Override
public void start(Stage stage) throws Exception {
    // Create a pane as the scene root
    Pane root = new Pane();

    // position a rectangle absolutely
    // NOTE: A rectangle is drawn from the upper left hand corner
    Rectangle r = RectangleBuilder.create()
            .x(0) // absolute position in container
            .y(0) // absolute position in container
            .fill(Color.AQUA)
            .width(50)
            .height(50)
            .build();
    r.relocate(100, 100);

    // NOTE: A circle is drawn from the center
    Circle c = CircleBuilder.create()
            .centerX(0)
            .centerY(0)
            .radius(50)
            .fill(Color.ORANGERED)
            .build();
    c.relocate(200, 200);

    root.getChildren().addAll(r,c);

    Scene scene = new Scene(root, 400, 400);
    stage.setScene(scene);
    stage.setTitle("Position Nodes With Relocate");
    stage.show();

    ScenicView.show(scene);
    /*
     * This approach treats the shape as its own coordinate system and uses
     * layoutX/Y to position the nodes.
     * 
     * Check layoutX/Y for the circle. Notice anything strange? It's position
     * says it is 250, 250. What?! Remember that when you use relocate(x, y)
     * it does the calculation finalX - getLayoutBounds().getMinX().
     * Because a circle is drawn from the center it's layout bounds are
     * [-50, -50, 100, 100]. 200 - -50 is 250. If you want to know the
     * position of the circle in the parent container, use 
     * boundsInParent.getMinX/Y(). This also works for rectangles.
     */
}
项目:JavaFXTutorials    文件:PositioningObjectsInGroups.java   
@Override
public void start(Stage stage) throws Exception {
    // Create a pane as the scene root
    Pane root = new Pane();

    // position a rectangle absolutely
    // NOTE: A rectangle is drawn from the upper left hand corner
    Rectangle r = RectangleBuilder.create()
            .x(0) // absolute position in container
            .y(0) // absolute position in container
            .fill(Color.AQUA)
            .width(50)
            .height(50)
            .build();
    r.relocate(100, 100);

    // NOTE: A circle is drawn from the center
    Circle c = CircleBuilder.create()
            .centerX(0)
            .centerY(0)
            .radius(50)
            .fill(Color.ORANGERED)
            .build();
    c.relocate(200, 200);

    Group g = new Group(r, c);
    g.relocate(0, 0); // add/remove this line to see the effect of relocate 
    root.getChildren().add(g);


    Scene scene = new Scene(root, 400, 400);
    stage.setScene(scene);
    stage.setTitle("Position Nodes With Relocate");
    stage.show();

    ScenicView.show(scene);

    /*
     *By default the bounds of the Group will be the sum of it's children's
     *bounds. If we don't set it's position with relocate, we'll need to use
     *BoundsInParent.getMinX/Y() to get it's position. 
     *
     *Notice also that if we don't call g.relocate() the circles and rectangles
     *positions appear to be with respect to the Pane's coordinate system. That is 
     *the Group is just wrapping the rectangle and circle. The only way we
     *can treat a Group like a coordinate system is use relocate to position
     *it. Then it behaves as we might expect.
     */

}