java.lang.Object
javafx.scene.effect.Effect
javafx.scene.effect.DropShadow
A high-level effect that renders a shadow of the given content behind
the content with the specified color, radius, and offset.
Example:
DropShadow dropShadow = new DropShadow();
dropShadow.setRadius(5.0);
dropShadow.setOffsetX(3.0);
dropShadow.setOffsetY(3.0);
dropShadow.setColor(Color.color(0.4, 0.5, 0.5));
Text text = new Text();
text.setEffect(dropShadow);
text.setCache(true);
text.setX(10.0);
text.setY(70.0);
text.setFill(Color.web("0x3b596d"));
text.setText("JavaFX drop shadow...");
text.setFont(Font.font(null, FontWeight.BOLD, 40));
DropShadow dropShadow2 = new DropShadow();
dropShadow2.setOffsetX(6.0);
dropShadow2.setOffsetY(4.0);
Circle circle = new Circle();
circle.setEffect(dropShadow2);
circle.setCenterX(50.0);
circle.setCenterY(125.0);
circle.setRadius(30.0);
circle.setFill(Color.STEELBLUE);
circle.setCache(true);
The code above produces the following:
- Since:
- JavaFX 2.0
-
Property Summary
PropertiesTypePropertyDescriptionfinal ObjectProperty<BlurType>The algorithm used to blur the shadow.final ObjectProperty<Color>The shadowColor.final DoublePropertyThe vertical size of the shadow blur kernel.final ObjectProperty<Effect>The input for thisEffect.final DoublePropertyThe shadow offset in the x direction, in pixels.final DoublePropertyThe shadow offset in the y direction, in pixels.final DoublePropertyThe radius of the shadow blur kernel.final DoublePropertyThe spread of the shadow.final DoublePropertyThe horizontal size of the shadow blur kernel. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of DropShadow with default parameters.DropShadow(double radius, double offsetX, double offsetY, Color color) Creates a new instance of DropShadow with the specified radius, offsetX, offsetY and color.DropShadow(double radius, Color color) Creates a new instance of DropShadow with specified radius and color.DropShadow(BlurType blurType, Color color, double radius, double spread, double offsetX, double offsetY) Creates a new instance of DropShadow with the specified blurType, color, radius, spread, offsetX and offsetY. -
Method Summary
Modifier and TypeMethodDescriptionfinal ObjectProperty<BlurType>The algorithm used to blur the shadow.final ObjectProperty<Color>The shadowColor.final BlurTypeGets the value of theblurTypeproperty.final ColorgetColor()Gets the value of thecolorproperty.final doubleGets the value of theheightproperty.final EffectgetInput()Gets the value of theinputproperty.final doubleGets the value of theoffsetXproperty.final doubleGets the value of theoffsetYproperty.final doubleGets the value of theradiusproperty.final doubleGets the value of thespreadproperty.final doublegetWidth()Gets the value of thewidthproperty.final DoublePropertyThe vertical size of the shadow blur kernel.final ObjectProperty<Effect>The input for thisEffect.final DoublePropertyThe shadow offset in the x direction, in pixels.final DoublePropertyThe shadow offset in the y direction, in pixels.final DoublePropertyThe radius of the shadow blur kernel.final voidsetBlurType(BlurType value) Sets the value of theblurTypeproperty.final voidSets the value of thecolorproperty.final voidsetHeight(double value) Sets the value of theheightproperty.final voidSets the value of theinputproperty.final voidsetOffsetX(double value) Sets the value of theoffsetXproperty.final voidsetOffsetY(double value) Sets the value of theoffsetYproperty.final voidsetRadius(double value) Sets the value of theradiusproperty.final voidsetSpread(double value) Sets the value of thespreadproperty.final voidsetWidth(double value) Sets the value of thewidthproperty.final DoublePropertyThe spread of the shadow.final DoublePropertyThe horizontal size of the shadow blur kernel.
-
Property Details
-
input
The input for thisEffect. If set tonull, or left unspecified, a graphical image of theNodeto which theEffectis attached will be used as the input.- Default value:
- null
- See Also:
-
radius
The radius of the shadow blur kernel. This attribute controls the distance that the shadow is spread to each side of the source pixels. Setting the radius is equivalent to setting both thewidthandheightattributes to a value of(2 * radius + 1).Min: 0.0 Max: 127.0 Default: 10.0 Identity: 0.0- Default value:
- 10.0
- See Also:
-
width
The horizontal size of the shadow blur kernel. This attribute controls the horizontal size of the total area over which the shadow of a single pixel is distributed by the blur algorithm. Values less than1.0are not distributed beyond the original pixel and so have no blurring effect on the shadow.Min: 0.0 Max: 255.0 Default: 21.0 Identity: <1.0- Default value:
- 21.0
- See Also:
-
height
The vertical size of the shadow blur kernel. This attribute controls the vertical size of the total area over which the shadow of a single pixel is distributed by the blur algorithm. Values less than1.0are not distributed beyond the original pixel and so have no blurring effect on the shadow.Min: 0.0 Max: 255.0 Default: 21.0 Identity: <1.0- Default value:
- 21.0
- See Also:
-
blurType
The algorithm used to blur the shadow.Min: n/a Max: n/a Default: BlurType.THREE_PASS_BOX Identity: n/a- Default value:
- THREE_PASS_BOX
- See Also:
-
spread
The spread of the shadow. The spread is the portion of the radius where the contribution of the source material will be 100%. The remaining portion of the radius will have a contribution controlled by the blur kernel. A spread of0.0will result in a distribution of the shadow determined entirely by the blur algorithm. A spread of1.0will result in a solid growth outward of the source material opacity to the limit of the radius with a very sharp cutoff to transparency at the radius.Min: 0.0 Max: 1.0 Default: 0.0 Identity: 0.0- Default value:
- 0.0
- See Also:
-
color
The shadowColor.Min: n/a Max: n/a Default: Color.BLACK Identity: n/a- Default value:
- BLACK
- See Also:
-
offsetX
The shadow offset in the x direction, in pixels.Min: n/a Max: n/a Default: 0.0 Identity: 0.0- Default value:
- 0.0
- See Also:
-
offsetY
The shadow offset in the y direction, in pixels.Min: n/a Max: n/a Default: 0.0 Identity: 0.0- Default value:
- 0.0
- See Also:
-
-
Constructor Details
-
DropShadow
public DropShadow()Creates a new instance of DropShadow with default parameters. -
DropShadow
Creates a new instance of DropShadow with specified radius and color.- Parameters:
radius- the radius of the shadow blur kernelcolor- the shadowColor- Since:
- JavaFX 2.1
-
DropShadow
Creates a new instance of DropShadow with the specified radius, offsetX, offsetY and color.- Parameters:
radius- the radius of the shadow blur kerneloffsetX- the shadow offset in the x directionoffsetY- the shadow offset in the y directioncolor- the shadowColor- Since:
- JavaFX 2.1
-
DropShadow
public DropShadow(BlurType blurType, Color color, double radius, double spread, double offsetX, double offsetY) Creates a new instance of DropShadow with the specified blurType, color, radius, spread, offsetX and offsetY.- Parameters:
blurType- the algorithm used to blur the shadowcolor- the shadowColorradius- the radius of the shadow blur kernelspread- the portion of the radius where the contribution of the source material will be 100%offsetX- the shadow offset in the x directionoffsetY- the shadow offset in the y direction- Since:
- JavaFX 2.1
-
-
Method Details
-
setInput
Sets the value of theinputproperty.- Property description:
- The input for this
Effect. If set tonull, or left unspecified, a graphical image of theNodeto which theEffectis attached will be used as the input. - Default value:
- null
- Parameters:
value- the value for theinputproperty- See Also:
-
getInput
Gets the value of theinputproperty.- Property description:
- The input for this
Effect. If set tonull, or left unspecified, a graphical image of theNodeto which theEffectis attached will be used as the input. - Default value:
- null
- Returns:
- the value of the
inputproperty - See Also:
-
inputProperty
The input for thisEffect. If set tonull, or left unspecified, a graphical image of theNodeto which theEffectis attached will be used as the input.- Default value:
- null
- Returns:
- the
inputproperty - See Also:
-
setRadius
public final void setRadius(double value) Sets the value of theradiusproperty.- Property description:
- The radius of the shadow blur kernel.
This attribute controls the distance that the shadow is spread
to each side of the source pixels.
Setting the radius is equivalent to setting both the
widthandheightattributes to a value of(2 * radius + 1).Min: 0.0 Max: 127.0 Default: 10.0 Identity: 0.0 - Default value:
- 10.0
- Parameters:
value- the value for theradiusproperty- See Also:
-
getRadius
public final double getRadius()Gets the value of theradiusproperty.- Property description:
- The radius of the shadow blur kernel.
This attribute controls the distance that the shadow is spread
to each side of the source pixels.
Setting the radius is equivalent to setting both the
widthandheightattributes to a value of(2 * radius + 1).Min: 0.0 Max: 127.0 Default: 10.0 Identity: 0.0 - Default value:
- 10.0
- Returns:
- the value of the
radiusproperty - See Also:
-
radiusProperty
The radius of the shadow blur kernel. This attribute controls the distance that the shadow is spread to each side of the source pixels. Setting the radius is equivalent to setting both thewidthandheightattributes to a value of(2 * radius + 1).Min: 0.0 Max: 127.0 Default: 10.0 Identity: 0.0- Default value:
- 10.0
- Returns:
- the
radiusproperty - See Also:
-
setWidth
public final void setWidth(double value) Sets the value of thewidthproperty.- Property description:
- The horizontal size of the shadow blur kernel.
This attribute controls the horizontal size of the total area over
which the shadow of a single pixel is distributed by the blur algorithm.
Values less than
1.0are not distributed beyond the original pixel and so have no blurring effect on the shadow.Min: 0.0 Max: 255.0 Default: 21.0 Identity: <1.0 - Default value:
- 21.0
- Parameters:
value- the value for thewidthproperty- See Also:
-
getWidth
public final double getWidth()Gets the value of thewidthproperty.- Property description:
- The horizontal size of the shadow blur kernel.
This attribute controls the horizontal size of the total area over
which the shadow of a single pixel is distributed by the blur algorithm.
Values less than
1.0are not distributed beyond the original pixel and so have no blurring effect on the shadow.Min: 0.0 Max: 255.0 Default: 21.0 Identity: <1.0 - Default value:
- 21.0
- Returns:
- the value of the
widthproperty - See Also:
-
widthProperty
The horizontal size of the shadow blur kernel. This attribute controls the horizontal size of the total area over which the shadow of a single pixel is distributed by the blur algorithm. Values less than1.0are not distributed beyond the original pixel and so have no blurring effect on the shadow.Min: 0.0 Max: 255.0 Default: 21.0 Identity: <1.0- Default value:
- 21.0
- Returns:
- the
widthproperty - See Also:
-
setHeight
public final void setHeight(double value) Sets the value of theheightproperty.- Property description:
- The vertical size of the shadow blur kernel.
This attribute controls the vertical size of the total area over
which the shadow of a single pixel is distributed by the blur algorithm.
Values less than
1.0are not distributed beyond the original pixel and so have no blurring effect on the shadow.Min: 0.0 Max: 255.0 Default: 21.0 Identity: <1.0 - Default value:
- 21.0
- Parameters:
value- the value for theheightproperty- See Also:
-
getHeight
public final double getHeight()Gets the value of theheightproperty.- Property description:
- The vertical size of the shadow blur kernel.
This attribute controls the vertical size of the total area over
which the shadow of a single pixel is distributed by the blur algorithm.
Values less than
1.0are not distributed beyond the original pixel and so have no blurring effect on the shadow.Min: 0.0 Max: 255.0 Default: 21.0 Identity: <1.0 - Default value:
- 21.0
- Returns:
- the value of the
heightproperty - See Also:
-
heightProperty
The vertical size of the shadow blur kernel. This attribute controls the vertical size of the total area over which the shadow of a single pixel is distributed by the blur algorithm. Values less than1.0are not distributed beyond the original pixel and so have no blurring effect on the shadow.Min: 0.0 Max: 255.0 Default: 21.0 Identity: <1.0- Default value:
- 21.0
- Returns:
- the
heightproperty - See Also:
-
setBlurType
Sets the value of theblurTypeproperty.- Property description:
- The algorithm used to blur the shadow.
Min: n/a Max: n/a Default: BlurType.THREE_PASS_BOX Identity: n/a - Default value:
- THREE_PASS_BOX
- Parameters:
value- the value for theblurTypeproperty- See Also:
-
getBlurType
Gets the value of theblurTypeproperty.- Property description:
- The algorithm used to blur the shadow.
Min: n/a Max: n/a Default: BlurType.THREE_PASS_BOX Identity: n/a - Default value:
- THREE_PASS_BOX
- Returns:
- the value of the
blurTypeproperty - See Also:
-
blurTypeProperty
The algorithm used to blur the shadow.Min: n/a Max: n/a Default: BlurType.THREE_PASS_BOX Identity: n/a- Default value:
- THREE_PASS_BOX
- Returns:
- the
blurTypeproperty - See Also:
-
setSpread
public final void setSpread(double value) Sets the value of thespreadproperty.- Property description:
- The spread of the shadow.
The spread is the portion of the radius where the contribution of
the source material will be 100%.
The remaining portion of the radius will have a contribution
controlled by the blur kernel.
A spread of
0.0will result in a distribution of the shadow determined entirely by the blur algorithm. A spread of1.0will result in a solid growth outward of the source material opacity to the limit of the radius with a very sharp cutoff to transparency at the radius.Min: 0.0 Max: 1.0 Default: 0.0 Identity: 0.0 - Default value:
- 0.0
- Parameters:
value- the value for thespreadproperty- See Also:
-
getSpread
public final double getSpread()Gets the value of thespreadproperty.- Property description:
- The spread of the shadow.
The spread is the portion of the radius where the contribution of
the source material will be 100%.
The remaining portion of the radius will have a contribution
controlled by the blur kernel.
A spread of
0.0will result in a distribution of the shadow determined entirely by the blur algorithm. A spread of1.0will result in a solid growth outward of the source material opacity to the limit of the radius with a very sharp cutoff to transparency at the radius.Min: 0.0 Max: 1.0 Default: 0.0 Identity: 0.0 - Default value:
- 0.0
- Returns:
- the value of the
spreadproperty - See Also:
-
spreadProperty
The spread of the shadow. The spread is the portion of the radius where the contribution of the source material will be 100%. The remaining portion of the radius will have a contribution controlled by the blur kernel. A spread of0.0will result in a distribution of the shadow determined entirely by the blur algorithm. A spread of1.0will result in a solid growth outward of the source material opacity to the limit of the radius with a very sharp cutoff to transparency at the radius.Min: 0.0 Max: 1.0 Default: 0.0 Identity: 0.0- Default value:
- 0.0
- Returns:
- the
spreadproperty - See Also:
-
setColor
Sets the value of thecolorproperty.- Property description:
- The shadow
Color.Min: n/a Max: n/a Default: Color.BLACK Identity: n/a - Default value:
- BLACK
- Parameters:
value- the value for thecolorproperty- See Also:
-
getColor
Gets the value of thecolorproperty.- Property description:
- The shadow
Color.Min: n/a Max: n/a Default: Color.BLACK Identity: n/a - Default value:
- BLACK
- Returns:
- the value of the
colorproperty - See Also:
-
colorProperty
The shadowColor.Min: n/a Max: n/a Default: Color.BLACK Identity: n/a- Default value:
- BLACK
- Returns:
- the
colorproperty - See Also:
-
setOffsetX
public final void setOffsetX(double value) Sets the value of theoffsetXproperty.- Property description:
- The shadow offset in the x direction, in pixels.
Min: n/a Max: n/a Default: 0.0 Identity: 0.0 - Default value:
- 0.0
- Parameters:
value- the value for theoffsetXproperty- See Also:
-
getOffsetX
public final double getOffsetX()Gets the value of theoffsetXproperty.- Property description:
- The shadow offset in the x direction, in pixels.
Min: n/a Max: n/a Default: 0.0 Identity: 0.0 - Default value:
- 0.0
- Returns:
- the value of the
offsetXproperty - See Also:
-
offsetXProperty
The shadow offset in the x direction, in pixels.Min: n/a Max: n/a Default: 0.0 Identity: 0.0- Default value:
- 0.0
- Returns:
- the
offsetXproperty - See Also:
-
setOffsetY
public final void setOffsetY(double value) Sets the value of theoffsetYproperty.- Property description:
- The shadow offset in the y direction, in pixels.
Min: n/a Max: n/a Default: 0.0 Identity: 0.0 - Default value:
- 0.0
- Parameters:
value- the value for theoffsetYproperty- See Also:
-
getOffsetY
public final double getOffsetY()Gets the value of theoffsetYproperty.- Property description:
- The shadow offset in the y direction, in pixels.
Min: n/a Max: n/a Default: 0.0 Identity: 0.0 - Default value:
- 0.0
- Returns:
- the value of the
offsetYproperty - See Also:
-
offsetYProperty
The shadow offset in the y direction, in pixels.Min: n/a Max: n/a Default: 0.0 Identity: 0.0- Default value:
- 0.0
- Returns:
- the
offsetYproperty - See Also:
-