/** * {@inheritDoc} */ public JFXListView() { this.setCellFactory(listView -> new JFXListCell<>()); initialize(); }
@Override protected void layoutChildren() { super.layoutChildren(); cellRippler.resizeRelocate(0, 0, getWidth(), getHeight()); double gap = getGap(); clip = new Rectangle(0, gap / 2, getWidth(), getHeight() - gap); setClip(clip); } else { if (gap != 0) { this.setTranslateY(-gap / 2 + (-gap * (getIndex()))); clip.setY(gap / 2); clip.setHeight(getHeight() - gap); gapAnimation = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(this.translateYProperty(), 0, Interpolator.EASE_BOTH))); } else if (selectionChanged) { clip.setY(0); clip.setHeight(getHeight()); gapAnimation = new Timeline( new KeyFrame(Duration.millis(240), new KeyValue(clip.yProperty(), gap / 2, Interpolator.EASE_BOTH), new KeyValue(clip.heightProperty(), getHeight() - gap, Interpolator.EASE_BOTH) )); this.setTranslateY(0); clip.setY(gap / 2);
listViewProperty().addListener((listObj, oldList, newList) -> { if (newList != null) { if (getListView() instanceof JFXListView) { ((JFXListView<?>) newList).currentVerticalGapProperty().addListener((o, oldVal, newVal) -> { cellRippler.rippler.setClip(null); if (newVal.doubleValue() != 0) { playExpandAnimation = true; getListView().requestLayout(); } else { gapAnimation = new Timeline( new KeyFrame(Duration.millis(240), new KeyValue(this.translateYProperty(), -gap / 2 - (gap * (getIndex())), Interpolator.EASE_BOTH) )); gapAnimation.play(); gapAnimation.setOnFinished((finish) -> { requestLayout(); Platform.runLater(() -> getListView().requestLayout()); }); selectedProperty().addListener((o, oldVal, newVal) -> { if (newVal) { selectionChanged = true;
private void initialize() { this.getStyleClass().add(DEFAULT_STYLE_CLASS); this.setPadding(new Insets(8, 12, 8, 12)); }
super.updateItem(item, empty); if (empty) { setText(null); setGraphic(null); setMouseTransparent(true); setStyle("-fx-background-color:TRANSPARENT;"); } else { setMouseTransparent(false); setStyle(null); if (item instanceof Node) { setText(null); Node currentNode = getGraphic(); Node newNode = (Node) item; if (currentNode == null || !currentNode.equals(newNode)) { ((JFXListView<?>) getListView()).addSublist((JFXListView<?>) newNode, this.getIndex()); this.getStyleClass().add("sublist-item"); if (this.getPadding() != null) { this.setPadding(new Insets(this.getPadding().getTop(), 0, this.getPadding().getBottom(), 0)); sublistContainer.setMaxHeight(0); sublistContainer.getChildren().setAll(newNode); sublistContainer.setTranslateY(this.snappedBottomInset()); sublistContainer.setOpacity(0);
@Override protected double computePrefHeight(double width) { double gap = getGap(); return super.computePrefHeight(width) + gap; }
private double getGap() { return (getListView() instanceof JFXListView) ? (((JFXListView<?>) getListView()).isExpanded() ? ((JFXListView<?>) getListView()) .currentVerticalGapProperty() .get() : 0) : 0; } }
@Override protected Node getMask() { Region clip = new Region(); JFXNodeUtils.updateBackground(JFXListCell.this.getBackground(), clip); double width = control.getLayoutBounds().getWidth(); double height = control.getLayoutBounds().getHeight(); clip.resize(width, height); return clip; }
/** * this method is used to set some nodes in cell content as mouse transparent nodes * so clicking on them will trigger the ripple effect. */ protected void makeChildrenTransparent() { for (Node child : getChildren()) { if (child instanceof Label) { Set<Node> texts = child.lookupAll("Text"); for (Node text : texts) { text.setMouseTransparent(true); } } else if (child instanceof Shape) { child.setMouseTransparent(true); } } }
super.updateItem(item, empty); if (empty) { setText(null); setGraphic(null); setMouseTransparent(true); setStyle("-fx-background-color:TRANSPARENT;"); } else { setMouseTransparent(false); setStyle(null); if (item instanceof Node) { setText(null); Node currentNode = getGraphic(); Node newNode = (Node) item; if (currentNode == null || !currentNode.equals(newNode)) { ((JFXListView<?>) getListView()).addSublist((JFXListView<?>) newNode, this.getIndex()); this.getStyleClass().add("sublist-item"); if (this.getPadding() != null) { this.setPadding(new Insets(this.getPadding().getTop(), 0, this.getPadding().getBottom(), 0)); sublistContainer.setMaxHeight(0); sublistContainer.getChildren().setAll(newNode); sublistContainer.setTranslateY(this.snappedBottomInset()); sublistContainer.setOpacity(0);
private void initialize() { this.getStyleClass().add(DEFAULT_STYLE_CLASS); this.setPadding(new Insets(8, 12, 8, 12)); }
private void updateClipHeight(double newHeight) { clip.setHeight(newHeight - getGap()); }
private double getGap() { return (getListView() instanceof JFXListView) ? (((JFXListView<?>) getListView()).isExpanded() ? ((JFXListView<?>) getListView()) .currentVerticalGapProperty() .get() : 0) : 0; } }
@Override protected Node getMask() { Region clip = new Region(); JFXNodeUtils.updateBackground(JFXListCell.this.getBackground(), clip); double width = control.getLayoutBounds().getWidth(); double height = control.getLayoutBounds().getHeight(); clip.resize(width, height); return clip; }
/** * this method is used to set some nodes in cell content as mouse transparent nodes * so clicking on them will trigger the ripple effect. */ protected void makeChildrenTransparent() { for (Node child : getChildren()) { if (child instanceof Label) { Set<Node> texts = child.lookupAll("Text"); for (Node text : texts) { text.setMouseTransparent(true); } } else if (child instanceof Shape) { child.setMouseTransparent(true); } } }
@Override protected void layoutChildren() { super.layoutChildren(); cellRippler.resizeRelocate(0, 0, getWidth(), getHeight()); double gap = getGap(); clip = new Rectangle(0, gap / 2, getWidth(), getHeight() - gap); setClip(clip); } else { if (gap != 0) { this.setTranslateY(-gap / 2 + (-gap * (getIndex()))); clip.setY(gap / 2); clip.setHeight(getHeight() - gap); gapAnimation = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(this.translateYProperty(), 0, Interpolator.EASE_BOTH))); } else if (selectionChanged) { clip.setY(0); clip.setHeight(getHeight()); gapAnimation = new Timeline( new KeyFrame(Duration.millis(240), new KeyValue(clip.yProperty(), gap / 2, Interpolator.EASE_BOTH), new KeyValue(clip.heightProperty(), getHeight() - gap, Interpolator.EASE_BOTH) )); this.setTranslateY(0); clip.setY(gap / 2);
listViewProperty().addListener((listObj, oldList, newList) -> { if (newList != null) { if (getListView() instanceof JFXListView) { ((JFXListView<?>) newList).currentVerticalGapProperty().addListener((o, oldVal, newVal) -> { cellRippler.rippler.setClip(null); if (newVal.doubleValue() != 0) { playExpandAnimation = true; getListView().requestLayout(); } else { gapAnimation = new Timeline( new KeyFrame(Duration.millis(240), new KeyValue(this.translateYProperty(), -gap / 2 - (gap * (getIndex())), Interpolator.EASE_BOTH) )); gapAnimation.play(); gapAnimation.setOnFinished((finish) -> { requestLayout(); Platform.runLater(() -> getListView().requestLayout()); }); selectedProperty().addListener((o, oldVal, newVal) -> { if (newVal) { selectionChanged = true;
chipView.setSuggestionsCellFactory(param -> new JFXListCell<>());
@Override protected double computePrefHeight(double width) { double gap = getGap(); return super.computePrefHeight(width) + gap; }
/** * {@inheritDoc} */ public JFXListView() { this.setCellFactory(listView -> new JFXListCell<>()); initialize(); }