List of usage examples for javafx.collections FXCollections observableArrayList
@SuppressWarnings("unchecked") public static <E> ObservableList<E> observableArrayList()
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param iNumZone numro de la zone//from w w w .j a v a 2s . co m * @param points liste de points du polygone * @return ancres du polygone */ private static ObservableList<AncreForme> olCreeAncresPourPolygone(int iNumZone, final ObservableList<Double> points) { ObservableList<AncreForme> olAnchors = FXCollections.observableArrayList(); for (int i = 0; i < points.size(); i += 2) { final int idx = i; DoubleProperty xProperty = new SimpleDoubleProperty(points.get(i)); DoubleProperty yProperty = new SimpleDoubleProperty(points.get(i + 1)); xProperty.addListener((ObservableValue<? extends Number> ov, Number oldX, Number x) -> { points.set(idx, (double) x); String chaine = ""; chaine = points.stream().map((point) -> point.toString() + ",").reduce(chaine, String::concat); chaine = chaine.substring(0, chaine.length() - 1); zones[iNumZone].setStrCoordonneesZone(chaine); }); yProperty.addListener((ObservableValue<? extends Number> ov, Number oldY, Number y) -> { points.set(idx + 1, (double) y); String chaine = ""; chaine = points.stream().map((point) -> point.toString() + ",").reduce(chaine, String::concat); chaine = chaine.substring(0, chaine.length() - 1); zones[iNumZone].setStrCoordonneesZone(chaine); }); olAnchors.add(new AncreForme(Color.GOLD, xProperty, yProperty)); } return olAnchors; }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param iNumZone numro de la zone/*from w w w . j a v a 2 s. c om*/ * @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; }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param iNumZone numero de la zone//w ww .jav a2 s. c o m * @param rect rectangle concern * @return ancres rectangle */ private static ObservableList<AncreForme> olCreeAncresPourRectangle(int iNumZone, Rectangle rect) { ObservableList<AncreForme> olAnchors = FXCollections.observableArrayList(); DoubleProperty xProperty1 = new SimpleDoubleProperty(rect.getX()); DoubleProperty yProperty1 = new SimpleDoubleProperty(rect.getY()); DoubleProperty xProperty2 = new SimpleDoubleProperty(rect.getWidth() + rect.getX()); DoubleProperty yProperty2 = new SimpleDoubleProperty(rect.getHeight() + rect.getY()); olAnchors.add(new AncreForme(Color.GOLD, xProperty1, yProperty1)); AncreForme ancrePoint2 = new AncreForme(Color.BLUEVIOLET, xProperty2, yProperty2); olAnchors.add(ancrePoint2); xProperty1.addListener((ObservableValue<? extends Number> ov, Number oldX, Number x) -> { double dX = -rect.getX() + (double) x; rect.setX((double) x); ancrePoint2.setCenterX(ancrePoint2.getCenterX() + dX); String chaine = Math.round(rect.getX() * 10) / 10 + "," + Math.round(rect.getY() * 10) / 10 + "," + Math.round((rect.getX() + rect.getWidth()) * 10) / 10 + "," + Math.round((rect.getY() + rect.getHeight()) * 10) / 10; zones[iNumZone].setStrCoordonneesZone(chaine); }); yProperty1.addListener((ObservableValue<? extends Number> ov, Number oldY, Number y) -> { double dY = -rect.getY() + (double) y; rect.setY((double) y); ancrePoint2.setCenterY(ancrePoint2.getCenterY() + dY); String chaine = Math.round(rect.getX() * 10) / 10 + "," + Math.round(rect.getY() * 10) / 10 + "," + Math.round((rect.getX() + rect.getWidth()) * 10) / 10 + "," + Math.round((rect.getY() + rect.getHeight()) * 10) / 10; zones[iNumZone].setStrCoordonneesZone(chaine); }); xProperty2.addListener((ObservableValue<? extends Number> ov, Number oldX, Number x) -> { rect.setWidth((double) x - rect.getX()); String chaine = Math.round(rect.getX() * 10) / 10 + "," + Math.round(rect.getY() * 10) / 10 + "," + Math.round((rect.getX() + rect.getWidth()) * 10) / 10 + "," + Math.round((rect.getY() + rect.getHeight()) * 10) / 10; zones[iNumZone].setStrCoordonneesZone(chaine); }); yProperty2.addListener((ObservableValue<? extends Number> ov, Number oldY, Number y) -> { rect.setHeight((double) y - rect.getY()); String chaine = Math.round(rect.getX() * 10) / 10 + "," + Math.round(rect.getY() * 10) / 10 + "," + Math.round((rect.getX() + rect.getWidth()) * 10) / 10 + "," + Math.round((rect.getY() + rect.getHeight()) * 10) / 10; zones[iNumZone].setStrCoordonneesZone(chaine); }); return olAnchors; }