FileDocCategorySizeDatePackage
RadialGradientPaintDef.javaAPI DocphoneME MR2 API (J2ME)7681Wed May 02 18:00:34 BST 2007com.sun.perseus.j2d

RadialGradientPaintDef

public class RadialGradientPaintDef extends Object implements PaintDef
RadialGradientPaint support.
version
$Id: RadialGradientPaintDef.java,v 1.4 2006/04/21 06:35:33 st125089 Exp $

Fields Summary
public static final int
CYCLE_NONE
public static final int
CYCLE_REPEAT
public static final int
CYCLE_REFLECT
private com.sun.pisces.Transform6
IDENTITY
float
cx
The gradient x-axis center origin
float
cy
The gradient y-axis center origin
float
fx
The gradient x-axis focal
float
fy
The gradient y-axis focal
float
r
The gradient radius
float[]
fractions
The gradient stops.
int[]
frac
The gradient stops, as fixed point values.
int[]
rgba
The array of ARGB color values.
int[]
lrgba
The last used rgba array, accounting for operation opacity.
int
lastPaintOpacity
The last paintOpacity.
int
cycleMethod
One of the cycle methods (CYCLE_NONE, CYCLE_REPEAT, CYCLE_REFLECT
protected boolean
isObjectBBox
Set to true if this gradient is in objectBoundingBox space.
protected Transform
gradientTransform
An additional transform from the gradient space. This corresponds to a SVG gradientTransform attribute.
Constructors Summary
public RadialGradientPaintDef(float cx, float cy, float fx, float fy, float r, float[] fractions, int[] rgba, int cycleMethod, boolean isObjectBBox, Transform gradientTransform)
Constructs an RadialGradientPaint.

param
cx the gradient x-axis origin
param
cy the gradient y-axis orign
param
fx the gradient x-axis focal point
param
fy the gradient y-axis focal point
param
r the gradient radius
param
fractions the array of stop values
param
rgba the array of ARGB color values
param
cycleMethod one of the cycle methods (CYCLE_NONE, CYCLE_REPEAT, CYCLE_REFLECT
param
isObjectBBox if set to true, the RenderGraphic's current paintTarget object bounding box should be used to append and additional transform to the gradientTransform. The objectBoundingBox transform is appended to the right of the gradientTransform.
param
gradientTransform an additional transform to add between the device coordinate space and the gradient's coordinate space.


                                                                                                                                                            
        
                                     
                                     
                                     
                                     
                                     
                                     
                                     
                                     
                                      
        this.cx = cx;
        this.cy = cy;
        this.fx = fx;
        this.fy = fy;
        this.r = r;
        this.fractions = fractions;
        this.rgba = rgba;
        this.cycleMethod = cycleMethod;
        this.isObjectBBox = isObjectBBox;
        this.gradientTransform = gradientTransform;
    
Methods Summary
public voidsetPaint(PiscesRenderGraphics rg, com.sun.pisces.PiscesRenderer pr, int paintOpacity)
Sets the paint on a PiscesRender.

param
rg the RenderGraphics on requesting the paint to be set.
param
renderer the PiscesRender on which to set the paint.
param
paintOpacity additional paint opacity.

        // First, lazilly compute the fractions in fixed point.
        if (frac == null) {
            frac = new int[fractions.length];
            for (int i = 0; i < fractions.length; i++) {
                frac[i] = (int) (fractions[i] * 65536);
            }
        }

        // Now, lazilly compute the offset colors accounting for the current 
        // paint opacity.
        int[] c = rgba;
        if (paintOpacity != 255) {
            c = lrgba;
            if (paintOpacity != lastPaintOpacity) {
                if (lrgba == null) {
                    lrgba = new int[rgba.length];
                }
                int a = 0;
                for (int i = 0; i < rgba.length; i++) {
                    lrgba[i] = (rgba[i] & 0x00ffffff);
                    a = (paintOpacity * (0xff & (rgba[i] >> 24)) / 255);
                    lrgba[i] |= (a << 24);
                }
                lastPaintOpacity = paintOpacity;
            }
        }

        // Finally, compute the paint transform.

        // Start with the paintTarget's user space coordinate system.
        Transform txf = null;
        if (rg.paintTransform != null) {
            txf = new Transform(rg.paintTransform);
        } else {
            txf = new Transform(rg.transform.m00 / 65536f,
                                rg.transform.m10 / 65536f,
                                rg.transform.m01 / 65536f,
                                rg.transform.m11 / 65536f,
                                rg.transform.m02 / 65536f,
                                rg.transform.m12 / 65536f);
        }

        // Append the objectBoundingBox space to user space transform.
        if (isObjectBBox) {
            SVGRect bbox = rg.paintTarget.getBBox();
            txf.mTranslate(bbox.getX(), bbox.getY());
            txf.mScale(bbox.getWidth(), bbox.getHeight());
        } 

        // Now, append the gradient transform.
        if (gradientTransform != null) {
            txf.mMultiply(gradientTransform);
        }
        
        Transform6 t = new Transform6();
        t.m00 = (int) (txf.m0 * 65536);
        t.m10 = (int) (txf.m1 * 65536);
        t.m01 = (int) (txf.m2 * 65536);
        t.m11 = (int) (txf.m3 * 65536);
        t.m02 = (int) (txf.m4 * 65536);
        t.m12 = (int) (txf.m5 * 65536);
        
        pr.setRadialGradient((int) (cx * 65536),
                             (int) (cy * 65536),
                             (int) (fx * 65536),
                             (int) (fy * 65536),
                             (int) (r * 65536),
                             frac, 
                             rgba, 
                             cycleMethod, 
                             t);