Как плавно анимировать ImageView с применением эффектов

Я создал CollapsablePane, который показывает EffectImageView как collapsableContent, а Node как mainContent. EffectImageView состоит из двух слоев ImageViews, к нижнему из которых применен эффект BoxBlur.

Когда на mainContent есть ScrollEvent, collapsableContent будет соответственно анимироваться setTranslateY.

С применением эффекта BoxBlur перевод нижней части collapsableContent очень негладкий, в то время как без эффекта он абсолютно гладкий.

Есть ли возможность улучшить производительность перехода?

public class EffectImageView extends Pane {

    private ImageView      img;
    private ImageView      imgEffect;

    private Rectangle      clipTop;
    private Rectangle      clipBottom;

    private DoubleProperty imageEffectHeight = new SimpleDoubleProperty();
    private double         effectOffset;

    public EffectImageView() {
        img = createCachedImageView();
        imgEffect = createCachedImageView();

        imgEffect.imageProperty().bind(img.imageProperty());
        imgEffect.fitWidthProperty().bind(img.fitWidthProperty());
        imgEffect.fitHeightProperty().bind(img.fitHeightProperty());

        clipTop = new Rectangle();
        clipTop.widthProperty().bind(img.fitWidthProperty());
        clipTop.heightProperty().bind(img.fitHeightProperty().subtract(imageEffectHeight).subtract(translateYProperty()));

        clipBottom = new Rectangle();
        clipBottom.widthProperty().bind(img.fitWidthProperty());
        clipBottom.heightProperty().bind(imageEffectHeight);
        clipBottom.translateYProperty().bind(heightProperty().subtract(imageEffectHeight).subtract(translateYProperty()));

        img.setClip(clipTop);
        imgEffect.setClip(clipBottom);

        getChildren().addAll(img, imgEffect);
    }

    private ImageView createCachedImageView() {
        ImageView img = new ImageView();
        img.setCache(true);
        img.setCacheHint(CacheHint.SPEED);
        return img;
    }

    public final ObjectProperty<Image> imageProperty() {
        return img.imageProperty();
    }

    public final Image getImage() {
        return img.getImage();
    }

    public final void setImage(Image image) {
        img.setImage(image);
    }

    public void setImageEffect(Effect effect) {
        imgEffect.setEffect(effect);
    }

    public final DoubleProperty imageEffectHeightProperty() {
        return imageEffectHeight;
    }

    public void setEffectOffset(double offset) {
        effectOffset = offset;
    }

    @Override
    protected void layoutChildren() {
        double w = getWidth();
        double h = getHeight();

        img.relocate(-effectOffset, 0);
        imgEffect.relocate(-effectOffset, 0);

        img.setFitWidth(w + effectOffset * 2);
        img.setFitHeight(h);
    }
}

person jns    schedule 24.03.2017    source источник