public void clear() { getChildren().clear(); rippler.overlayRect = null; generating.set(false); } }
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(); } } }
private void releaseRipple() { Ripple ripple = ripplesQueue.poll(); if(ripple!=null) { ripple.inAnimation.stop(); ripple.outAnimation = new Timeline( new KeyFrame(Duration.millis(Math.min(800, (0.9 * 500) / ripple.getScaleX())) , ripple.outKeyValues)); ripple.outAnimation.setOnFinished((event) -> getChildren().remove(ripple)); ripple.outAnimation.play(); if (generating.getAndSet(false)) { if (overlayRect != null) { overlayRect.inAnimation.stop(); if (!forceOverlay) overlayRect.outAnimation.play(); } } } }
private void releaseRipple() { Ripple ripple = ripplesQueue.poll(); if(ripple!=null) { ripple.inAnimation.stop(); ripple.outAnimation = new Timeline( new KeyFrame(Duration.millis(Math.min(800, (0.9 * 500) / ripple.getScaleX())) , ripple.outKeyValues)); ripple.outAnimation.setOnFinished((event) -> getChildren().remove(ripple)); ripple.outAnimation.play(); if (generating.getAndSet(false)) { if (overlayRect != null) { overlayRect.inAnimation.stop(); if (!forceOverlay) overlayRect.outAnimation.play(); } } } }
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(); } } }
void createOverlay() { if (overlayRect == null) { overlayRect = new OverLayRipple(); overlayRect.setClip(getMask()); getChildren().add(0, overlayRect); if (ripplerFill.get() instanceof Color) { overlayRect.setFill(new Color(((Color) ripplerFill.get()).getRed(), ((Color) ripplerFill.get()).getGreen(), ((Color) ripplerFill.get()).getBlue(), 0.2)); }else{ overlayRect.setFill(Color.TRANSPARENT); } } }
private void resetOverLay() { if (rippler.overlayRect != null) { rippler.overlayRect.inAnimation.stop(); final RippleGenerator.OverLayRipple oldOverlay = rippler.overlayRect; rippler.overlayRect.outAnimation.setOnFinished((finish) -> rippler.getChildren().remove(oldOverlay)); rippler.overlayRect.outAnimation.play(); rippler.overlayRect = null; } }
public void clear() { getChildren().clear(); rippler.overlayRect = null; generating.set(false); } }
void createOverlay() { if (overlayRect == null) { overlayRect = new OverLayRipple(); overlayRect.setClip(getMask()); getChildren().add(0, overlayRect); if (ripplerFill.get() instanceof Color) { overlayRect.setFill(new Color(((Color) ripplerFill.get()).getRed(), ((Color) ripplerFill.get()).getGreen(), ((Color) ripplerFill.get()).getBlue(), 0.2)); }else{ overlayRect.setFill(Color.TRANSPARENT); } } }
private void resetOverLay() { if (rippler.overlayRect != null) { rippler.overlayRect.inAnimation.stop(); final RippleGenerator.OverLayRipple oldOverlay = rippler.overlayRect; rippler.overlayRect.outAnimation.setOnFinished((finish) -> rippler.getChildren().remove(oldOverlay)); rippler.overlayRect.outAnimation.play(); rippler.overlayRect = null; } }