protected Paint createHorizontalGradient ( Shape s , TwoColors 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 } , new Color [ ] { colors . top , colors . bottom } ) ; }
Creates a simple horizontal gradient using the shape for bounds and the colors for top and bottom colors .