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

public Class Lighting

extends Effect
Class Inheritance
Imports
javafx.beans.Observable, javafx.beans.property.DoubleProperty, .DoublePropertyBase, .ObjectProperty, .ObjectPropertyBase, javafx.scene.Node, 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.scenario.effect.PhongLighting

An effect that simulates a light source shining on the given content, which can be used to give flat objects a more realistic, three-dimensional appearance.

Example:

Light.Distant light = new Light.Distant();
light.setAzimuth(-135.0);

Lighting lighting = new Lighting();
lighting.setLight(light);
lighting.setSurfaceScale(5.0);

Text text = new Text();
text.setText("JavaFX!");
text.setFill(Color.STEELBLUE);
text.setFont(Font.font(null, FontWeight.BOLD, 60));
text.setX(10.0);
text.setY(10.0);
text.setTextOrigin(VPos.TOP);

text.setEffect(lighting);

The code above produces the following:

The visual effect of Lighting on text

Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private ObjectProperty<Effect>
bumpInput

The optional bump map input.

private ObjectProperty<Effect>
contentInput

The content input for this Effect.

private final Light
private DoubleProperty
diffuseConstant

The diffuse constant.

private ObjectProperty<Light>
light

The light source for this Lighting effect.

private final Lighting.LightChangeListener
private DoubleProperty
specularConstant

The specular constant.

private DoubleProperty
specularExponent

The specular exponent.

private DoubleProperty
surfaceScale

The surface scale factor.

Constructor Summary

AccessConstructor and Description
public
Lighting()

Creates a new instance of Lighting with default parameters.

public
Lighting(Light
the light source for this Lighting effect
light
)

Creates a new instance of Lighting with the specified light.

Method Summary

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

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

pack-priv PhongLighting
public final DoubleProperty
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.

public final Effect
public final Effect
public final double
public final Light
private Light
public final double
public final double
public final double
public final ObjectProperty<Light>
public final void
public final void
public final void
setDiffuseConstant(double value)

public final void
setLight(Light value)

public final void
setSpecularConstant(double value)

public final void
setSpecularExponent(double value)

public final void
setSurfaceScale(double value)

public final DoubleProperty
public final DoubleProperty
public final DoubleProperty
pack-priv void
Inherited from javafx.scene.effect.Effect:
containsCycleseffectBoundsChangedgetInputBoundsgetKernelSizegetPeergetShadowBoundsmarkDirtysynctransformBounds

Field Detail

bumpInputback to summary
private ObjectProperty<Effect> bumpInput

The optional bump map input. If not specified, a bump map will be automatically generated from the default input. If set to null, or left unspecified, a graphical image of the Node to which the Effect is attached will be used to generate a default bump map.

Default Value
a Shadow effect with a radius of 10
contentInputback to summary
private ObjectProperty<Effect> contentInput

The content 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
defaultLightback to summary
private final Light defaultLight
diffuseConstantback to summary
private DoubleProperty diffuseConstant

The diffuse constant.

      Min: 0.0
      Max: 2.0
  Default: 1.0
 Identity: n/a
Default Value
1.0
lightback to summary
private ObjectProperty<Light> light

The light source for this Lighting effect.

lightChangeListenerback to summary
private final Lighting.LightChangeListener lightChangeListener
specularConstantback to summary
private DoubleProperty specularConstant

The specular constant.

      Min: 0.0
      Max: 2.0
  Default: 0.3
 Identity: n/a
Default Value
0.3
specularExponentback to summary
private DoubleProperty specularExponent

The specular exponent.

      Min:  0.0
      Max: 40.0
  Default: 20.0
 Identity:  n/a
Default Value
20.0
surfaceScaleback to summary
private DoubleProperty surfaceScale

The surface scale factor.

      Min:  0.0
      Max: 10.0
  Default:  1.5
 Identity:  n/a
Default Value
1.5

Constructor Detail

Lightingback to summary
public Lighting()

Creates a new instance of Lighting with default parameters.

Lightingback to summary
public Lighting(Light light)

Creates a new instance of Lighting with the specified light.

Parameters
light:Light

the light source for this Lighting effect

Since
JavaFX 2.1

Method Detail

bumpInputPropertyback to summary
public final ObjectProperty<Effect> bumpInputProperty()
checkChainContainsback to summary
pack-priv boolean checkChainContains(Effect e)

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

Annotations
@Override
contentInputPropertyback to summary
public final ObjectProperty<Effect> contentInputProperty()
copyback to summary
pack-priv Effect copy()

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

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

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

Annotations
@Override
diffuseConstantPropertyback to summary
public final DoubleProperty diffuseConstantProperty()
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
getBumpInputback to summary
public final Effect getBumpInput()
getContentInputback to summary
public final Effect getContentInput()
getDiffuseConstantback to summary
public final double getDiffuseConstant()
getLightback to summary
public final Light getLight()
getLightInternalback to summary
private Light getLightInternal()
getSpecularConstantback to summary
public final double getSpecularConstant()
getSpecularExponentback to summary
public final double getSpecularExponent()
getSurfaceScaleback to summary
public final double getSurfaceScale()
lightPropertyback to summary
public final ObjectProperty<Light> lightProperty()
setBumpInputback to summary
public final void setBumpInput(Effect value)
setContentInputback to summary
public final void setContentInput(Effect value)
setDiffuseConstantback to summary
public final void setDiffuseConstant(double value)
setLightback to summary
public final void setLight(Light value)
setSpecularConstantback to summary
public final void setSpecularConstant(double value)
setSpecularExponentback to summary
public final void setSpecularExponent(double value)
setSurfaceScaleback to summary
public final void setSurfaceScale(double value)
specularConstantPropertyback to summary
public final DoubleProperty specularConstantProperty()
specularExponentPropertyback to summary
public final DoubleProperty specularExponentProperty()
surfaceScalePropertyback to summary
public final DoubleProperty surfaceScaleProperty()
updateback to summary
pack-priv void update()

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

Annotations
@Override
javafx.scene.effect back to summary

private Class Lighting.LightChangeListener

extends EffectChangeListener
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv Light
Inherited from javafx.scene.effect.EffectChangeListener:
registredOn

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
invalidated(Observable valueModel)

Implements javafx.beans.InvalidationListener.invalidated.

This method needs to be provided by an implementation of InvalidationListener.

public void
register(Light value)

Inherited from javafx.scene.effect.EffectChangeListener:
register

Field Detail

lightback to summary
pack-priv Light light

Constructor Detail

LightChangeListenerback to summary
private LightChangeListener()

Method Detail

invalidatedback to summary
public void invalidated(Observable valueModel)

Implements javafx.beans.InvalidationListener.invalidated.

Doc from javafx.beans.InvalidationListener.invalidated.

This method needs to be provided by an implementation of InvalidationListener. It is called if an Observable becomes invalid.

In general, it is considered bad practice to modify the observed value in this method.

Annotations
@Override
registerback to summary
public void register(Light value)