Spec-Zone.ru › OpenJavaFX 17

Class DropShadow

java.lang.Object
javafx.scene.effect.Effect
javafx.scene.effect.DropShadow
public class DropShadow
extends Effect
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:

The visual effect of DropShadow on
 cirle and text

Since:
JavaFX 2.0

Property Summary

Properties
Type Property Description
ObjectProperty<BlurType> blurType
The algorithm used to blur the shadow.
ObjectProperty<Color> color
The shadow Color.
DoubleProperty height
The vertical size of the shadow blur kernel.
ObjectProperty<Effect> input
The input for this Effect.
DoubleProperty offsetX
The shadow offset in the x direction, in pixels.
DoubleProperty offsetY
The shadow offset in the y direction, in pixels.
DoubleProperty radius
The radius of the shadow blur kernel.
DoubleProperty spread
The spread of the shadow.
DoubleProperty width
The horizontal size of the shadow blur kernel.

Constructor Summary

Constructors
Constructor Description
DropShadow()
Creates 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 Type Method Description
ObjectProperty<BlurType> blurTypeProperty()
The algorithm used to blur the shadow.
ObjectProperty<Color> colorProperty()
The shadow Color.
BlurType getBlurType()
Gets the value of the property blurType.
Color getColor()
Gets the value of the property color.
double getHeight()
Gets the value of the property height.
Effect getInput()
Gets the value of the property input.
double getOffsetX()
Gets the value of the property offsetX.
double getOffsetY()
Gets the value of the property offsetY.
double getRadius()
Gets the value of the property radius.
double getSpread()
Gets the value of the property spread.
double getWidth()
Gets the value of the property width.
DoubleProperty heightProperty()
The vertical size of the shadow blur kernel.
ObjectProperty<Effect> inputProperty()
The input for this Effect.
DoubleProperty offsetXProperty()
The shadow offset in the x direction, in pixels.
DoubleProperty offsetYProperty()
The shadow offset in the y direction, in pixels.
DoubleProperty radiusProperty()
The radius of the shadow blur kernel.
void setBlurType​(BlurType value)
Sets the value of the property blurType.
void setColor​(Color value)
Sets the value of the property color.
void setHeight​(double value)
Sets the value of the property height.
void setInput​(Effect value)
Sets the value of the property input.
void setOffsetX​(double value)
Sets the value of the property offsetX.
void setOffsetY​(double value)
Sets the value of the property offsetY.
void setRadius​(double value)
Sets the value of the property radius.
void setSpread​(double value)
Sets the value of the property spread.
void setWidth​(double value)
Sets the value of the property width.
DoubleProperty spreadProperty()
The spread of the shadow.
DoubleProperty widthProperty()
The horizontal size of the shadow blur kernel.

Methods declared in class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Property Details

input

public final ObjectProperty<Effect> inputProperty
The input for this Effect. If set to null, or left unspecified, a graphical image of the Node to which the Effect is attached will be used as the input.
Default value:
null
See Also:
getInput(), setInput(Effect)

radius

public final DoubleProperty 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 the width and height attributes 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:
getRadius(), setRadius(double)

width

public final DoubleProperty 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 than 1.0 are 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:
getWidth(), setWidth(double)

height

public final DoubleProperty 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 than 1.0 are 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:
getHeight(), setHeight(double)

blurType

public final ObjectProperty<BlurType> 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
See Also:
getBlurType(), setBlurType(BlurType)

spread

public final DoubleProperty 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 of 0.0 will result in a distribution of the shadow determined entirely by the blur algorithm. A spread of 1.0 will 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:
getSpread(), setSpread(double)

color

public final ObjectProperty<Color> colorProperty
The shadow Color.
       Min: n/a
       Max: n/a
   Default: Color.BLACK
  Identity: n/a
 
Default value:
BLACK
See Also:
getColor(), setColor(Color)

offsetX

public final DoubleProperty 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
See Also:
getOffsetX(), setOffsetX(double)

offsetY

public final DoubleProperty 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
See Also:
getOffsetY(), setOffsetY(double)

Constructor Details

DropShadow

public DropShadow()
Creates a new instance of DropShadow with default parameters.

DropShadow

public DropShadow(double radius, Color color)
Creates a new instance of DropShadow with specified radius and color.
Parameters:
radius - the radius of the shadow blur kernel
color - the shadow Color
Since:
JavaFX 2.1

DropShadow

public DropShadow(double radius, double offsetX, double offsetY, Color color)
Creates a new instance of DropShadow with the specified radius, offsetX, offsetY and color.
Parameters:
radius - the radius of the shadow blur kernel
offsetX - the shadow offset in the x direction
offsetY - the shadow offset in the y direction
color - the shadow Color
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 shadow
color - the shadow Color
radius - the radius of the shadow blur kernel
spread - the portion of the radius where the contribution of the source material will be 100%
offsetX - the shadow offset in the x direction
offsetY - the shadow offset in the y direction
Since:
JavaFX 2.1

Method Details

setInput

public final void setInput(Effect value)
Sets the value of the property input.
Property description:
The input for this Effect. If set to null, or left unspecified, a graphical image of the Node to which the Effect is attached will be used as the input.
Default value:
null

getInput

public final Effect getInput()
Gets the value of the property input.
Property description:
The input for this Effect. If set to null, or left unspecified, a graphical image of the Node to which the Effect is attached will be used as the input.
Default value:
null

inputProperty

public final ObjectProperty<Effect> inputProperty()
The input for this Effect. If set to null, or left unspecified, a graphical image of the Node to which the Effect is attached will be used as the input.
Default value:
null
See Also:
getInput(), setInput(Effect)

setRadius

public final void setRadius(double value)
Sets the value of the property radius.
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 width and height attributes to a value of (2 * radius + 1).
       Min:   0.0
       Max: 127.0
   Default:  10.0
  Identity:   0.0
 
Default value:
10.0

getRadius

public final double getRadius()
Gets the value of the property radius.
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 width and height attributes to a value of (2 * radius + 1).
       Min:   0.0
       Max: 127.0
   Default:  10.0
  Identity:   0.0
 
Default value:
10.0

radiusProperty

public final DoubleProperty 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 the width and height attributes 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:
getRadius(), setRadius(double)

setWidth

public final void setWidth(double value)
Sets the value of the property width.
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.0 are 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

getWidth

public final double getWidth()
Gets the value of the property width.
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.0 are 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

widthProperty

public final DoubleProperty 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 than 1.0 are 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:
getWidth(), setWidth(double)

setHeight

public final void setHeight(double value)
Sets the value of the property height.
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.0 are 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

getHeight

public final double getHeight()
Gets the value of the property height.
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.0 are 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

heightProperty

public final DoubleProperty 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 than 1.0 are 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:
getHeight(), setHeight(double)

setBlurType

public final void setBlurType(BlurType value)
Sets the value of the property blurType.
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

getBlurType

public final BlurType getBlurType()
Gets the value of the property blurType.
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

blurTypeProperty

public final ObjectProperty<BlurType> 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
See Also:
getBlurType(), setBlurType(BlurType)

setSpread

public final void setSpread(double value)
Sets the value of the property spread.
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.0 will result in a distribution of the shadow determined entirely by the blur algorithm. A spread of 1.0 will 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

getSpread

public final double getSpread()
Gets the value of the property spread.
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.0 will result in a distribution of the shadow determined entirely by the blur algorithm. A spread of 1.0 will 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

spreadProperty

public final DoubleProperty 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 of 0.0 will result in a distribution of the shadow determined entirely by the blur algorithm. A spread of 1.0 will 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:
getSpread(), setSpread(double)

setColor

public final void setColor(Color value)
Sets the value of the property color.
Property description:
The shadow Color.
       Min: n/a
       Max: n/a
   Default: Color.BLACK
  Identity: n/a
 
Default value:
BLACK

getColor

public final Color getColor()
Gets the value of the property color.
Property description:
The shadow Color.
       Min: n/a
       Max: n/a
   Default: Color.BLACK
  Identity: n/a
 
Default value:
BLACK

colorProperty

public final ObjectProperty<Color> colorProperty()
The shadow Color.
       Min: n/a
       Max: n/a
   Default: Color.BLACK
  Identity: n/a
 
Default value:
BLACK
See Also:
getColor(), setColor(Color)

setOffsetX

public final void setOffsetX(double value)
Sets the value of the property offsetX.
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

getOffsetX

public final double getOffsetX()
Gets the value of the property offsetX.
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

offsetXProperty

public final DoubleProperty 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
See Also:
getOffsetX(), setOffsetX(double)

setOffsetY

public final void setOffsetY(double value)
Sets the value of the property offsetY.
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

getOffsetY

public final double getOffsetY()
Gets the value of the property offsetY.
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

offsetYProperty

public final DoubleProperty 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
See Also:
getOffsetY(), setOffsetY(double)

© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API