RadialGradientPaintDefpublic class RadialGradientPaintDef extends Object implements PaintDefRadialGradientPaint support. |
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 | cxThe gradient x-axis center origin | float | cyThe gradient y-axis center origin | float | fxThe gradient x-axis focal | float | fyThe gradient y-axis focal | float | rThe gradient radius | float[] | fractionsThe gradient stops. | int[] | fracThe gradient stops, as fixed point values. | int[] | rgbaThe array of ARGB color values. | int[] | lrgbaThe last used rgba array, accounting for operation opacity. | int | lastPaintOpacityThe last paintOpacity. | int | cycleMethodOne of the cycle methods (CYCLE_NONE,
CYCLE_REPEAT, CYCLE_REFLECT | protected boolean | isObjectBBoxSet to true if this gradient is in objectBoundingBox space. | protected Transform | gradientTransformAn 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 .
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 void | setPaint(PiscesRenderGraphics rg, com.sun.pisces.PiscesRenderer pr, int paintOpacity)Sets the paint on a PiscesRender.
// 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);
|
|