Java Reference
In-Depth Information
final void setEffect(Effect effect )
In this case, effect is the effect that will be applied. To specify no effect, pass null . Thus, to
add an effect to a node, first create an instance of that effect and then pass it to setEffect( ) .
Once this has been done, the effect will be used whenever the node is rendered (as long as
the effect is supported by the environment). To demonstrate the power of effects, we will
use two of them: Reflection and BoxBlur . However, the process of adding an effect is es-
sentially the same no matter what effect you choose.
BoxBlur blurs the node on which it is used. It is called BoxBlur because it uses a blur-
ring technique based on adjusting pixels within a rectangular region. The amount of blur-
ring is under your control. To use a blur effect, you must first create a BoxBlur instance.
BoxBlur supplies two constructors. Here is the constructor that we will use:
BoxBlur(double width , double height , int iterations )
Here, width and height specify the size of box into which a pixel will be blurred. These
values must be between 0 and 255, inclusive. Typically, these values are at the lower end
of this range. The number of times that the blur effect is applied is specified by iterations ,
which must be between 0 and 3, inclusive. A default constructor is also supported, which
sets the width and height to 5.0 and the iterations to 1.
After a BoxBlur instance has been created, the width and height of the box can be
changed by using setWidth( ) and setHeight( ) , shown here:
final void setWidth(double width )
final void setHeight(double height )
The number of iterations can be changed by calling setIterations( ) :
final void setIterations(int iterations )
By using these methods, you can change the blur effect during the execution of your pro-
gram.
Reflection produces an effect that simulates a reflection of the node on which it is called.
It is particularly useful on text, such as that contained in a label. Reflection gives you sig-
nificant control over how the reflection will look. For example, you can set the opacity of
both the top and the bottom of the reflection. You can also set the space between the image
and its reflection, and the amount reflected. These can set by the following Reflection con-
structor:
Search WWH ::




Custom Search