List of usage examples for javafx.scene.shape Circle getCenterX
public final double getCenterX()
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.getCenterX()); final Group root = new Group(circ); final Scene scene = new Scene(root, 400, 300); primaryStage.setScene(scene);/* www . j a v a 2 s. c om*/ primaryStage.show(); }
From source file:Main.java
private Circle createCircle(double x, double y, double r, Color color) { Circle circle = new Circle(x, y, r, color); circle.setCursor(Cursor.HAND); circle.setOnMousePressed((t) -> { orgSceneX = t.getSceneX();/*from w ww . ja v a 2s. c om*/ orgSceneY = t.getSceneY(); Circle c = (Circle) (t.getSource()); c.toFront(); }); circle.setOnMouseDragged((t) -> { double offsetX = t.getSceneX() - orgSceneX; double offsetY = t.getSceneY() - orgSceneY; Circle c = (Circle) (t.getSource()); c.setCenterX(c.getCenterX() + offsetX); c.setCenterY(c.getCenterY() + offsetY); orgSceneX = t.getSceneX(); orgSceneY = t.getSceneY(); }); return circle; }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param iNumZone numro de la zone/* w ww.jav a 2 s . co 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; }