Top Description Inners Fields Constructors Methods
com.sun.scenario.effect

public Class Blend

extends CoreEffect<RenderState>
Class Inheritance
Known Direct Subclasses
com.sun.javafx.sg.prism.NGCanvas.MyBlend
Imports
com.sun.javafx.geom.Point2D, .Rectangle, com.sun.javafx.geom.transform.BaseTransform, com.sun.scenario.effect.impl.state.RenderState

An effect that blends the two inputs together using one of the pre-defined Modes.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Blend.Mode

A blending mode that defines the manner in which the inputs are composited together.

Field Summary

Modifier and TypeField and Description
private Blend.Mode
private float

Constructor Summary

AccessConstructor and Description
public
Blend(Blend.Mode
the blending mode
mode
,
Effect
the bottom input
bottomInput
,
Effect
the top input
topInput
)

Constructs a new Blend effect with the given mode and the default opacity (1.0).

Method Summary

Modifier and TypeMethod and Description
public final Effect

Returns:

the bottom input for this Effect
getBottomInput
()

Returns the bottom input for this Effect.

public Blend.Mode

Returns:

the Mode used to blend the two inputs together.
getMode
()

Returns the Mode used to blend the two inputs together.

public float

Returns:

the opacity value
getOpacity
()

Returns the opacity value, which is modulated with the top input prior to blending.

public RenderState
getRenderState(FilterContext fctx, BaseTransform transform, Rectangle outputClip, Object renderHelper, Effect defaultInput)

Implements abstract com.sun.scenario.effect.FilterEffect.getRenderState.

Returns the object representing the rendering strategy and state for the filter operation characterized by the specified arguments.

public final Effect

Returns:

the top input for this Effect
getTopInput
()

Returns the top input for this Effect.

public boolean
reducesOpaquePixels()

Implements abstract com.sun.scenario.effect.Effect.reducesOpaquePixels.

Whether an opacity for any pixel is different (lower) than the corresponding pixel in the default input.

public void
setBottomInput(Effect
the bottom input for this Effect
bottomInput
)

Sets the bottom input for this Effect to a specific Effect or to the default input if input is null.

public void
setMode(Blend.Mode
the blending mode
mode
)

Sets the Mode used to blend the two inputs together.

public void
setOpacity(float
the opacity value
opacity
)

Sets the opacity value, which is modulated with the top input prior to blending.

public void
setTopInput(Effect
the top input for this Effect
topInput
)

Sets the top input for this Effect to a specific Effect or to the default input if input is null.

public Point2D

Returns:

the transformed point in the coordinate space of the result
transform
(Point2D
the point in the coordinate space of the primary content input to be transformed
p
,
Effect
the default input Effect to be used in all cases where a filter has a null input
defaultInput
)

Overrides com.sun.scenario.effect.FilterEffect.transform.

Transform the specified point p from the coordinate space of the primary content input to the coordinate space of the effect output.

public Point2D

Returns:

the untransformed point in the coordinate space of the primary content input
untransform
(Point2D
the point in the coordinate space of the result output to be transformed
p
,
Effect
the default input Effect to be used in all cases where a filter has a null input
defaultInput
)

Overrides com.sun.scenario.effect.FilterEffect.untransform.

Transform the specified point p from the coordinate space of the output of the effect into the coordinate space of the primary content input.

Inherited from com.sun.scenario.effect.CoreEffect:
filterImageDatasgetAccelTypegetPeerupdatePeerKeyupdatePeerKey

Field Detail

modeback to summary
private Blend.Mode mode
opacityback to summary
private float opacity

Constructor Detail

Blendback to summary
public Blend(Blend.Mode mode, Effect bottomInput, Effect topInput)

Constructs a new Blend effect with the given mode and the default opacity (1.0). Either or both inputs may be null to indicate that the default input should be used.

Parameters
mode:Blend.Mode

the blending mode

bottomInput:Effect

the bottom input

topInput:Effect

the top input

Exceptions
IllegalArgumentException:
if mode is null

Method Detail

getBottomInputback to summary
public final Effect getBottomInput()

Returns the bottom input for this Effect.

Returns:Effect

the bottom input for this Effect

getModeback to summary
public Blend.Mode getMode()

Returns the Mode used to blend the two inputs together.

Returns:Blend.Mode

the Mode used to blend the two inputs together.

getOpacityback to summary
public float getOpacity()

Returns the opacity value, which is modulated with the top input prior to blending.

Returns:float

the opacity value

getRenderStateback to summary
public RenderState getRenderState(FilterContext fctx, BaseTransform transform, Rectangle outputClip, Object renderHelper, Effect defaultInput)

Implements abstract com.sun.scenario.effect.FilterEffect.getRenderState.

Doc from com.sun.scenario.effect.FilterEffect.getRenderState.

Returns the object representing the rendering strategy and state for the filter operation characterized by the specified arguments. This call can also be used to get a state object for non-rendering cases like querying the bounds of an operation in which case the FilterContext object may be null. outputClip and renderHelper may always be null just as they may be null for a given filter operation.

Annotations
@Override
getTopInputback to summary
public final Effect getTopInput()

Returns the top input for this Effect.

Returns:Effect

the top input for this Effect

reducesOpaquePixelsback to summary
public boolean reducesOpaquePixels()

Implements abstract com.sun.scenario.effect.Effect.reducesOpaquePixels.

Doc from com.sun.scenario.effect.Effect.reducesOpaquePixels.

Whether an opacity for any pixel is different (lower) than the corresponding pixel in the default input. It is always safe to return true from this method, though the consequences may be that the caller chooses to not utilize a planned optimization.

Annotations
@Override
setBottomInputback to summary
public void setBottomInput(Effect bottomInput)

Sets the bottom input for this Effect to a specific Effect or to the default input if input is null.

Parameters
bottomInput:Effect

the bottom input for this Effect

setModeback to summary
public void setMode(Blend.Mode mode)

Sets the Mode used to blend the two inputs together.

      Min: n/a
      Max: n/a
  Default: Mode.SRC_OVER
 Identity: n/a
Parameters
mode:Blend.Mode

the blending mode

Exceptions
IllegalArgumentException:
if mode is null
setOpacityback to summary
public void setOpacity(float opacity)

Sets the opacity value, which is modulated with the top input prior to blending.

      Min: 0.0
      Max: 1.0
  Default: 1.0
 Identity: 1.0
Parameters
opacity:float

the opacity value

Exceptions
IllegalArgumentException:
if opacity is outside the allowable range
setTopInputback to summary
public void setTopInput(Effect topInput)

Sets the top input for this Effect to a specific Effect or to the default input if input is null.

Parameters
topInput:Effect

the top input for this Effect

transformback to summary
public Point2D transform(Point2D p, Effect defaultInput)

Overrides com.sun.scenario.effect.FilterEffect.transform.

Transform the specified point p from the coordinate space of the primary content input to the coordinate space of the effect output. In essence, this method asks the question "Which output coordinate is most affected by the data at the specified coordinate in the primary source input?"

The Blend effect delegates this operation to its top input, or the defaultInput if the top input is null.

Parameters
p:Point2D

the point in the coordinate space of the primary content input to be transformed

defaultInput:Effect

the default input Effect to be used in all cases where a filter has a null input

Returns:Point2D

the transformed point in the coordinate space of the result

Annotations
@Override
untransformback to summary
public Point2D untransform(Point2D p, Effect defaultInput)

Overrides com.sun.scenario.effect.FilterEffect.untransform.

Transform the specified point p from the coordinate space of the output of the effect into the coordinate space of the primary content input. In essence, this method asks the question "Which source coordinate contributes most to the definition of the output at the specified coordinate?"

The Blend effect delegates this operation to its top input, or the defaultInput if the top input is null.

Parameters
p:Point2D

the point in the coordinate space of the result output to be transformed

defaultInput:Effect

the default input Effect to be used in all cases where a filter has a null input

Returns:Point2D

the untransformed point in the coordinate space of the primary content input

Annotations
@Override
com.sun.scenario.effect back to summary

public final Enum Blend.Mode

extends Enum<Blend.Mode>
Class Inheritance

A blending mode that defines the manner in which the inputs are composited together. Each Mode describes a mathematical equation that combines premultiplied inputs to produce some premultiplied result.

Field Summary

Modifier and TypeField and Description
public static final Blend.Mode
ADD

The color and alpha components from the top input are added to those from the bottom input.

public static final Blend.Mode
BLUE

The blue component of the bottom input is replaced with the blue component of the top input; the other color components are unaffected.

public static final Blend.Mode
COLOR_BURN

The inverse of the bottom input color components are divided by the top input color components, all of which is then inverted to produce the resulting color.

public static final Blend.Mode
COLOR_DODGE

The bottom input color components are divided by the inverse of the top input color components to produce the resulting color.

public static final Blend.Mode
DARKEN

REMIND: cross check this formula with OpenVG spec...

public static final Blend.Mode
DIFFERENCE

The darker of the color components from the two inputs are subtracted from the lighter ones to produce the resulting color.

public static final Blend.Mode
EXCLUSION

The color components from the two inputs are multiplied and doubled, and then subtracted from the sum of the bottom input color components, to produce the resulting color.

public static final Blend.Mode
GREEN

The green component of the bottom input is replaced with the green component of the top input; the other color components are unaffected.

public static final Blend.Mode
HARD_LIGHT

The input color components are either multiplied or screened, depending on the top input color.

public static final Blend.Mode
LIGHTEN

REMIND: cross check this formula with OpenVG spec...

public static final Blend.Mode
MULTIPLY

The color components from the first input are multiplied with those from the second input.

public static final Blend.Mode
OVERLAY

The input color components are either multiplied or screened, depending on the bottom input color.

public static final Blend.Mode
RED

The red component of the bottom input is replaced with the red component of the top input; the other color components are unaffected.

public static final Blend.Mode
SCREEN

The color components from both of the inputs are inverted, multiplied with each other, and that result is again inverted to produce the resulting color.

public static final Blend.Mode
SOFT_LIGHT

REMIND: this is a complicated formula, TBD...

public static final Blend.Mode
SRC_ATOP

The part of the top input lying inside of the bottom input is blended with the bottom input.

public static final Blend.Mode
SRC_IN

The part of the top input lying inside of the bottom input is kept in the resulting image.

public static final Blend.Mode
SRC_OUT

The part of the top input lying outside of the bottom input is kept in the resulting image.

public static final Blend.Mode
SRC_OVER

The top input is blended over the bottom input.

Constructor Summary

AccessConstructor and Description
private
Mode()

Method Summary

Modifier and TypeMethod and Description
public static Blend.Mode
public static Blend.Mode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ADDback to summary
public static final Blend.Mode ADD

The color and alpha components from the top input are added to those from the bottom input. The result is clamped to 1.0 if it exceeds the logical maximum of 1.0.

Thus:

     Ar = min(1, Atop+Abot)
     Cr = min(1, Ctop+Cbot)

Notes:

  • This mode is commutative (ordering of inputs does not matter).
  • This mode is sometimes referred to as "linear dodge" in imaging software packages.
BLUEback to summary
public static final Blend.Mode BLUE

The blue component of the bottom input is replaced with the blue component of the top input; the other color components are unaffected. The alpha components are blended according to the SRC_OVER equation.

Thus:

     Ar = Atop + Abot*(1-Atop)
     Rr = Rbot
     Gr = Gbot
     Br = Btop
COLOR_BURNback to summary
public static final Blend.Mode COLOR_BURN

The inverse of the bottom input color components are divided by the top input color components, all of which is then inverted to produce the resulting color. The alpha components are blended according to the SRC_OVER equation.

Thus:

     Ar = Atop + Abot*(1-Atop)
     Cr = 1-((1-Cbot) / Ctop)
COLOR_DODGEback to summary
public static final Blend.Mode COLOR_DODGE

The bottom input color components are divided by the inverse of the top input color components to produce the resulting color. The alpha components are blended according to the SRC_OVER equation.

Thus:

     Ar = Atop + Abot*(1-Atop)
     Cr = Cbot / (1-Ctop)
DARKENback to summary
public static final Blend.Mode DARKEN

REMIND: cross check this formula with OpenVG spec... The darker of the color components from the two inputs are selected to produce the resulting color. The alpha components are blended according to the SRC_OVER equation.

Thus:

     Ar = Atop + Abot*(1-Atop)
     Cr = min(Ctop, Cbot)

Notes:

  • This mode is commutative (ordering of inputs does not matter).
  • This mode is the mathematical opposite of the LIGHTEN mode.
DIFFERENCEback to summary
public static final Blend.Mode DIFFERENCE

The darker of the color components from the two inputs are subtracted from the lighter ones to produce the resulting color. The alpha components are blended according to the SRC_OVER equation.

Thus:

     Ar = Atop + Abot*(1-Atop)
     Cr = abs(Ctop-Cbot)

Notes:

  • This mode is commutative (ordering of inputs does not matter).
  • This mode can be used to invert parts of the bottom input image, or to quickly compare two images (equal pixels will result in black).
  • Rendering with a completely white top input inverts the bottom input; rendering with a completely black top input produces a result equivalent to the bottom input.
EXCLUSIONback to summary
public static final Blend.Mode EXCLUSION

The color components from the two inputs are multiplied and doubled, and then subtracted from the sum of the bottom input color components, to produce the resulting color. The alpha components are blended according to the SRC_OVER equation.

Thus:

     Ar = Atop + Abot*(1-Atop)
     Cr = Ctop + Cbot - (2*Ctop*Cbot)

Notes:

  • This mode is commutative (ordering of inputs does not matter).
  • This mode can be used to invert parts of the bottom input.
  • This mode produces results that are similar to those of DIFFERENCE, except with lower contrast.
  • Rendering with a completely white top input inverts the bottom input; rendering with a completely black top input produces a result equivalent to the bottom input.
GREENback to summary
public static final Blend.Mode GREEN

The green component of the bottom input is replaced with the green component of the top input; the other color components are unaffected. The alpha components are blended according to the SRC_OVER equation.

Thus:

     Ar = Atop + Abot*(1-Atop)
     Rr = Rbot
     Gr = Gtop
     Br = Bbot
HARD_LIGHTback to summary
public static final Blend.Mode HARD_LIGHT

The input color components are either multiplied or screened, depending on the top input color. The alpha components are blended according to the SRC_OVER equation.

Thus:

     Ar = Atop + Abot*(1-Atop)
     REMIND: not sure how to express this succinctly yet...

Notes:

  • This mode is a combination of SCREEN and MULTIPLY, depending on the top input color.
  • This mode is the mathematical opposite of the OVERLAY mode.
LIGHTENback to summary
public static final Blend.Mode LIGHTEN

REMIND: cross check this formula with OpenVG spec... The lighter of the color components from the two inputs are selected to produce the resulting color. The alpha components are blended according to the SRC_OVER equation.

Thus:

     Ar = Atop + Abot*(1-Atop)
     Cr = max(Ctop, Cbot)

Notes:

  • This mode is commutative (ordering of inputs does not matter).
  • This mode is the mathematical opposite of the DARKEN mode.
MULTIPLYback to summary
public static final Blend.Mode MULTIPLY

The color components from the first input are multiplied with those from the second input. The alpha components are blended according to the SRC_OVER equation.

Thus:

     Ar = Atop + Abot*(1-Atop)
     Cr = Ctop * Cbot

Notes:

  • This mode is commutative (ordering of inputs does not matter).
  • This mode is the mathematical opposite of the SCREEN mode.
  • The resulting color is always at least as dark as either of the input colors.
  • Rendering with a completely black top input produces black; rendering with a completely white top input produces a result equivalent to the bottom input.
OVERLAYback to summary
public static final Blend.Mode OVERLAY

The input color components are either multiplied or screened, depending on the bottom input color. The alpha components are blended according to the SRC_OVER equation.

Thus:

     Ar = Atop + Abot*(1-Atop)
     REMIND: not sure how to express this succinctly yet...

Notes:

  • This mode is a combination of SCREEN and MULTIPLY, depending on the bottom input color.
  • This mode is the mathematical opposite of the HARD_LIGHT mode.
  • In this mode, the top input colors "overlay" the bottom input while preserving highlights and shadows of the latter.
REDback to summary
public static final Blend.Mode RED

The red component of the bottom input is replaced with the red component of the top input; the other color components are unaffected. The alpha components are blended according to the SRC_OVER equation.

Thus:

     Ar = Atop + Abot*(1-Atop)
     Rr = Rtop
     Gr = Gbot
     Br = Bbot
SCREENback to summary
public static final Blend.Mode SCREEN

The color components from both of the inputs are inverted, multiplied with each other, and that result is again inverted to produce the resulting color. The alpha components are blended according to the SRC_OVER equation.

Thus:

     Ar = Atop + Abot*(1-Atop)
     Cr = 1 - ((1-Ctop) * (1-Cbot))

Notes:

  • This mode is commutative (ordering of inputs does not matter).
  • This mode is the mathematical opposite of the MULTIPLY mode.
  • The resulting color is always at least as light as either of the input colors.
  • Rendering with a completely white top input produces white; rendering with a completely black top input produces a result equivalent to the bottom input.
SOFT_LIGHTback to summary
public static final Blend.Mode SOFT_LIGHT

REMIND: this is a complicated formula, TBD...

SRC_ATOPback to summary
public static final Blend.Mode SRC_ATOP

The part of the top input lying inside of the bottom input is blended with the bottom input. (Equivalent to the Porter-Duff "source atop destination" rule.)

Thus:

     Ar = Atop*Abot + Abot*(1-Atop) = Abot
     Cr = Ctop*Abot + Cbot*(1-Atop)
SRC_INback to summary
public static final Blend.Mode SRC_IN

The part of the top input lying inside of the bottom input is kept in the resulting image. (Equivalent to the Porter-Duff "source in destination" rule.)

Thus:

     Ar = Atop*Abot
     Cr = Ctop*Abot
SRC_OUTback to summary
public static final Blend.Mode SRC_OUT

The part of the top input lying outside of the bottom input is kept in the resulting image. (Equivalent to the Porter-Duff "source held out by destination" rule.)

Thus:

     Ar = Atop*(1-Abot)
     Cr = Ctop*(1-Abot)
SRC_OVERback to summary
public static final Blend.Mode SRC_OVER

The top input is blended over the bottom input. (Equivalent to the Porter-Duff "source over destination" rule.)

Thus:

     Ar = Atop + Abot*(1-Atop)
     Cr = Ctop + Cbot*(1-Atop)

Constructor Detail

Modeback to summary
private Mode()

Method Detail

valueOfback to summary
public static Blend.Mode valueOf(String name)
valuesback to summary
public static Blend.Mode[] values()