Example usage for java.awt RadialGradientPaint RadialGradientPaint

List of usage examples for java.awt RadialGradientPaint RadialGradientPaint

Introduction

In this page you can find the example usage for java.awt RadialGradientPaint RadialGradientPaint.

Prototype

public RadialGradientPaint(Point2D center, float radius, Point2D focus, float[] fractions, Color[] colors,
        CycleMethod cycleMethod) 

Source Link

Document

Constructs a RadialGradientPaint with a default SRGB color space.

Usage

From source file:Main.java

/**
 * Creates a nifty looking inner shadow for the window.
 * @param width The width of the shadow.
 * @param height The height of the shadow.
 * @return The translucent shadow that was created.
 */// w ww  .jav a  2 s .  c om
public static BufferedImage genInnerShadow(int width, int height) {
    BufferedImage shadowOuter = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics g = shadowOuter.getGraphics();
    Graphics2D g2 = (Graphics2D) g;
    Point2D center = new Point2D.Float(width / 2, height / 2);
    float radius = width;
    Point2D focus = new Point2D.Float(width / 2, height / 2);
    float[] dist = { 0.0f, 1.0f };
    Color[] colors = { new Color(0, 0, 0, 0), new Color(0, 0, 0, 220) };
    RadialGradientPaint p = new RadialGradientPaint(center, radius, focus, dist, colors, CycleMethod.NO_CYCLE);
    g2.setPaint(p);
    g2.fillRect(0, 0, width, height);
    return shadowOuter;
}