/** * will retrieve icons from the glyphs map for a certain glyphName * * @param glyphName the glyph name * @return SVGGlyph node */ public static SVGGlyph getIcoMoonGlyph(String glyphName) throws Exception{ SVGGlyphBuilder builder = glyphsMap.get(glyphName); if(builder == null) throw new Exception("Glyph '" + glyphName + "' not found!"); SVGGlyph glyph = builder.build(); // we need to apply transformation to correct the icon since // its being inverted after importing from icomoon glyph.getTransforms().add(new Scale(1, -1)); Translate height = new Translate(); height.yProperty().bind(Bindings.createDoubleBinding(() -> -glyph.getHeight(), glyph.heightProperty())); glyph.getTransforms().add(height); return glyph; }
final double curveTheta = 2 * curves.indexOf(curvedLine) * Math.PI / shapesNumber; curvedLine.controlX1Property().bind(Bindings.createDoubleBinding(() -> { final double a = firstCurve.getControlX1() - centerX; final double b = Math.sin(curveTheta) * (firstCurve.getControlY1() - centerY); }, firstCurve.controlX1Property(), firstCurve.controlY1Property())); curvedLine.controlY1Property().bind(Bindings.createDoubleBinding(() -> { final double a = Math.sin(curveTheta) * (firstCurve.getControlX1() - centerX); final double b = Math.cos(curveTheta) * (firstCurve.getControlY1() - centerY); curvedLine.controlX2Property().bind(Bindings.createDoubleBinding(() -> { final double a = firstCurve.getControlX2() - centerX; final double b = firstCurve.getControlY2() - centerY; }, firstCurve.controlX2Property(), firstCurve.controlY2Property())); curvedLine.controlY2Property().bind(Bindings.createDoubleBinding(() -> { final double a = Math.sin(curveTheta) * (firstCurve.getControlX2() - centerX); final double b = Math.cos(curveTheta) * (firstCurve.getControlY2() - centerY);
Region toggleNode = getToggleNode(); newVal.layoutXProperty() .bind(Bindings.createDoubleBinding(() -> toggleNode.getLayoutX() + toggleNode.getWidth() / 2, toggleNode.widthProperty(), toggleNode.layoutXProperty())); newVal.layoutYProperty() .bind(Bindings.createDoubleBinding(() -> toggleNode.getLayoutY() + toggleNode.getHeight() / 2, toggleNode.heightProperty(), toggleNode.layoutYProperty())); getClip().layoutYProperty().unbind(); getClip().layoutXProperty() .bind(Bindings.createDoubleBinding(() -> newVal.getLayoutX() + newVal.getWidth() / 2, newVal.widthProperty(), newVal.layoutXProperty())); getClip().layoutYProperty() .bind(Bindings.createDoubleBinding(() -> newVal.getLayoutY() + newVal.getHeight() / 2, newVal.heightProperty(), newVal.layoutYProperty()));
glyph.setSize(20, 20); button.setGraphic(glyph); button.translateYProperty().bind(Bindings.createDoubleBinding(() -> { return header.getBoundsInParent().getHeight() - button.getHeight() / 2; }, header.boundsInParentProperty(), button.heightProperty()));
actionContainer.setPadding(new Insets(0, 10, 0, 0)); toast.prefWidthProperty().bind(Bindings.createDoubleBinding(() -> { if (getPrefWidth() == -1) { return getPrefWidth();
private void initListeners() { initTranslateBinding = Bindings.createDoubleBinding(() -> -1 * directionProperty.get().doubleValue() * defaultSizeProperty.getValue() - initOffset * directionProperty.get().doubleValue(),
toggleAnimation.setOnFinished((finish) -> { if (toggleAnimation.getRate() == 1) { this.getClip().scaleXProperty().bind(Bindings.createDoubleBinding(() -> { double X = this.getWidth() / getClip().getLayoutBounds().getWidth(); double Y = this.getHeight() / getClip().getLayoutBounds().getHeight(); }, this.widthProperty(), this.heightProperty())); this.getClip().scaleYProperty().bind(Bindings.createDoubleBinding(() -> { double X = this.getWidth() / getClip().getLayoutBounds().getWidth(); double Y = this.getHeight() / getClip().getLayoutBounds().getHeight();
/** * Converts a double object observable value into a double binding. * * @param observable the observable to be converted. * * @return a double binding. */ @Nonnull public static DoubleBinding mapToDouble(@Nonnull final ObservableObjectValue<Double> observable) { requireNonNull(observable, ERROR_OBSERVABLE_NULL); return createDoubleBinding(observable::get, observable); }
/** * Creates a number binding that contains the sum of the items of the given observable list. * * @param items the observable list of items. * * @return a number binding. */ @Nonnull public static NumberBinding sumOfList(@Nonnull final ObservableList<? extends Number> items) { requireNonNull(items, ERROR_ITEMS_NULL); return createDoubleBinding(() -> items.stream().mapToDouble(Number::doubleValue).sum(), items); }
/** * Creates a number binding that contains the sum of the items of the given observable set. * * @param items the observable set of items. * * @return a number binding. */ @Nonnull public static NumberBinding sumOfSet(@Nonnull final ObservableSet<? extends Number> items) { requireNonNull(items, ERROR_ITEMS_NULL); return createDoubleBinding(() -> items.stream().mapToDouble(Number::doubleValue).sum(), items); }
/** * Creates a number binding that contains the sum of the values of the given observable map. * * @param items the observable map of items. * * @return a number binding. */ @Nonnull public static <K> NumberBinding sumOfMap(@Nonnull final ObservableMap<K, ? extends Number> items) { requireNonNull(items, ERROR_ITEMS_NULL); return createDoubleBinding(() -> items.values().stream().mapToDouble(Number::doubleValue).sum(), items); }
/** * Creates a number binding that contains the sum of the items of the given observable set. * * @param items the observable set of items. * @param mapper a non-interfering, stateless function to apply to the each element. * * @return a number binding. */ @Nonnull public static <T> NumberBinding sumOfSet(@Nonnull final ObservableSet<T> items, @Nonnull final ToDoubleFunction<? super T> mapper) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(mapper, ERROR_MAPPER_NULL); return createDoubleBinding(() -> items.stream().mapToDouble(mapper).sum(), items); }
@Nonnull public static DoubleBinding microMeter2mm(@Nonnull DoubleProperty doubleProperty) { return Bindings.createDoubleBinding(() -> microMeter2mm(doubleProperty.get()), doubleProperty); }
/** * Creates a number binding that computes the maximum value amongst elements. * * @param items the observable set of items. * @param defaultValue the value to be returned if there is no value present. * * @return a number binding */ @Nonnull public static NumberBinding maxInSet(@Nonnull final ObservableSet<? extends Number> items, @Nonnull final Number defaultValue) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(defaultValue, ERROR_DEFAULT_VALUE_NULL); return createDoubleBinding(() -> items.stream().mapToDouble(Number::doubleValue).max().orElse(defaultValue.doubleValue()), items); }
/** * Creates a number binding that computes the average value amongst elements. * * @param items the observable list of items. * @param defaultValue the value to be returned if there is no value present. * * @return a number binding */ @Nonnull public static NumberBinding averageInList(@Nonnull final ObservableList<? extends Number> items, @Nonnull final Number defaultValue) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(defaultValue, ERROR_DEFAULT_VALUE_NULL); return createDoubleBinding(() -> items.stream().mapToDouble(Number::doubleValue).average().orElse(defaultValue.doubleValue()), items); }
/** * Creates a number binding that computes the average value amongst elements. * * @param items the observable set of items. * @param defaultValue the value to be returned if there is no value present. * * @return a number binding */ @Nonnull public static NumberBinding averageInSet(@Nonnull final ObservableSet<? extends Number> items, @Nonnull final Number defaultValue) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(defaultValue, ERROR_DEFAULT_VALUE_NULL); return createDoubleBinding(() -> items.stream().mapToDouble(Number::doubleValue).average().orElse(defaultValue.doubleValue()), items); }
/** * Creates a number binding that computes the maximum value amongst values. * * @param items the observable map of items. * @param supplier a {@code Supplier} whose result is returned if no value is present. * * @return a number binding */ @Nonnull public static <K> NumberBinding maxInMap(@Nonnull final ObservableMap<K, ? extends Number> items, @Nonnull final Supplier<? extends Number> supplier) { requireNonNull(items, ERROR_ITEMS_NULL); requireNonNull(supplier, ERROR_SUPPLIER_NULL); return createDoubleBinding(() -> items.values().stream().mapToDouble(Number::doubleValue).max().orElseGet(resolveDoubleSupplier(supplier)), items); }
public static DoubleBinding createTextHeightBinding(String text, ObservableValue<Font> font, ObservableValue<Number> fontZoomFactor) { return Bindings.createDoubleBinding(()->{ return getTextHeight(text, font.getValue(), fontZoomFactor.getValue().doubleValue()); }, font, fontZoomFactor); }
public static DoubleBinding createTextWidthBinding(String text, ObservableValue<Font> font, ObservableValue<Number> fontZoomFactor) { return Bindings.createDoubleBinding(()->{ return getTextWidth(text, font.getValue(), fontZoomFactor.getValue().doubleValue()); }, font, fontZoomFactor); }
/** * Create a binding for text width calculation. * @param text * @param font * @return */ public static DoubleBinding createTextWidthBinding(ObservableValue<String> text, ObservableValue<Font> font, ObservableValue<Number> fontZoomFactor) { return Bindings.createDoubleBinding(()->{ return getTextWidth(text.getValue(), font.getValue(), fontZoomFactor.getValue().doubleValue()); }, text, font, fontZoomFactor); }