/* * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package javafx.scene.effect; import javafx.beans.property.DoubleProperty; import javafx.beans.property.DoublePropertyBase; import javafx.beans.property.ObjectProperty; import javafx.scene.Node; import com.sun.javafx.util.Utils; import com.sun.javafx.effect.EffectDirtyBits; import com.sun.javafx.geom.BaseBounds; import com.sun.javafx.geom.transform.BaseTransform; import com.sun.javafx.scene.BoundsAccessor; /** * A blur effect using a Gaussian convolution kernel, with a configurable * radius. * *
* Example: *
* Text text = new Text();
* text.setText("Blurry Text!");
* text.setFill(Color.web("0x3b596d"));
* text.setFont(Font.font(null, FontWeight.BOLD, 50));
* text.setX(10);
* text.setY(50);
*
* text.setEffect(new GaussianBlur());
*
* * The code above produces the following: *
*
*
*
* Min: 0.0 * Max: 63.0 * Default: 10.0 * Identity: 0.0 ** @defaultValue 10.0 */ private DoubleProperty radius; public final void setRadius(double value) { radiusProperty().set(value); } public final double getRadius() { return radius == null ? 10 : radius.get(); } public final DoubleProperty radiusProperty() { if (radius == null) { radius = new DoublePropertyBase(10) { @Override public void invalidated() { markDirty(EffectDirtyBits.EFFECT_DIRTY); effectBoundsChanged(); } @Override public Object getBean() { return GaussianBlur.this; } @Override public String getName() { return "radius"; } }; } return radius; } private float getClampedRadius() { return (float) Utils.clamp(0, getRadius(), 63); } @Override void impl_update() { Effect localInput = getInput(); if (localInput != null) { localInput.impl_sync(); } com.sun.scenario.effect.GaussianBlur peer = (com.sun.scenario.effect.GaussianBlur) impl_getImpl(); peer.setRadius(getClampedRadius()); peer.setInput(localInput == null ? null : localInput.impl_getImpl()); } /** * @treatAsPrivate implementation detail * @deprecated This is an internal API that is not intended for use and will be removed in the next version */ @Deprecated @Override public BaseBounds impl_getBounds(BaseBounds bounds, BaseTransform tx, Node node, BoundsAccessor boundsAccessor) { bounds = getInputBounds(bounds, BaseTransform.IDENTITY_TRANSFORM, node, boundsAccessor, getInput()); float r = getClampedRadius(); bounds = bounds.deriveWithPadding(r, r, 0); return transformBounds(tx, bounds); } /** * @treatAsPrivate implementation detail * @deprecated This is an internal API that is not intended for use and will be removed in the next version */ @Deprecated @Override public Effect impl_copy() { return new GaussianBlur(this.getRadius()); } }