Package javafx.beans.binding

Examples of javafx.beans.binding.DoubleBinding


            })
            .build();
       
        final Circle colorRectIndicator = CircleBuilder.create().centerX(60).centerY(60).radius(5).stroke(Color.WHITE).fill(null).effect(new DropShadow(2, 0, 1, Color.BLACK)).build();
       
        colorRectIndicator.centerXProperty().bind(new DoubleBinding() {
            { bind(sat); }
            @Override protected double computeValue() {
                return (PICKER_PADDING + 10) + (RECT_SIZE * (sat.get() / 100));
            }
        });
       
        colorRectIndicator.centerYProperty().bind(new DoubleBinding() {
            { bind(bright); }
            @Override protected double computeValue() {
                return (PICKER_PADDING + ARROW_SIZE + 10) + (RECT_SIZE * (1 - (bright.get() / 100)));
            }
        });
       
        final Rectangle colorRect = RectangleBuilder.create()
                .x(PICKER_PADDING + 10)
                .y(PICKER_PADDING + ARROW_SIZE + 10)
                .width(RECT_SIZE)
                .height(RECT_SIZE)
                .build();
        colorRect.fillProperty().bind(new ObjectBinding<Paint>() {
            { bind(color); }
            @Override protected Paint computeValue() {
                return Color.hsb(hue.getValue(), 1, 1);
            }
        });
       
        Rectangle colorRectOverlayOne = RectangleBuilder.create()
                .x(PICKER_PADDING + 10)
                .y(PICKER_PADDING + ARROW_SIZE + 10)
                .width(RECT_SIZE)
                .height(RECT_SIZE)
                .fill(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, new Stop(0, Color.rgb(255, 255, 255, 1)), new Stop(1, Color.rgb(255, 255, 255, 0)))).build();
       
        EventHandler<MouseEvent> rectMouseHandler = new EventHandler<MouseEvent>() {
            @Override public void handle(MouseEvent event) {
                final double x = event.getX() - colorRect.getX();
                final double y = event.getY() - colorRect.getY();
                sat.set(clamp(x / RECT_SIZE) * 100);
                bright.set(100 - (clamp(y / RECT_SIZE) * 100));
            }
        };
       
        Rectangle colorRectOverlayTwo = RectangleBuilder.create()
                .x(PICKER_PADDING + 10)
                .y(PICKER_PADDING + ARROW_SIZE + 10)
                .width(RECT_SIZE)
                .height(RECT_SIZE)
                .fill(new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, new Stop(0, Color.rgb(0, 0, 0, 0)), new Stop(1, Color.rgb(0, 0, 0, 1))))
                .onMouseDragged(rectMouseHandler)
                .onMouseClicked(rectMouseHandler)
                .build();
        final Rectangle colorBar = RectangleBuilder.create()
                .x(PICKER_PADDING + PICKER_WIDTH - 30)
                .y(PICKER_PADDING + ARROW_SIZE + 10)
                .width(20)
                .height(RECT_SIZE)
                .fill(createHueGradient())
                .build();
        final Rectangle colorBarIndicator = RectangleBuilder.create()
                .x(PICKER_PADDING + PICKER_WIDTH - 32)
                .y(PICKER_PADDING + ARROW_SIZE + 15)
                .width(24)
                .height(10)
                .arcWidth(4)
                .arcHeight(4)
                .stroke(Color.WHITE)
                .fill(null)
                .effect(new DropShadow(2, 0, 1, Color.BLACK))
                .build();
       
        colorBarIndicator.yProperty().bind(new DoubleBinding() {
            { bind(hue); }
            @Override protected double computeValue() {
                return (PICKER_PADDING + ARROW_SIZE + 5) + (RECT_SIZE * (hue.get() / 360));
            }
        });
View Full Code Here


   *
     * @param position (x or y)
   * @return
   */
  public static DoubleBinding snapXY(final ObservableNumberValue position) {
    return new DoubleBinding() {
            {
                super.bind(position);
            }

            @Override
View Full Code Here

     * @param offset (width or height)
   * @param dependencies
   * @return
   */
  public static DoubleBinding snapWH(final ObservableNumberValue position, final ObservableNumberValue offset, final Observable... dependencies) {
        return new DoubleBinding() {
            {
                super.bind(dependencies);
            }

            @Override
View Full Code Here

    ObservableList<T> observableArrayList = FXCollections.observableArrayList();

    items.set(observableArrayList);
    focusModel.set(new CarouselFocusModel<>(this));

    maxCellWidth.bind(new DoubleBinding() {
      {
        bind(orientation);
        bind(cellSizeRatio);
        bind(widthProperty());
        bind(heightProperty());
      }

      @Override
      protected double computeValue() {
        return getCellSizeRatio() * (getOrientation() == Orientation.HORIZONTAL ? getHeight() : getWidth());
      }
    });

    maxCellHeight.bind(new DoubleBinding() {
      {
        bind(orientation);
        bind(cellSizeRatio);
        bind(widthProperty());
        bind(heightProperty());
View Full Code Here

     * Misc utilities                                                         *
     *                                                                        *
     *************************************************************************/

    public static DoubleBinding getMaxSquareSizeBinding(final DoubleProperty WIDTH_PROPERTY, final DoubleProperty HEIGHT_PROPERTY) {
        final DoubleBinding MAX_SQUARE_SIZE = new DoubleBinding() {
            {
                super.bind(WIDTH_PROPERTY, HEIGHT_PROPERTY);
            }

            @Override protected double computeValue() {
View Full Code Here

        };
        return MAX_SQUARE_SIZE;
    }

    public static DoubleBinding getMaxSquareSizeBinding(final ReadOnlyDoubleProperty WIDTH_PROPERTY, final ReadOnlyDoubleProperty HEIGHT_PROPERTY) {
        final DoubleBinding MAX_SQUARE_SIZE = new DoubleBinding() {
            {
                super.bind(WIDTH_PROPERTY, HEIGHT_PROPERTY);
            }

            @Override protected double computeValue() {
View Full Code Here

        // Make the progress line+circle follow the pledged amount and disappear if there are no pledges yet.
        //
        // This is all calculated lazily, so changes in pledgedProperty propagate through to the widgets only
        // when they actually need to be drawn.
        DoubleBinding progress = min(1.0, divide(pledgedAmount, (double) project.getGoalAmount().value));
        NumberBinding pixelWidth = multiply(widthProperty(), progress);
        // These come pre-bound in the FXML just to make things look more clear in Scene Builder, so unbind them here.
        progressLine.endXProperty().unbind();
        progressCircle.centerXProperty().unbind();
        animatedBind(progressLine, progressLine.endXProperty(), pixelWidth);
View Full Code Here

TOP

Related Classes of javafx.beans.binding.DoubleBinding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.