if (cyclic)
{
// Create a radial gradient
Point2D radius = new Point2D.Double(p2.getX() - p1.getX(), p2.getY() - p1.getY());
paint = new RadialGradientPaint(p1, c1, radius, c2);
}
else
{
// Create a linear gradient
paint = new GradientPaint(p1, c1, p2, c2, true);