public EllipseResizer(Ellipse sceneGraphObject) {
   super(sceneGraphObject);
   originalRadiusX = sceneGraphObject.getRadiusX();
   originalRadiusY = sceneGraphObject.getRadiusY();
   propertyNames.add(radiusXName);
   propertyNames.add(radiusYName);
 }
 private void initializeCeiling(BorderPane root) {
   ceiling = new Ellipse();
   ceiling.centerXProperty().bind(root.widthProperty().multiply(0.35));
   ceiling.centerYProperty().bind(root.heightProperty().multiply(0.1));
   ceiling.radiusXProperty().bind(root.widthProperty().multiply(0.5));
   ceiling.radiusYProperty().bind(root.heightProperty().multiply(0.25));
 }
  @Override
  public void start(Stage primaryStage) {
    ImageView us = new ImageView(new Image("File:C:/Java/site/image/us.gif"));
    Label lb1 = new Label("US\n50 States", us);
    lb1.setStyle("-fx-border-color: green; -fx-border-width: 2");
    lb1.setContentDisplay(ContentDisplay.BOTTOM);
    lb1.setTextFill(Color.RED);

    Label lb2 = new Label("Circle", new Circle(50, 50, 25));
    lb2.setContentDisplay(ContentDisplay.TOP);
    lb2.setTextFill(Color.ORANGE);

    Label lb3 = new Label("Rectangle", new Rectangle(10, 10, 50, 25));
    lb3.setContentDisplay(ContentDisplay.RIGHT);

    Label lb4 = new Label("Ellipse", new Ellipse(50, 50, 50, 25));
    lb4.setContentDisplay(ContentDisplay.LEFT);

    Ellipse ellipse = new Ellipse(50, 50, 50, 25);
    ellipse.setStroke(Color.GREEN);
    ellipse.setFill(Color.WHITE);
    StackPane stackPane = new StackPane();

    stackPane.getChildren().addAll(ellipse, new Label("JavaFX"));
    Label lb5 = new Label("A pane inside a label", stackPane);
    lb5.setContentDisplay(ContentDisplay.BOTTOM);

    HBox pane = new HBox(20);
    pane.getChildren().addAll(lb1, lb2, lb3, lb4, lb5);

    Scene scene = new Scene(pane, 700, 150);
    primaryStage.setTitle("LabelWithGraphic");
    primaryStage.setScene(scene);
    primaryStage.show();
  }
Esempio n. 4
0
 private static void write(Ellipse ellipse, Writer writer) throws IOException {
   writer.write(
       String.format(
           "<ellipse cx=\"%f\" cy=\"%f\" rx=\"%f\" ry=\"%f\" />\n",
           ellipse.getCenterX(),
           ellipse.getCenterY(),
           ellipse.getRadiusX(),
           ellipse.getRadiusY()));
 }
  /**
   * Determines the radial line segment at angles evenly subdivided by a preset number of stitches.
   *
   * @param ellipse Ellipse
   * @param lineList List&lt;Line&gt;
   */
  private void fillEllipse(Ellipse ellipse, List<Line> lineList) {
    double endX, endY, radius, degree, degreeInterval;
    Line radialLine;

    degreeInterval = 360 / NUM_STITCHES;
    degree = 0;
    for (int i = 0; i < NUM_STITCHES; i++) {
      radius = EmbMath.getEllipseRadiusDeg(ellipse, degree);

      endX = ellipse.getCenterX() + (radius * Math.cos(Math.toRadians(degree)));
      endY = ellipse.getCenterY() + (radius * Math.sin(Math.toRadians(degree)));
      radialLine = new Line(ellipse.getCenterX(), ellipse.getCenterY(), endX, endY);

      lineList.add(radialLine);
      degree += degreeInterval;
    }
  }
Esempio n. 6
0
    private void configureBackground() {
      ImageView imageView = new ImageView();
      Image image = loadImage();
      imageView.setImage(image);

      Circle circle1 = new Circle();
      circle1.setCenterX(140);
      circle1.setCenterY(140);
      circle1.setRadius(120);
      circle1.setFill(Color.TRANSPARENT);
      circle1.setStroke(Color.web("#0A0A0A"));
      circle1.setStrokeWidth(0.3);

      Circle circle2 = new Circle();
      circle2.setCenterX(140);
      circle2.setCenterY(140);
      circle2.setRadius(118);
      circle2.setFill(Color.TRANSPARENT);
      circle2.setStroke(Color.web("#0A0A0A"));
      circle2.setStrokeWidth(0.3);

      Circle circle3 = new Circle();
      circle3.setCenterX(140);
      circle3.setCenterY(140);
      circle3.setRadius(140);
      circle3.setFill(Color.TRANSPARENT);
      circle3.setStroke(Color.web("#818a89"));
      circle3.setStrokeWidth(1);

      Ellipse ellipse = new Ellipse(140, 95, 180, 95);
      Circle ellipseClip = new Circle(140, 140, 140);
      ellipse.setFill(Color.web("#535450"));
      ellipse.setStrokeWidth(0);
      GaussianBlur ellipseEffect = new GaussianBlur();
      ellipseEffect.setRadius(10);
      ellipse.setEffect(ellipseEffect);
      ellipse.setOpacity(0.1);
      ellipse.setClip(ellipseClip);
      background.getChildren().addAll(imageView, circle1, circle2, circle3, ellipse);
    }