Example usage for javafx.scene.shape Circle getRadius

List of usage examples for javafx.scene.shape Circle getRadius

Introduction

In this page you can find the example usage for javafx.scene.shape Circle getRadius.

Prototype

public final double getRadius() 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Title");

    final Circle circ = new Circle(40, Color.RED);

    System.out.println(circ.getRadius());

    final Group root = new Group(circ);
    final Scene scene = new Scene(root, 400, 300);

    primaryStage.setScene(scene);/*from www . ja v  a  2  s . c  o m*/
    primaryStage.show();
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param iNumZone numro de la zone/*w  w w. j  a va 2 s .  c  o  m*/
 * @param cercle cercle concern
 * @return ancres cercles
 */
private static ObservableList<AncreForme> olCreeAncresPourCercle(int iNumZone, Circle cercle) {
    ObservableList<AncreForme> olAnchors = FXCollections.observableArrayList();

    DoubleProperty xProperty1 = new SimpleDoubleProperty(cercle.getCenterX());
    DoubleProperty yProperty1 = new SimpleDoubleProperty(cercle.getCenterY());
    olAnchors.add(new AncreForme(Color.GOLD, xProperty1, yProperty1));
    DoubleProperty xProperty2 = new SimpleDoubleProperty(cercle.getCenterX() + cercle.getRadius());
    DoubleProperty yProperty2 = new SimpleDoubleProperty(cercle.getCenterY());
    final AncreForme ancRayon = new AncreForme(Color.BLUEVIOLET, xProperty2, yProperty2);
    olAnchors.add(ancRayon);
    xProperty1.addListener((ObservableValue<? extends Number> ov, Number oldX, Number x) -> {
        double dX = (double) x - cercle.getCenterX();
        double rayon = Math.sqrt(Math.pow(cercle.getCenterX() - xProperty2.get(), 2.d)
                + Math.pow(cercle.getCenterY() - yProperty2.get(), 2.d));
        cercle.setCenterX((double) x);
        ancRayon.setCenterX(ancRayon.getCenterX() + dX);
        String chaine = Math.round(cercle.getCenterX() * 10) / 10 + ","
                + Math.round(cercle.getCenterY() * 10) / 10 + "," + Math.round(rayon * 10) / 10;
        zones[iNumZone].setStrCoordonneesZone(chaine);

    });

    yProperty1.addListener((ObservableValue<? extends Number> ov, Number oldY, Number y) -> {
        double dY = -cercle.getCenterY() + (double) y;
        double rayon = Math.sqrt(Math.pow(cercle.getCenterX() - xProperty2.get(), 2.d)
                + Math.pow(cercle.getCenterY() - yProperty2.get(), 2.d));
        cercle.setCenterY((double) y);
        ancRayon.setCenterY(ancRayon.getCenterY() + dY);
        String chaine = Math.round(cercle.getCenterX() * 10) / 10 + ","
                + Math.round(cercle.getCenterY() * 10) / 10 + "," + Math.round(rayon * 10) / 10;
        zones[iNumZone].setStrCoordonneesZone(chaine);
    });
    xProperty2.addListener((ObservableValue<? extends Number> ov, Number oldX, Number x) -> {
        double rayon = Math.sqrt(Math.pow(cercle.getCenterX() - (double) x, 2.d)
                + Math.pow(cercle.getCenterY() - yProperty2.get(), 2.d));
        cercle.setRadius(rayon);
        String chaine = Math.round(cercle.getCenterX() * 10) / 10 + ","
                + Math.round(cercle.getCenterY() * 10) / 10 + "," + Math.round(rayon * 10) / 10;
        zones[iNumZone].setStrCoordonneesZone(chaine);
    });

    yProperty2.addListener((ObservableValue<? extends Number> ov, Number oldY, Number y) -> {
        double rayon = Math.sqrt(Math.pow(cercle.getCenterX() - xProperty2.get(), 2.d)
                + Math.pow(cercle.getCenterY() - (double) y, 2.d));
        cercle.setRadius(rayon);
        String chaine = Math.round(cercle.getCenterX() * 10) / 10 + ","
                + Math.round(cercle.getCenterY() * 10) / 10 + "," + Math.round(rayon * 10) / 10;
        zones[iNumZone].setStrCoordonneesZone(chaine);
    });

    return olAnchors;
}