Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class Effect
- Object
- 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
Constructors
public Effect(String kind) | Creates an effect with no parameters set; every parameter then has its default. |
Methods
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
kindString- 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
enabledboolean- 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
nameString- the parameter
valueObject- its value
set
public Effect set(String name, float value)Sets a number parameter and returns this effect.
Parameters
nameString- the parameter
valuefloat- its value
setColor
public Effect setColor(String name, int argb)Sets a color parameter and returns this effect.
Parameters
nameString- the parameter
argbint- the color
getFloat
public float getFloat(String name, float def)A number parameter.
Parameters
nameString- the parameter
deffloat- the value when it is not set
getColor
public int getColor(String name, int def)A color parameter.
Parameters
nameString- the parameter
defint- the value when it is not set
getString
public String getString(String name, String def)A string parameter.
Parameters
nameString- the parameter
defString- the value when it is not set
getFloats
public float[] getFloats(String name, float[] def)A number array parameter.
Parameters
nameString- the parameter
deffloat[]- the value when it is not set
getColors
public int[] getColors(String name, int[] def)A color array parameter.
Parameters
nameString- the parameter
defint[]- the value when it is not set
getBlend
public BlendMode getBlend(BlendMode def)The blend mode parameter
blend.Parameters
defBlendMode- the value when it is not set
getRaster
public Raster getRaster(String name)A raster parameter, or null.
Parameters
nameString- 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
layerRaster- the layer’s pixels in device space
ctxEffectContext- the scale and backdrop
Returns
the new pixels, possibly a larger raster;
layer is not changedpadding
public int padding(double scale)How far, in device pixels, the effect can paint outside the layer’s content.
Parameters
scaledouble- device pixels per unit