List of usage examples for javafx.beans.property SimpleDoubleProperty SimpleDoubleProperty
public SimpleDoubleProperty(double initialValue)
From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java
private void showImage(File file) { try {//from w w w. j av a 2s .c om ImageView iv = new ImageView(new Image(file.toURI().toURL().toString())); iv.setPreserveRatio(true); Stage stage = new Stage(); final DoubleProperty zoomProperty = new SimpleDoubleProperty(200); zoomProperty.addListener(new InvalidationListener() { @Override public void invalidated(javafx.beans.Observable observable) { iv.setFitWidth(zoomProperty.get() * 4); iv.setFitHeight(zoomProperty.get() * 3); } }); ScrollPane sp = new ScrollPane(iv); stage.addEventFilter(ScrollEvent.ANY, new EventHandler<ScrollEvent>() { @Override public void handle(ScrollEvent event) { if (event.getDeltaY() > 0) { zoomProperty.set(zoomProperty.get() * 1.1); } else if (event.getDeltaY() < 0) { zoomProperty.set(zoomProperty.get() / 1.1); } } }); stage.setScene(new Scene(new Group(sp))); stage.sizeToScene(); stage.show(); } catch (IOException ex) { showErrorDialog(ex); } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param iNumZone numro de la zone/*from w w w .j a v a2 s . 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 2s.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; }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param iNumZone numero de la zone/*from w ww . ja v a2 s . com*/ * @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; }
From source file:org.mskcc.shenkers.view.IntervalViewNGTest.java
@Test public void testGenericStackedIntervalView() throws InterruptedException { List<Pair<Integer, Integer>> intervals = Arrays.asList(new Pair(0, 1), new Pair(1, 2), new Pair(2, 3), new Pair(3, 4), new Pair(4, 5), new Pair(5, 6)); List<Pane> nodes = intervals.stream().map(i -> new RectangleIntervalNode()).collect(Collectors.toList()); GenericStackedIntervalView p = new GenericStackedIntervalView(0, 6); p.setData(intervals, nodes);// w w w. java 2 s. c om ScrollPane sp = new ScrollPane(p); ScrollBar sb = new ScrollBar(); sb.maxProperty().bind(sp.vmaxProperty()); sb.minProperty().bind(sp.vminProperty()); sb.visibleAmountProperty().bind(sp.heightProperty().divide(p.prefHeightProperty())); sb.setOrientation(Orientation.VERTICAL); sp.vvalueProperty().bindBidirectional(sb.valueProperty()); HiddenSidesPane hsp = new HiddenSidesPane(); hsp.setContent(sp); hsp.setRight(sb); sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); p.setOrientation(Orientation.VERTICAL); p.prefTileHeightProperty().bind(new SimpleDoubleProperty(40)); // p.minHeightProperty().bind(new SimpleDoubleProperty(20).multiply(Bindings.size(p.getChildren()))); p.prefTileWidthProperty().bind(sp.widthProperty()); p.prefHeightProperty() .bind(new SimpleDoubleProperty(50).multiply(Bindings.size(p.getChildren())).subtract(10)); p.prefWidthProperty().bind(sp.widthProperty()); sp.setPadding(Insets.EMPTY); p.setVgap(10); CountDownLatch l = new CountDownLatch(1); Platform.runLater(() -> { Stage stage = new Stage(); stage.setOnHidden(e -> { l.countDown(); }); Scene scene = new Scene(hsp, 300, 300, Color.GRAY); stage.setTitle("GenericStackedPaneTest"); stage.setScene(scene); stage.show(); }); l.await(); }
From source file:org.mskcc.shenkers.view.IntervalViewNGTest.java
public void testStackedIntervalView() throws InterruptedException { StackedIntervalView p = new StackedIntervalView(0, 6); p.setData(Arrays.asList(new Pair(0, 1), new Pair(1, 2), new Pair(2, 3), new Pair(3, 4), new Pair(4, 5), new Pair(5, 6) //, {8, 10}, {1, 2}, {3, 7}, // {9, 10}, {1, 2}, {3, 5}, {6, 7}, {8, 10}, {2, 5}, {8, 10} ));/* www . j a v a 2 s. co m*/ ScrollPane sp = new ScrollPane(p); ScrollBar sb = new ScrollBar(); sb.maxProperty().bind(sp.vmaxProperty()); sb.minProperty().bind(sp.vminProperty()); sb.visibleAmountProperty().bind(sp.heightProperty().divide(p.prefHeightProperty())); sb.setOrientation(Orientation.VERTICAL); sp.vvalueProperty().bindBidirectional(sb.valueProperty()); HiddenSidesPane hsp = new HiddenSidesPane(); hsp.setContent(sp); hsp.setRight(sb); sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); p.setOrientation(Orientation.VERTICAL); p.prefTileHeightProperty().bind(new SimpleDoubleProperty(40)); // p.minHeightProperty().bind(new SimpleDoubleProperty(20).multiply(Bindings.size(p.getChildren()))); p.prefTileWidthProperty().bind(sp.widthProperty()); p.prefHeightProperty() .bind(new SimpleDoubleProperty(50).multiply(Bindings.size(p.getChildren())).subtract(10)); p.prefWidthProperty().bind(sp.widthProperty()); sp.setPadding(Insets.EMPTY); p.setVgap(10); CountDownLatch l = new CountDownLatch(1); Platform.runLater(() -> { Stage stage = new Stage(); stage.setOnHidden(e -> { l.countDown(); }); Scene scene = new Scene(hsp, 300, 300, Color.GRAY); stage.setTitle("StackedPaneTest"); stage.setScene(scene); stage.show(); }); l.await(); }
From source file:org.mskcc.shenkers.view.IntervalViewNGTest.java
public void testStackIntervalView() throws InterruptedException { System.out.println("testStackIntervalView"); int[][] d = new int[][] { { 2, 6 }, { 7, 10 }, { 1, 3 }, { 4, 6 }, { 8, 10 }, { 1, 2 }, { 3, 7 }, { 9, 10 }, { 1, 2 }, { 3, 5 }, { 6, 7 }, { 8, 10 }, { 2, 5 }, { 8, 10 } }; List<int[]> asList = Arrays.asList(d); Collections.sort(asList, new Comparator<int[]>() { @Override//from w w w .j av a 2 s. co m public int compare(int[] o1, int[] o2) { return o1[0] - o2[0]; } }); List<TreeRangeSet<Integer>> rows = new ArrayList<>(); rows.add(TreeRangeSet.create()); for (int[] r : d) { Range<Integer> R = Range.closed(r[0], r[1]); int i = 0; added: { while (i < rows.size()) { TreeRangeSet<Integer> set = rows.get(i); RangeSet<Integer> intersection = set.subRangeSet(Range.closed(r[0] - 1, r[1] + 1)); if (intersection.isEmpty()) { set.add(R); break added; } i++; } // Stri i = ; TreeRangeSet<Integer> row = TreeRangeSet.create(); row.add(R); rows.add(row); } } TilePane p = new TilePane(); p.setSnapToPixel(false); for (int i = 0; i < rows.size(); i++) { p.getChildren().add(get(rows.get(i), 0, 11)); System.out.println(rows.get(i).toString()); StringBuilder sb = new StringBuilder(11); sb.append(StringUtils.repeat(".", 11)); for (int j = 0; j < 11; j++) { if (rows.get(i).contains(j)) { sb.setCharAt(j, 'X'); } } System.out.println(sb.toString()); } // p.prefWidth(100); // p.prefHeight(100); ScrollPane sp = new ScrollPane(p); ScrollBar sb = new ScrollBar(); sb.maxProperty().bind(sp.vmaxProperty()); sb.minProperty().bind(sp.vminProperty()); sb.visibleAmountProperty().bind(sp.heightProperty().divide(p.prefHeightProperty())); sb.setOrientation(Orientation.VERTICAL); sp.vvalueProperty().bindBidirectional(sb.valueProperty()); HiddenSidesPane hsp = new HiddenSidesPane(); hsp.setContent(sp); hsp.setRight(sb); sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); p.setOrientation(Orientation.VERTICAL); p.prefTileHeightProperty().bind(new SimpleDoubleProperty(40)); // p.minHeightProperty().bind(new SimpleDoubleProperty(20).multiply(Bindings.size(p.getChildren()))); p.prefTileWidthProperty().bind(sp.widthProperty()); p.prefHeightProperty() .bind(new SimpleDoubleProperty(50).multiply(Bindings.size(p.getChildren())).subtract(10)); p.prefWidthProperty().bind(sp.widthProperty()); sp.setPadding(Insets.EMPTY); p.setVgap(10); CountDownLatch l = new CountDownLatch(1); Platform.runLater(() -> { Stage stage = new Stage(); stage.setOnHidden(e -> { l.countDown(); }); Scene scene = new Scene(hsp, 300, 300, Color.GRAY); stage.setTitle("JavaFX Scene Graph Demo"); stage.setScene(scene); stage.show(); }); l.await(); }
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
private void refreshTableData() { // int nn = 0; // double nPositive = 0; // for (TMAEntry entry : entriesBase) { // if (entry.isMissing()) // continue; // nPositive += entry.getMeasurementAsDouble("Num Positive"); // nn++; // }// w w w . j ava2 s .c om // System.err.println(nPositive + " positive cells across " + nn + " tissue samples"); Collection<? extends TMAEntry> entries = groupByIDProperty.get() ? createSummaryEntries(entriesBase) : entriesBase; // Ensure that we don't try to modify a filtered list List<TreeTableColumn<TMAEntry, ?>> columns = new ArrayList<>(); // Add an empty column. // Its purpose is to provide the space needed for the little expansion arrows, to avoid // these stealing space from the first interesting column. // Note: there's nothing to prevent the user reordering it along with other columns... // but hopefully it looks 'right' enough where it is that few would try to do that TreeTableColumn<TMAEntry, String> columnEmpty = new TreeTableColumn<>(" "); columnEmpty .setCellValueFactory(new Callback<CellDataFeatures<TMAEntry, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<TMAEntry, String> p) { return Bindings.createStringBinding(() -> ""); } }); columnEmpty.setSortable(false); columnEmpty.setResizable(false); columns.add(columnEmpty); // Check if we have any images or overlays boolean hasImages = entries.stream().anyMatch(e -> e.hasImage()); boolean hasOverlay = entries.stream().anyMatch(e -> e.hasOverlay()); // Add columns to show images, if we have them if (hasImages || hasOverlay) { TreeTableColumn<TMAEntry, TMAEntry> columnImage = hasImages ? new TreeTableColumn<>("Thumbnail") : null; TreeTableColumn<TMAEntry, TMAEntry> columnOverlay = hasOverlay ? new TreeTableColumn<>("Overlay") : null; if (hasImages) { columnImage.setCellValueFactory( new Callback<CellDataFeatures<TMAEntry, TMAEntry>, ObservableValue<TMAEntry>>() { @Override public ObservableValue<TMAEntry> call(CellDataFeatures<TMAEntry, TMAEntry> p) { return p.getValue().valueProperty(); } }); columnImage.setCellFactory(c -> new ImageTableCell(imageCache, false)); columnImage.maxWidthProperty().bind(maxSmallWidth); columnImage.widthProperty().addListener((v, o, n) -> { if (n.doubleValue() == columnImage.getPrefWidth()) return; if (hasOverlay) columnOverlay.setPrefWidth(n.doubleValue()); table.refresh(); }); columns.add(columnImage); } if (hasOverlay) { columnOverlay.setCellValueFactory( new Callback<CellDataFeatures<TMAEntry, TMAEntry>, ObservableValue<TMAEntry>>() { @Override public ObservableValue<TMAEntry> call(CellDataFeatures<TMAEntry, TMAEntry> p) { return p.getValue().valueProperty(); } }); columnOverlay.setCellFactory(c -> new ImageTableCell(imageCache, true)); columnOverlay.maxWidthProperty().bind(maxSmallWidth); columnOverlay.widthProperty().addListener((v, o, n) -> { if (n.doubleValue() == columnOverlay.getPrefWidth()) return; columnImage.setPrefWidth(n.doubleValue()); if (hasImages) table.refresh(); }); columns.add(columnOverlay); } } // Update image availability if (hasImages) { if (hasOverlay) imageAvailability.set(ImageAvailability.BOTH); else imageAvailability.set(ImageAvailability.IMAGE_ONLY); } else if (hasOverlay) { imageAvailability.set(ImageAvailability.OVERLAY_ONLY); } else imageAvailability.set(ImageAvailability.NONE); for (String name : model.getAllNames()) { if (model.getMeasurementNames().contains(name)) { TreeTableColumn<TMAEntry, Number> column = new TreeTableColumn<>(name); column.setCellValueFactory( new Callback<CellDataFeatures<TMAEntry, Number>, ObservableValue<Number>>() { @Override public ObservableValue<Number> call(CellDataFeatures<TMAEntry, Number> p) { double value = p.getValue() == null ? Double.NaN : model.getNumericValue(p.getValue().getValue(), name); return new SimpleDoubleProperty(value); } }); column.setCellFactory(c -> new NumericTableCell<>()); columns.add(column); } else { TreeTableColumn<TMAEntry, Object> column = new TreeTableColumn<>(name); column.setCellValueFactory( new Callback<CellDataFeatures<TMAEntry, Object>, ObservableValue<Object>>() { @Override public ObservableValue<Object> call(CellDataFeatures<TMAEntry, Object> p) { return new SimpleObjectProperty<>(p.getValue() == null ? null : model.getStringValue(p.getValue().getValue(), name)); } }); column.setCellFactory(c -> new BasicTableCell<>()); columns.add(column); } } // Set the column visibility depending upon whether they were hidden previously columns.stream().forEach(c -> c.setVisible(!lastHiddenColumns.contains(c.getText()))); // Set columns for table table.getColumns().setAll(columns); // Set new root for table TreeItem<TMAEntry> root = new RootTreeItem(entries, combinedPredicate); table.setShowRoot(false); table.setRoot(root); model.refreshList(); }