protected Paint createHorizontalGradient(Shape s,Color[] colors){
  Rectangle2D bounds=s.getBounds2D();
  float xMin=(float)bounds.getMinX();
  float xMax=(float)bounds.getMaxX();
  float yCenter=(float)bounds.getCenterY();
  return createGradient(xMin,yCenter,xMax,yCenter,new float[]{0f,1f},colors);
}

protected Paint createHorizontalGradient ( Shape s , Color [ ] colors ) { Rectangle2D bounds = s . getBounds2D ( ) ; float xMin = ( float ) bounds . getMinX ( ) ; float xMax = ( float ) bounds . getMaxX ( ) ; float yCenter = ( float ) bounds . getCenterY ( ) ; return createGradient ( xMin , yCenter , xMax , yCenter , new float [ ] { 0f , 1f } , colors ) ; }
creates a simple horizontal gradient using the shape for bounds and the colors for top and bottom colors .
