use of java.awt.image.WritableRaster in project processdash by dtuma.
the class TeamMemberTimeCellRenderer method getGradient.
/** Construct a Paint that can be used to fade to the background color.
*/
protected Paint getGradient() {
Color backgroundColor = getBackground();
BufferedImage i = new BufferedImage(gradientWidth, 1, BufferedImage.TYPE_INT_ARGB);
WritableRaster alpha = i.getAlphaRaster();
for (int x = gradientWidth; x-- > 0; ) {
i.setRGB(x, 0, backgroundColor.getRGB());
double sample = gradientWidth - x;
sample = sample / gradientWidth;
sample = (1.0 - sample * sample) * 255;
alpha.setSample(x, 0, 0, sample);
}
// to perform a quadratic fade instead of a linear fade.
return new TexturePaint(i, new Rectangle(leftBorder, 0, gradientWidth, 1));
}
Aggregations