XFlarePainter.java :  » XML-UI » xui32 » com » xoetrope » swing » painter » Java Open Source

Java Open Source » XML UI » xui32 
xui32 » com » xoetrope » swing » painter » XFlarePainter.java
package com.xoetrope.swing.painter;

import com.xoetrope.batik.ext.awt.RadialGradientPaint;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Paint;
import javax.swing.JComponent;
import net.xoetrope.swing.painter.XGradientBackground;

/**
 * Paints a background with a radial gradient
 * <p>Copyright (c) Xoetrope Ltd., 2002-2006</p>
 * <p>License: see license.txt</p>
 * $Revision: 1.1 $
 */
public class XFlarePainter extends XGradientBackground
{
  protected float offsetX = 0.333F;
  protected float offsetY = 0.333F;
  
  /**
   * Get the paint operation for the background
   * @param x starting x position
   * @param y starting y position
   * @param start the starting color
   * @param wScreen the width
   * @param hScreen the height
   * @param end the ending color
   * @return the paint operation
   */
  protected Paint getBackgroundPaint( float x, float y, Color start, float wScreen, float hScreen, Color end )
  {
    Color[] colors = new Color[ 2 ];
    float fractions[] = { 0.0F, 1.0F };
    colors[ 0 ] = start;
    colors[ 1 ] = end;
    float wr = ( 1.0F - offsetX ) * wScreen;
    float hr = ( 1.0F - offsetY ) * wScreen;
    float radius = (float)Math.sqrt( wr * wr + hr * hr );
    return new RadialGradientPaint( x + offsetX * wScreen, y + offsetY * hScreen, radius, fractions, colors );
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.