Package javafx.beans

Examples of javafx.beans.InvalidationListener


public class CarouselCell<T> extends IndexedCell<T> {

  public CarouselCell() {
    getStyleClass().setAll("carousel-cell");

    indexProperty().addListener(new InvalidationListener() {
      @Override
      public void invalidated(Observable observable) {
        updateItem();
      }
    });
View Full Code Here


  public AbstractCarouselSkin(final Carousel<T> carousel) {
    super(carousel, new CarouselBehavior<>(carousel));

    getStyleClass().setAll("scroll-area");

    InvalidationListener cellCountInvalidationListener = new InvalidationListener() {
      @Override
      public void invalidated(Observable observable) {
        allocateCells();
        sortChildren();
      }
View Full Code Here

public class RayCarouselSkin<T> extends AbstractCarouselSkin<T> {

  public RayCarouselSkin(final Carousel<T> carousel) {
    super(carousel);

    InvalidationListener invalidationListener = new InvalidationListener() {
      @Override
      public void invalidated(Observable observable) {
        requestLayout();
      }
    };
View Full Code Here

        this.formatProvider = formatProvider;
    }

    public DisposableNode createNode(final PropertyElementController<T> controller) {
        final TextField textBox = new TextField();
        final InvalidationListener textBoxListener = createTextBoxListener(controller, textBox);
        textBox.textProperty().addListener(textBoxListener);
        if (controller.getValue() != null) {
            textBox.textProperty().setValue(formatProvider.getFormat(controller.getElement()).format(controller.getValue()));
        }
        final InvalidationListener controllerListener = createControllerListener(textBox, controller);
        controller.addListener(controllerListener);
        textBox.promptTextProperty().bind(controller.getPromptText());

        return new DisposableNodeWrapper(textBox, new Callback<Node, Void>() {
            public Void call(Node node) {
View Full Code Here

        });
    }


    protected InvalidationListener createTextBoxListener(final PropertyElementController<T> controller, final TextField textBox) {
        return new InvalidationListener() {

            public void invalidated(Observable observable) {
                if (textBox.getText().trim().length() > 0) {
                    try {
                        ParsePosition parsePosition = new ParsePosition(0);
View Full Code Here

            }
        };
    }

    protected InvalidationListener createControllerListener(final TextField textBox, final PropertyElementController<T> controller) {
        return new InvalidationListener() {

            public void invalidated(Observable observable) {
                if (controller.getValue() != null) {
                    textBox.textProperty().setValue(formatProvider.getFormat(controller.getElement()).format(controller.getValue()));
                } else {
View Full Code Here

                    }
                }
            });

            // If number in controller changes update the TextField with the formatted number string
            CONTROL.numberProperty().addListener(new InvalidationListener() {
                @Override
                public void invalidated(Observable arg0) {
                    setText(CONTROL.getText());
                }
            });
View Full Code Here

    final DoubleProperty frameWidthProperty = getSkinnable().frameWidthProperty();
    final DoubleProperty scopeLineWidthProperty = getSkinnable().scopeLineWidthProperty();
    final BooleanProperty scopeLinesVisibleProperty = getSkinnable().scopeLinesVisibleProperty();

    // Adding listener to control "radiusProperty" to add the value to "localRadius".
    getSkinnable().radiusProperty().addListener(new InvalidationListener() {
      @Override
      public void invalidated(Observable arg0) {
        localRadius.set(getSkinnable().getRadius());
      }
    });
    localRadius.set(getSkinnable().getRadius());

    // Adding listener to control "scaleFactorProperty" to add the value to "localScaleFactor".
    getSkinnable().scaleFactorProperty().addListener(new InvalidationListener() {
      @Override
      public void invalidated(Observable arg0) {
        localScaleFactor.set(getSkinnable().getScaleFactor());
      }
    });
    localScaleFactor.set(getSkinnable().getScaleFactor());

    snapView = new ImageView();
    callBack = new Callback<SnapshotResult, Void>() {
      @Override
      public Void call(SnapshotResult result) {
        return null;
      }
    };
    final Scale scale = new Scale();
    scale.xProperty().bind(localScaleFactor);
    scale.yProperty().bind(localScaleFactor);
    param = new SnapshotParameters();
    param.setDepthBuffer(true);
    param.setTransform(scale);

    final StackPane mainContent = new StackPane();
    final Circle frame = new Circle();
    frame.getStyleClass().add("magnifier-frame");
    frame.radiusProperty().bind(localRadius.add(frameWidthProperty));
   
    final Circle cClip = new Circle();
    cClip.radiusProperty().bind(localRadius);
    cClip.translateXProperty().bind(localRadius);
    cClip.translateYProperty().bind(localRadius);

    viewer = new Viewer(localRadius, localRadius);
    viewer.setClip(cClip);

    final Line vL = new Line();
    vL.setStartX(0);
    vL.setStartY(0);
    vL.setEndX(0);
    vL.getStyleClass().add("magnifier-vLine");
    vL.strokeWidthProperty().bind(scopeLineWidthProperty);
    vL.visibleProperty().bind(scopeLinesVisibleProperty);
    vL.endYProperty().bind(localRadius.multiply(2));

    final Line hL = new Line();
    hL.setStartX(0);
    hL.setStartY(0);
    hL.setEndY(0);
    hL.getStyleClass().add("magnifier-hLine");
    hL.strokeWidthProperty().bind(scopeLineWidthProperty);
    hL.visibleProperty().bind(scopeLinesVisibleProperty);
    hL.endXProperty().bind(localRadius.multiply(2));

    // Adding all parts in a container.
    mainContent.getChildren().addAll(frame, viewer, vL, hL);

    final Popup popUp = new Popup();
    popUp.getContent().add(mainContent);

    final EventHandler<MouseEvent> enteredEvent = new EventHandler<MouseEvent>() {
      @Override
      public void handle(MouseEvent e) {
        popUp.show(getSkinnable(), e.getScreenX() - shift, e.getScreenY() - shift);
        takeSnap(e.getX(), e.getY());
      }
    };
    final EventHandler<MouseEvent> exitedEvent = new EventHandler<MouseEvent>() {
      @Override
      public void handle(MouseEvent e) {
        popUp.hide();
      }
    };
    final EventHandler<MouseEvent> movedEvent = new EventHandler<MouseEvent>() {
      @Override
      public void handle(MouseEvent e) {
        final double r = localRadius.get();
        final double s = localScaleFactor.get();
        if (e.getSceneX() > (scene.getWidth() - (2 * r))) {
          popUp.setX(e.getScreenX() - (2 * r) - shift);
        } else {
          popUp.setX(e.getScreenX() - shift);
        }

        if (e.getSceneY() > (scene.getHeight() - (2 * r))) {
          popUp.setY(e.getScreenY() - (2 * r) - shift);
        } else {
          popUp.setY(e.getScreenY() - shift);
        }
        prevX.set(e.getX());
        prevY.set(e.getY());
        shiftViewerContent(prevX.get(), prevY.get(), r, s);
      }
    };

    // Adding mask implementation. The below mask is responsible to not access the contents when magnifier is shown.
    final StackPane mask = new StackPane();

    // Adding listener to activateProperty.
    getSkinnable().activeProperty().addListener(new InvalidationListener() {
      @Override
      public void invalidated(Observable arg0) {
        final Magnifier skinnable = getSkinnable();
        if (skinnable.isActive()) {
          skinnable.addEventFilter(MouseEvent.MOUSE_ENTERED, enteredEvent);
          skinnable.addEventFilter(MouseEvent.MOUSE_EXITED, exitedEvent);
          skinnable.addEventFilter(MouseEvent.MOUSE_MOVED, movedEvent);
          if (!getChildren().contains(mask)) {
            getChildren().add(mask);
          }
        } else {
          skinnable.removeEventFilter(MouseEvent.MOUSE_ENTERED, enteredEvent);
          skinnable.removeEventFilter(MouseEvent.MOUSE_EXITED, exitedEvent);
          skinnable.removeEventFilter(MouseEvent.MOUSE_MOVED, movedEvent);
          if (getChildren().contains(mask)) {
            getChildren().remove(mask);
          }
        }
      }
    });
    if (getSkinnable().isActive()) {
      final Magnifier skinnable = getSkinnable();
      skinnable.addEventFilter(MouseEvent.MOUSE_ENTERED, enteredEvent);
      skinnable.addEventFilter(MouseEvent.MOUSE_EXITED, exitedEvent);
      skinnable.addEventFilter(MouseEvent.MOUSE_MOVED, movedEvent);
    }

    // Adding listener to contentProperty.
    getSkinnable().contentProperty().addListener(new InvalidationListener() {
      @Override
      public void invalidated(Observable arg0) {
        getChildren().clear();
        getChildren().addAll(getSkinnable().getContent(),mask);
      }
View Full Code Here

            getStyleClass().setAll("tab-content-area");
            setManaged(false);
            this.tab = tab;
            updateContent();

            tabListener = new InvalidationListener() {
                @Override public void invalidated(Observable valueModel) {
                    if (valueModel == getTab().selectedProperty()) {
                        setVisible(getTab().isSelected());
                    } else if (valueModel == getTab().contentProperty()) {
                        getChildren().clear();
                        updateContent();
                    }
                }
            };
            tab.selectedProperty().addListener(new InvalidationListener() {
                @Override public void invalidated(Observable valueModel) {
                    setVisible(getTab().isSelected());
                }
            });
            tab.contentProperty().addListener(new InvalidationListener() {
                @Override public void invalidated(Observable valueModel) {
                    getChildren().clear();
                    updateContent();
                }
            });
View Full Code Here

            inner.getStyleClass().add("container");
            inner.getChildren().add(downArrowBtn);

            getChildren().add(inner);

            tabPane.sideProperty().addListener(new InvalidationListener() {
                @Override public void invalidated(Observable valueModel) {
                    Side tabPosition = getSkinnable().getSide();
                    downArrow.setRotate(tabPosition.equals(Side.BOTTOM)? 180.0F : 0.0F);
                }
            });
View Full Code Here

TOP

Related Classes of javafx.beans.InvalidationListener

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.