final ColorDefinition cdStart = (ColorDefinition) g.getStartColor( ); final ColorDefinition cdEnd = (ColorDefinition) g.getEndColor( );
final ColorDefinition cdStart = g.getStartColor( ); final ColorDefinition cdEnd = g.getEndColor( );
	public void fillArea( AreaRenderEvent are ) throws ChartException	{		// SETUP SWING DATA STRUCTURES		final GeneralPath gp = new GeneralPath( );		PrimitiveRenderEvent pre;		for ( int i = 0; i < are.getElementCount( ); i++ )		{			pre = are.getElement( i );			if ( pre instanceof ArcRenderEvent )			{				final ArcRenderEvent acre = (ArcRenderEvent) pre;				final Arc2D.Double a2d = new Arc2D.Double( acre.getTopLeft( )						.getX( ),						acre.getTopLeft( ).getY( ),						acre.getWidth( ),						acre.getHeight( ),						acre.getStartAngle( ),						acre.getAngleExtent( ),						toSwingArcType( acre.getStyle( ) ) );				gp.append( a2d, true );			}			else if ( pre instanceof LineRenderEvent )			{				final LineRenderEvent lre = (LineRenderEvent) pre;				final Line2D.Double l2d = new Line2D.Double( lre.getStart( )						.getX( ),						lre.getStart( ).getY( ),						lre.getEnd( ).getX( ),						lre.getEnd( ).getY( ) );				gp.append( l2d, true );			}		}		// BEGIN FILLING		final Fill flBackground = are.getBackground( );		if ( flBackground instanceof ColorDefinition )		{			_g2d.setColor( (Color) _ids.getColor( (ColorDefinition) flBackground ) );		}		else if ( flBackground instanceof Gradient )		{			final Gradient g = (Gradient) flBackground;			final ColorDefinition cdStart = (ColorDefinition) g.getStartColor( );			final ColorDefinition cdEnd = (ColorDefinition) g.getEndColor( );			// boolean bCyclic = g.isCyclic();			double dAngleInDegrees = g.getDirection( );			final double dAngleInRadians = ( ( -dAngleInDegrees * Math.PI ) / 180.0 );			// int iAlpha = g.getTransparency();			Bounds bo = are.getBounds( );			/*			 * if (bCyclic) { }			 */			if ( dAngleInDegrees < -90 || dAngleInDegrees > 90 )			{				throw new ChartException( ChartDeviceExtensionPlugin.ID,						ChartException.RENDERING,						"exception.gradient.angle",//$NON-NLS-1$						new Object[]{							new Double( dAngleInDegrees )						},						ResourceBundle.getBundle( Messages.DEVICE_EXTENSION,								getLocale( ) ) );			}			Point2D.Double p2dStart, p2dEnd;			if ( dAngleInDegrees == 90 )			{				p2dStart = new Point2D.Double( bo.getLeft( ), bo.getTop( )						+ bo.getHeight( ) );				p2dEnd = new Point2D.Double( bo.getLeft( ), bo.getTop( ) );			}			else if ( dAngleInDegrees == -90 )			{				p2dEnd = new Point2D.Double( bo.getLeft( ), bo.getTop( )						+ bo.getHeight( ) );				p2dStart = new Point2D.Double( bo.getLeft( ), bo.getTop( ) );			}			else if ( dAngleInDegrees > 0 )			{				p2dStart = new Point2D.Double( bo.getLeft( ), bo.getTop( )						+ bo.getHeight( ) );				p2dEnd = new Point2D.Double( bo.getLeft( ) + bo.getWidth( ),						bo.getTop( )								+ bo.getHeight( )								- bo.getWidth( )								* Math.abs( Math.tan( dAngleInRadians ) ) );			}			else if ( dAngleInDegrees < 0 )			{				p2dStart = new Point2D.Double( bo.getLeft( ), bo.getTop( ) );				p2dEnd = new Point2D.Double( bo.getLeft( ) + bo.getWidth( ),						bo.getTop( )								+ bo.getWidth( )								* Math.abs( Math.tan( dAngleInRadians ) ) );			}			else			{				p2dStart = new Point2D.Double( bo.getLeft( ), bo.getTop( ) );				p2dEnd = new Point2D.Double( bo.getLeft( ) + bo.getWidth( ),						bo.getTop( ) );			}			_g2d.setPaint( new GradientPaint( p2dStart,					(Color) _ids.getColor( cdStart ),					p2dEnd,					(Color) _ids.getColor( cdEnd ) ) );		}		else if ( flBackground instanceof org.eclipse.birt.chart.model.attribute.Image )		{			// TBD		}		_g2d.fill( gp );	}