@Override public void start(Stage primaryStage) throws Exception { JFXHamburger show = new JFXHamburger(); show.setPadding(new Insets(10, 5, 10, 5)); JFXRippler rippler = new JFXRippler(show, RipplerMask.CIRCLE, RipplerPos.BACK); JFXListView<Label> list = new JFXListView<>(); for (int i = 1; i < 5; i++) { list.getItems().add(new Label("Item " + i)); } AnchorPane container = new AnchorPane(); container.getChildren().add(rippler); AnchorPane.setLeftAnchor(rippler, 200.0); AnchorPane.setTopAnchor(rippler, 210.0); StackPane main = new StackPane(); main.getChildren().add(container); JFXPopup popup = new JFXPopup(list); rippler.setOnMouseClicked(e -> popup.show(rippler, PopupVPosition.TOP, PopupHPosition.LEFT)); final Scene scene = new Scene(main, 800, 800); scene.getStylesheets().add(PopupDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); primaryStage.setTitle("JFX Popup Demo"); primaryStage.setScene(scene); primaryStage.setResizable(false); primaryStage.show(); }
/** * init mouse listeners on the control */ protected void initControlListeners() { // if the control got resized the overlay rect must be rest control.layoutBoundsProperty().addListener(observable -> resetRippler()); if(getChildren().contains(control)) control.boundsInParentProperty().addListener(observable -> resetRippler()); control.addEventHandler(MouseEvent.MOUSE_PRESSED, (event) -> createRipple(event.getX(), event.getY())); // create fade out transition for the ripple control.addEventHandler(MouseEvent.MOUSE_RELEASED, e -> releaseRipple()); }
/** * creates a rippler for the specified control, mask and position. * * @param control * @param mask can be either rectangle/cricle * @param pos can be either FRONT/BACK (position the ripple effect infront of or behind the control) */ public JFXRippler(Node control, RipplerMask mask, RipplerPos pos) { initialize(); setMaskType(mask); setPosition(pos); createRippleUI(); setControl(control); // listen to control position changed position.addListener(observable -> updateControlPosition()); setPickOnBounds(false); setCache(true); setCacheHint(CacheHint.SPEED); setCacheShape(true); }
OverLayRipple() { super(); setOverLayBounds(this); this.getStyleClass().add("jfx-rippler-overlay"); // update initial position if(JFXRippler.this.getChildrenUnmodifiable().contains(control)) { double diffMinX = Math.abs(control.getBoundsInLocal().getMinX() - control.getLayoutBounds().getMinX()); double diffMinY = Math.abs(control.getBoundsInLocal().getMinY() - control.getLayoutBounds().getMinY()); Bounds bounds = control.getBoundsInParent(); this.setX(bounds.getMinX() + diffMinX - snappedLeftInset()); this.setY(bounds.getMinY() + diffMinY - snappedTopInset()); } // set initial attributes setOpacity(0); setCache(true); setCacheHint(CacheHint.SPEED); setCacheShape(true); setManaged(false); } }
circlePane.setPadding(new Insets(circleRadius * 1.5)); JFXRippler rippler = new JFXRippler(circlePane, RipplerMask.CIRCLE, RipplerPos.BACK); rippler.setTranslateX(computeTranslation(circleRadius, line)); releaseManualRippler = rippler.createManualRipple(); } else if (releaseManualRippler != null) { releaseManualRippler.run(); if (newVal) { if (!getSkinnable().isPressed()) { rippler.setOverlayVisible(true); rippler.setOverlayVisible(false); toggleButton.pressedProperty().addListener(observable -> rippler.setOverlayVisible(false)); timer.reverseAndContinue(); } else { rippler.setTranslateX(computeTranslation(circleRadius, line)); new JFXKeyFrame(Duration.millis(100), JFXKeyValue.builder() .setTarget(rippler.translateXProperty()) .setEndValueSupplier(() -> computeTranslation(circleRadius, line)) .setInterpolator(Interpolator.EASE_BOTH)
cellRippler.ripplerFillProperty().bind(((JFXRippler) newNode).ripplerFillProperty()); cellRippler.maskTypeProperty().bind(((JFXRippler) newNode).maskTypeProperty()); cellRippler.positionProperty().bind(((JFXRippler) newNode).positionProperty()); cellContent = ((JFXRippler) newNode).getControl();
final JFXRippler rippler = new JFXRippler(colorBox, JFXRippler.RipplerMask.FIT); rippler.ripplerFillProperty().bind(displayNode.textFillProperty()); getChildren().setAll(rippler); JFXDepthManager.setDepth(getSkinnable(), 1); if (colorPicker.isFocused()) { if (!getSkinnable().isPressed()) { rippler.setOverlayVisible(true); rippler.setOverlayVisible(false);
button.addEventFilter(MouseEvent.MOUSE_DRAGGED, e-> mousePressed = false); button.ripplerFillProperty().addListener((o, oldVal, newVal) -> buttonRippler.setRipplerFill(newVal)); releaseManualRippler = buttonRippler.createManualRipple(); playClickAnimation(1); if (newVal){ if (!getSkinnable().isPressed()){ buttonRippler.setOverlayVisible(true); buttonRippler.setOverlayVisible(false);
centerY, ripplerRadius.get().doubleValue() == Region.USE_COMPUTED_SIZE ? computeRippleRadius() : ripplerRadius.get().doubleValue(), null); setCache(true); setCacheHint(CacheHint.SPEED); setCacheShape(true); setManaged(false); setSmooth(true); KeyValue[] inKeyValues = new KeyValue[isRipplerRecenter() ? 4 : 2]; outKeyValues = new KeyValue[isRipplerRecenter() ? 5 : 3]; outKeyValues[2] = new KeyValue(this.opacityProperty(), 0, rippleInterpolator); if (isRipplerRecenter()) { double dx = (control.getLayoutBounds().getWidth() / 2 - centerX) / 1.55; double dy = (control.getLayoutBounds().getHeight() / 2 - centerY) / 1.55;
boxContainer.getChildren().add(box); boxContainer.setPadding(new Insets(padding)); rippler = new JFXRippler(boxContainer, RipplerMask.CIRCLE); rippler.setRipplerFill(getSkinnable().isSelected() ? control.getUnCheckedColor() : control.getCheckedColor()); rippler.setRipplerFill(newVal ? control.getUnCheckedColor() : control.getCheckedColor()); transition.setRate(newVal ? 1 : -1); transition.play();
boxContainer.getChildren().add(box); boxContainer.getStyleClass().add("box-container"); rippler = new JFXRippler(boxContainer, RipplerMask.CIRCLE, JFXRippler.RipplerPos.BACK); if (newVal) { if (!getSkinnable().isPressed()) { rippler.setOverlayVisible(true); rippler.setOverlayVisible(false); control.pressedProperty().addListener((o, oldVal, newVal) -> rippler.setOverlayVisible(false)); updateChildren();
}); container.setOnMouseReleased(release -> arrowAnimation.stop()); JFXRippler arrowRippler = new JFXRippler(container, RipplerMask.CIRCLE, RipplerPos.BACK); arrowRippler.setPadding(new Insets(0, 5, 0, 5));
releaseManualRippler = rippler.createManualRipple(); } else if (releaseManualRippler != null) { releaseManualRippler.run(); if (newVal) { if (!getSkinnable().isPressed()) { rippler.setOverlayVisible(true); rippler.setOverlayVisible(false); toggleNode.pressedProperty().addListener((o, oldVal, newVal) -> rippler.setOverlayVisible(false));
label.setStyle(FX_BACKGROUND_COLOR_WHITE); label.setPadding(new Insets(20)); JFXRippler rippler = new JFXRippler(label); rippler.setEnabled(false); main.getChildren().add(rippler); l1.setStyle(FX_BACKGROUND_COLOR_WHITE); l1.setPadding(new Insets(20)); JFXRippler rippler1 = new JFXRippler(l1); main.getChildren().add(rippler1); JFXDepthManager.setDepth(rippler1, 1); l2.setStyle(FX_BACKGROUND_COLOR_WHITE); l2.setPadding(new Insets(20)); JFXRippler rippler2 = new JFXRippler(l2); main.getChildren().add(rippler2); JFXDepthManager.setDepth(rippler2, 2); l3.setStyle(FX_BACKGROUND_COLOR_WHITE); l3.setPadding(new Insets(20)); JFXRippler rippler3 = new JFXRippler(l3); main.getChildren().add(rippler3); JFXDepthManager.setDepth(rippler3, 3); l4.setStyle(FX_BACKGROUND_COLOR_WHITE); l4.setPadding(new Insets(20)); JFXRippler rippler4 = new JFXRippler(l4); main.getChildren().add(rippler4); JFXDepthManager.setDepth(rippler4, 4);
inner.setRotate(getSkinnable().getSide().equals(Side.BOTTOM) ? 180.0F : 0.0F); rippler = new JFXRippler(inner); getChildren().addAll(rippler);
protected void positionControl(Node control) { if(this.position.get() == RipplerPos.BACK){ getChildren().add(control); }else{ getChildren().add(0, control); } }
void createRipple() { if (enabled) { if (!generating.getAndSet(true)) { // create overlay once then change its color later createOverlay(); if (this.getClip() == null || (getChildren().size() == 1 && !cacheRipplerClip) || resetClip) { this.setClip(getMask()); } this.resetClip = false; // create the ripple effect final Ripple ripple = new Ripple(generatorCenterX, generatorCenterY); getChildren().add(ripple); ripplesQueue.add(ripple); // animate the ripple overlayRect.outAnimation.stop(); overlayRect.inAnimation.play(); ripple.inAnimation.play(); } } }
@Override public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() { return getClassCssMetaData(); }
circlePane.setPadding(new Insets(circleRadius * 1.5)); JFXRippler rippler = new JFXRippler(circlePane, RipplerMask.CIRCLE, RipplerPos.BACK); rippler.setTranslateX(computeTranslation(circleRadius, line)); releaseManualRippler = rippler.createManualRipple(); } else if (releaseManualRippler != null) { releaseManualRippler.run(); if (newVal) { if (!getSkinnable().isPressed()) { rippler.setOverlayVisible(true); rippler.setOverlayVisible(false); toggleButton.pressedProperty().addListener(observable -> rippler.setOverlayVisible(false)); timer.reverseAndContinue(); } else { rippler.setTranslateX(computeTranslation(circleRadius, line)); new JFXKeyFrame(Duration.millis(100), JFXKeyValue.builder() .setTarget(rippler.translateXProperty()) .setEndValueSupplier(() -> computeTranslation(circleRadius, line)) .setInterpolator(Interpolator.EASE_BOTH)
OverLayRipple() { super(); setOverLayBounds(this); this.getStyleClass().add("jfx-rippler-overlay"); // update initial position if(JFXRippler.this.getChildrenUnmodifiable().contains(control)) { double diffMinX = Math.abs(control.getBoundsInLocal().getMinX() - control.getLayoutBounds().getMinX()); double diffMinY = Math.abs(control.getBoundsInLocal().getMinY() - control.getLayoutBounds().getMinY()); Bounds bounds = control.getBoundsInParent(); this.setX(bounds.getMinX() + diffMinX - snappedLeftInset()); this.setY(bounds.getMinY() + diffMinY - snappedTopInset()); } // set initial attributes setOpacity(0); setCache(true); setCacheHint(CacheHint.SPEED); setCacheShape(true); setManaged(false); } }