Search in sources :

Example 96 with WritableRaster

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));
}
Also used : TexturePaint(java.awt.TexturePaint) WritableRaster(java.awt.image.WritableRaster) Color(java.awt.Color) Rectangle(java.awt.Rectangle) BufferedImage(java.awt.image.BufferedImage) TexturePaint(java.awt.TexturePaint) Paint(java.awt.Paint)

Aggregations

WritableRaster (java.awt.image.WritableRaster)96 BufferedImage (java.awt.image.BufferedImage)64 ColorModel (java.awt.image.ColorModel)31 DirectColorModel (java.awt.image.DirectColorModel)16 Raster (java.awt.image.Raster)15 IndexColorModel (java.awt.image.IndexColorModel)14 DataBufferByte (java.awt.image.DataBufferByte)13 Graphics2D (java.awt.Graphics2D)12 Rectangle (java.awt.Rectangle)12 ComponentColorModel (java.awt.image.ComponentColorModel)11 Point (java.awt.Point)9 DataBuffer (java.awt.image.DataBuffer)8 SampleModel (java.awt.image.SampleModel)8 ColorSpace (java.awt.color.ColorSpace)7 IOException (java.io.IOException)7 Color (java.awt.Color)6 DataBufferInt (java.awt.image.DataBufferInt)6 Iterator (java.util.Iterator)6 AffineTransform (java.awt.geom.AffineTransform)5 MultiPixelPackedSampleModel (java.awt.image.MultiPixelPackedSampleModel)5