Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class Effect

  1. Object
  2. Effect

An effect: a kind and its parameters.

Parameters are numbers (Float), colors (Integer, 0xAARRGGBB), number arrays (float[]), color arrays (int[]), strings, BlendModes, Rasters and, for SVG filters, lists of primitives (each a Map). Every kind is described in Effects.

Fields

public static final String DROP_SHADOW = "dropShadow"Shadow behind the layer.
public static final String INNER_SHADOW = "innerShadow"Shadow inside the layer’s edges.
public static final String OUTER_GLOW = "outerGlow"Glow around the layer.
public static final String INNER_GLOW = "innerGlow"Glow inside the layer’s edges.
public static final String GAUSSIAN_BLUR = "gaussianBlur"Gaussian blur of the layer.
public static final String BACKGROUND_BLUR = "backgroundBlur"Blur of what is behind the layer, seen through it.
public static final String MOTION_BLUR = "motionBlur"Blur along a direction.
public static final String ZOOM_BLUR = "zoomBlur"A blur radiating from a point, as a camera zooming during the exposure.
public static final String STROKE = "stroke"Outline around the layer’s edges.
public static final String COLOR_OVERLAY = "colorOverlay"Solid color over the layer.
public static final String GRADIENT_OVERLAY = "gradientOverlay"Gradient over the layer.
public static final String PATTERN_OVERLAY = "patternOverlay"Pattern over the layer.
public static final String BEVEL = "bevel"Bevel and emboss.
public static final String SATIN = "satin"Satin shading.
public static final String COLOR_MATRIX = "colorMatrix"A 4x5 color matrix.
public static final String LEVELS = "levels"Input and output levels with gamma.
public static final String CURVES = "curves"Tone curves.
public static final String HUE_SATURATION = "hueSaturation"Hue, saturation and lightness.
public static final String BRIGHTNESS_CONTRAST = "brightnessContrast"Brightness and contrast.
public static final String INVERT = "invert"Inverted colors.
public static final String THRESHOLD = "threshold"Black and white at a threshold.
public static final String GRADIENT_MAP = "gradientMap"Luminance mapped through a gradient.
public static final String CHANNEL_MIXER = "channelMixer"Output channels mixed from the input channels.
public static final String PHOTO_FILTER = "photoFilter"A colored filter over the image.
public static final String POSTERIZE = "posterize"Fewer tones per channel.
public static final String EXPOSURE = "exposure"Exposure, offset and gamma.
public static final String VIBRANCE = "vibrance"Saturation boost that spares saturated colors.
public static final String BLACK_AND_WHITE = "blackAndWhite"Grayscale with per-hue weights.
public static final String COLOR_BALANCE = "colorBalance"Shifts colors toward red, green or blue separately in shadows, midtones and highlights.
public static final String SELECTIVE_COLOR = "selectiveColor"Changes the ink of chosen color ranges, as Photoshop’s selective color does.
public static final String SVG_FILTER = "svgFilter"An SVG filter graph.

Constructors

public Effect(String kind)Creates an effect with no parameters set; every parameter then has its default.

Methods

public String getKind()The kind.
public boolean isEnabled()False keeps the effect but does not apply it.
public void setEnabled(boolean enabled)Turns the effect on or off.
public Map<String, Object> getParameters()The parameters that have been set.
public Effect set(String name, Object value)Sets a parameter and returns this effect.
public Effect set(String name, float value)Sets a number parameter and returns this effect.
public Effect setColor(String name, int argb)Sets a color parameter and returns this effect.
public float getFloat(String name, float def)A number parameter.
public int getColor(String name, int def)A color parameter.
public String getString(String name, String def)A string parameter.
public float[] getFloats(String name, float[] def)A number array parameter.
public int[] getColors(String name, int[] def)A color array parameter.
public BlendMode getBlend(BlendMode def)The blend mode parameter blend.
public Raster getRaster(String name)A raster parameter, or null.
public List<Map<String, Object>> getPrimitives()The SVG filter primitives, or an empty list.
public Effect copy()A deep copy.
public Raster apply(Raster layer, EffectContext ctx)Applies the effect.
public int padding(double scale)How far, in device pixels, the effect can paint outside the layer’s content.

Inherited methods

Field details

DROP_SHADOW

public static final String DROP_SHADOW = "dropShadow"
Shadow behind the layer.

INNER_SHADOW

public static final String INNER_SHADOW = "innerShadow"
Shadow inside the layer’s edges.

OUTER_GLOW

public static final String OUTER_GLOW = "outerGlow"
Glow around the layer.

INNER_GLOW

public static final String INNER_GLOW = "innerGlow"
Glow inside the layer’s edges.

GAUSSIAN_BLUR

public static final String GAUSSIAN_BLUR = "gaussianBlur"
Gaussian blur of the layer.

BACKGROUND_BLUR

public static final String BACKGROUND_BLUR = "backgroundBlur"
Blur of what is behind the layer, seen through it.

MOTION_BLUR

public static final String MOTION_BLUR = "motionBlur"
Blur along a direction.

ZOOM_BLUR

public static final String ZOOM_BLUR = "zoomBlur"
A blur radiating from a point, as a camera zooming during the exposure.

STROKE

public static final String STROKE = "stroke"
Outline around the layer’s edges.

COLOR_OVERLAY

public static final String COLOR_OVERLAY = "colorOverlay"
Solid color over the layer.

GRADIENT_OVERLAY

public static final String GRADIENT_OVERLAY = "gradientOverlay"
Gradient over the layer.

PATTERN_OVERLAY

public static final String PATTERN_OVERLAY = "patternOverlay"
Pattern over the layer.

BEVEL

public static final String BEVEL = "bevel"
Bevel and emboss.

SATIN

public static final String SATIN = "satin"
Satin shading.

COLOR_MATRIX

public static final String COLOR_MATRIX = "colorMatrix"
A 4x5 color matrix.

LEVELS

public static final String LEVELS = "levels"
Input and output levels with gamma.

CURVES

public static final String CURVES = "curves"
Tone curves.

HUE_SATURATION

public static final String HUE_SATURATION = "hueSaturation"
Hue, saturation and lightness.

BRIGHTNESS_CONTRAST

public static final String BRIGHTNESS_CONTRAST = "brightnessContrast"
Brightness and contrast.

INVERT

public static final String INVERT = "invert"
Inverted colors.

THRESHOLD

public static final String THRESHOLD = "threshold"
Black and white at a threshold.

GRADIENT_MAP

public static final String GRADIENT_MAP = "gradientMap"
Luminance mapped through a gradient.

CHANNEL_MIXER

public static final String CHANNEL_MIXER = "channelMixer"
Output channels mixed from the input channels.

PHOTO_FILTER

public static final String PHOTO_FILTER = "photoFilter"
A colored filter over the image.

POSTERIZE

public static final String POSTERIZE = "posterize"
Fewer tones per channel.

EXPOSURE

public static final String EXPOSURE = "exposure"
Exposure, offset and gamma.

VIBRANCE

public static final String VIBRANCE = "vibrance"
Saturation boost that spares saturated colors.

BLACK_AND_WHITE

public static final String BLACK_AND_WHITE = "blackAndWhite"
Grayscale with per-hue weights.

COLOR_BALANCE

public static final String COLOR_BALANCE = "colorBalance"
Shifts colors toward red, green or blue separately in shadows, midtones and highlights.

SELECTIVE_COLOR

public static final String SELECTIVE_COLOR = "selectiveColor"
Changes the ink of chosen color ranges, as Photoshop’s selective color does.

SVG_FILTER

public static final String SVG_FILTER = "svgFilter"
An SVG filter graph.

Constructor details

Effect

public Effect(String kind)
Creates an effect with no parameters set; every parameter then has its default.

Parameters

kind String
one of the kind constants

Method details

getKind

public String getKind()
The kind.

isEnabled

public boolean isEnabled()
False keeps the effect but does not apply it.

setEnabled

public void setEnabled(boolean enabled)
Turns the effect on or off.

Parameters

enabled boolean
true to apply it

getParameters

public Map<String, Object> getParameters()
The parameters that have been set. The map is live.

set

public Effect set(String name, Object value)
Sets a parameter and returns this effect.

Parameters

name String
the parameter
value Object
its value

set

public Effect set(String name, float value)
Sets a number parameter and returns this effect.

Parameters

name String
the parameter
value float
its value

setColor

public Effect setColor(String name, int argb)
Sets a color parameter and returns this effect.

Parameters

name String
the parameter
argb int
the color

getFloat

public float getFloat(String name, float def)
A number parameter.

Parameters

name String
the parameter
def float
the value when it is not set

getColor

public int getColor(String name, int def)
A color parameter.

Parameters

name String
the parameter
def int
the value when it is not set

getString

public String getString(String name, String def)
A string parameter.

Parameters

name String
the parameter
def String
the value when it is not set

getFloats

public float[] getFloats(String name, float[] def)
A number array parameter.

Parameters

name String
the parameter
def float[]
the value when it is not set

getColors

public int[] getColors(String name, int[] def)
A color array parameter.

Parameters

name String
the parameter
def int[]
the value when it is not set

getBlend

public BlendMode getBlend(BlendMode def)
The blend mode parameter blend.

Parameters

def BlendMode
the value when it is not set

getRaster

public Raster getRaster(String name)
A raster parameter, or null.

Parameters

name String
the parameter

getPrimitives

public List<Map<String, Object>> getPrimitives()
The SVG filter primitives, or an empty list.

copy

public Effect copy()
A deep copy.

apply

public Raster apply(Raster layer, EffectContext ctx)
Applies the effect.

Parameters

layer Raster
the layer’s pixels in device space
ctx EffectContext
the scale and backdrop

Returns

the new pixels, possibly a larger raster; layer is not changed

padding

public int padding(double scale)
How far, in device pixels, the effect can paint outside the layer’s content.

Parameters

scale double
device pixels per unit