public BufferedImage createGradientLine(int width,Color leftColor,Color rightColor,double opacity){
  BufferedImage image=new BufferedImage(width,1,BufferedImage.TYPE_INT_ARGB);
  int iOpacity=(int)(255 * opacity);
  for (int col=0; col < width; col++) {
    double coef=(double)col / (double)width;
    int r=(int)(leftColor.getRed() + coef * (rightColor.getRed() - leftColor.getRed()));
    int g=(int)(leftColor.getGreen() + coef * (rightColor.getGreen() - leftColor.getGreen()));
    int b=(int)(leftColor.getBlue() + coef * (rightColor.getBlue() - leftColor.getBlue()));
    int color=(iOpacity << 24) | (r << 16) | (g << 8)| b;
    image.setRGB(col,0,color);
  }
  return image;
}

public BufferedImage createGradientLine ( int width , Color leftColor , Color rightColor , double opacity ) { BufferedImage image = new BufferedImage ( width , 1 , BufferedImage . TYPE_INT_ARGB ) ; int iOpacity = ( int ) ( 255 * opacity ) ; for ( int col = 0 ; col < width ; col ++ ) { double coef = ( double ) col / ( double ) width ; int r = ( int ) ( leftColor . getRed ( ) + coef * ( rightColor . getRed ( ) - leftColor . getRed ( ) ) ) ; int g = ( int ) ( leftColor . getGreen ( ) + coef * ( rightColor . getGreen ( ) - leftColor . getGreen ( ) ) ) ; int b = ( int ) ( leftColor . getBlue ( ) + coef * ( rightColor . getBlue ( ) - leftColor . getBlue ( ) ) ) ; int color = ( iOpacity << 24 ) | ( r << 16 ) | ( g << 8 ) | b ; image . setRGB ( col , 0 , color ) ; } return image ; }
description of the method
