File: GradientPainter.java

package info (click to toggle)
mac-widgets 0.10.0%2Bsvn416-dfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,968 kB
  • sloc: java: 9,909; makefile: 13; sh: 12
file content (31 lines) | stat: -rw-r--r-- 933 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.explodingpixels.painter;

import java.awt.Color;
import java.awt.Component;
import java.awt.GradientPaint;
import java.awt.Graphics2D;

public class GradientPainter implements MacWidgetsPainter<Component> {

    private final Color fTopColor;

    private final Color fBottomColor;

    public GradientPainter(Color topColor, Color bottomColor) {
        fTopColor = topColor;
        fBottomColor = bottomColor;
    }

    public void paint(Graphics2D g, Component object, int width, int height) {
        // create the paint - start the gradient one pixel from the top
        // of the component and finish the gradient one pixel from the
        // bottom.
        GradientPaint paint = new GradientPaint(
                0, 1, fTopColor,
                0, height, fBottomColor);
        // install the paint and fill a rectangle with it.
        g.setPaint(paint);
        g.fillRect(0, 0, width, height);
    }

}