APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.scene.effect

public Class DropShadow

extends Effect
Class Inheritance
Imports
javafx.beans.property.DoubleProperty, .DoublePropertyBase, .ObjectProperty, .ObjectPropertyBase, javafx.scene.Node, javafx.scene.paint.Color, com.sun.javafx.util.Utils, com.sun.javafx.effect.EffectDirtyBits, com.sun.javafx.geom.BaseBounds, com.sun.javafx.geom.transform.BaseTransform, com.sun.javafx.scene.BoundsAccessor, com.sun.javafx.tk.Toolkit

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

Field Summary

Modifier and TypeField and Description
private ObjectProperty<BlurType>
blurType

The algorithm used to blur the shadow.

private boolean
private ObjectProperty<Color>
color

The shadow Color.

private DoubleProperty
height

The vertical size of the shadow blur kernel.

private ObjectProperty<Effect>
input

The input for this Effect.

private DoubleProperty
offsetX

The shadow offset in the x direction, in pixels.

private DoubleProperty
offsetY

The shadow offset in the y direction, in pixels.

private DoubleProperty
radius

The radius of the shadow blur kernel.

private DoubleProperty
spread

The spread of the shadow.

private DoubleProperty
width

The horizontal size of the shadow blur kernel.

Constructor Summary

AccessConstructor and Description
public
DropShadow()

Creates a new instance of DropShadow with default parameters.

public
DropShadow(double
the radius of the shadow blur kernel
radius
,
Color
the shadow Color
color
)

Creates a new instance of DropShadow with specified radius and color.

public
DropShadow(double
the radius of the shadow blur kernel
radius
,
double
the shadow offset in the x direction
offsetX
,
double
the shadow offset in the y direction
offsetY
,
Color
the shadow Color
color
)

Creates a new instance of DropShadow with the specified radius, offsetX, offsetY and color.

public
DropShadow(BlurType
the algorithm used to blur the shadow
blurType
,
Color
the shadow Color
color
,
double
the radius of the shadow blur kernel
radius
,
double
the portion of the radius where the contribution of the source material will be 100%
spread
,
double
the shadow offset in the x direction
offsetX
,
double
the shadow offset in the y direction
offsetY
)

Creates a new instance of DropShadow with the specified blurType, color, radius, spread, offsetX and offsetY.

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<BlurType>
pack-priv boolean
public final ObjectProperty<Color>
pack-priv Effect
copy()

Implements abstract javafx.scene.effect.Effect.copy.

pack-priv DropShadow
public final BlurType
private BlurType
pack-priv BaseBounds
getBounds(BaseBounds bounds, BaseTransform tx, Node node, BoundsAccessor boundsAccessor)

Implements abstract javafx.scene.effect.Effect.getBounds.

Returns bounds of given node with applied effect.

private float
private float
private float
public final Color
private Color
public final double
public final Effect
public final double
public final double
public final double
public final double
public final double
public final DoubleProperty
public final ObjectProperty<Effect>
public final DoubleProperty
public final DoubleProperty
public final DoubleProperty
public final void
public final void
setColor(Color value)

public final void
setHeight(double value)

public final void
public final void
setOffsetX(double value)

public final void
setOffsetY(double value)

public final void
setRadius(double value)

public final void
setSpread(double value)

public final void
setWidth(double value)

public final DoubleProperty
pack-priv void
private void
updateHeight(double value)

private void
updateRadius(double value)

private void
updateWidth(double value)

public final DoubleProperty
Inherited from javafx.scene.effect.Effect:
containsCycleseffectBoundsChangedgetInputBoundsgetKernelSizegetPeergetShadowBoundsmarkDirtysynctransformBounds

Field Detail

blurTypeback to summary
private ObjectProperty<BlurType> 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
changeIsLocalback to summary
private boolean changeIsLocal
colorback to summary
private ObjectProperty<Color> color

The shadow Color.

      Min: n/a
      Max: n/a
  Default: Color.BLACK
 Identity: n/a
Default Value
BLACK
heightback to summary
private DoubleProperty 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 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
inputback to summary
private ObjectProperty<Effect> input

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
offsetXback to summary
private DoubleProperty 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
offsetYback to summary
private DoubleProperty 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
radiusback to summary
private DoubleProperty 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 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
spreadback to summary
private DoubleProperty 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 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
widthback to summary
private DoubleProperty 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 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

Constructor Detail

DropShadowback to summary
public DropShadow()

Creates a new instance of DropShadow with default parameters.

DropShadowback to summary
public DropShadow(double radius, Color color)

Creates a new instance of DropShadow with specified radius and color.

Parameters
radius:double

the radius of the shadow blur kernel

color:Color

the shadow Color

Since
JavaFX 2.1
DropShadowback to summary
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:double

the radius of the shadow blur kernel

offsetX:double

the shadow offset in the x direction

offsetY:double

the shadow offset in the y direction

color:Color

the shadow Color

Since
JavaFX 2.1
DropShadowback to summary
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:BlurType

the algorithm used to blur the shadow

color:Color

the shadow Color

radius:double

the radius of the shadow blur kernel

spread:double

the portion of the radius where the contribution of the source material will be 100%

offsetX:double

the shadow offset in the x direction

offsetY:double

the shadow offset in the y direction

Since
JavaFX 2.1

Method Detail

blurTypePropertyback to summary
public final ObjectProperty<BlurType> blurTypeProperty()
checkChainContainsback to summary
pack-priv boolean checkChainContains(Effect e)

Implements abstract javafx.scene.effect.Effect.checkChainContains.

Annotations
@Override
colorPropertyback to summary
public final ObjectProperty<Color> colorProperty()
copyback to summary
pack-priv Effect copy()

Implements abstract javafx.scene.effect.Effect.copy.

Annotations
@Override
createPeerback to summary
pack-priv DropShadow createPeer()

Implements abstract javafx.scene.effect.Effect.createPeer.

Annotations
@Override
getBlurTypeback to summary
public final BlurType getBlurType()
getBlurTypeInternalback to summary
private BlurType getBlurTypeInternal()
getBoundsback to summary
pack-priv BaseBounds getBounds(BaseBounds bounds, BaseTransform tx, Node node, BoundsAccessor boundsAccessor)

Implements abstract javafx.scene.effect.Effect.getBounds.

Doc from javafx.scene.effect.Effect.getBounds.

Returns bounds of given node with applied effect. We *never* pass null in as a bounds. This method will NOT take a null bounds object. The returned value may be the same bounds object passed in, or it may be a new object.

Annotations
@Override
getClampedHeightback to summary
private float getClampedHeight()
getClampedSpreadback to summary
private float getClampedSpread()
getClampedWidthback to summary
private float getClampedWidth()
getColorback to summary
public final Color getColor()
getColorInternalback to summary
private Color getColorInternal()
getHeightback to summary
public final double getHeight()
getInputback to summary
public final Effect getInput()
getOffsetXback to summary
public final double getOffsetX()
getOffsetYback to summary
public final double getOffsetY()
getRadiusback to summary
public final double getRadius()
getSpreadback to summary
public final double getSpread()
getWidthback to summary
public final double getWidth()
heightPropertyback to summary
public final DoubleProperty heightProperty()
inputPropertyback to summary
public final ObjectProperty<Effect> inputProperty()
offsetXPropertyback to summary
public final DoubleProperty offsetXProperty()
offsetYPropertyback to summary
public final DoubleProperty offsetYProperty()
radiusPropertyback to summary
public final DoubleProperty radiusProperty()
setBlurTypeback to summary
public final void setBlurType(BlurType value)
setColorback to summary
public final void setColor(Color value)
setHeightback to summary
public final void setHeight(double value)
setInputback to summary
public final void setInput(Effect value)
setOffsetXback to summary
public final void setOffsetX(double value)
setOffsetYback to summary
public final void setOffsetY(double value)
setRadiusback to summary
public final void setRadius(double value)
setSpreadback to summary
public final void setSpread(double value)
setWidthback to summary
public final void setWidth(double value)
spreadPropertyback to summary
public final DoubleProperty spreadProperty()
updateback to summary
pack-priv void update()

Implements abstract javafx.scene.effect.Effect.update.

Annotations
@Override
updateHeightback to summary
private void updateHeight(double value)
updateRadiusback to summary
private void updateRadius(double value)
updateWidthback to summary
private void updateWidth(double value)
widthPropertyback to summary
public final DoubleProperty widthProperty()