graphics.setBackgroundColor( ReportColorConstants.greyFillColor );
	protected void paintFigure( Graphics graphics )	{		//set		/*		 * @TODO:Pratik maybe you can break this method into a few methods. that		 * might make it a little easier to read and understand. plus,		 * sub-classes could customize certain parts.		 */		setIntervalForPaint( );		double dotsPerUnit = getDPU( );		Rectangle clip = transposer.t( graphics.getClip( Rectangle.SINGLETON ) );		Rectangle figClientArea = transposer.t( getClientArea( ) );		// Use the x and width of the client area, but the y and height of the		// clip as the		// bounds of the area which is to be repainted. This will increase		// performance as the		// entire ruler will not be repainted everytime.		Rectangle clippedBounds = clip;		clippedBounds.x = figClientArea.x;		clippedBounds.width = figClientArea.width - BORDER_WIDTH;		// Paint the background		if ( isOpaque( ) )		{			graphics.fillRectangle( transposer.t( clippedBounds ) );		}		/*		 * A major mark is one that goes all the way from the left edge to the		 * right edge of a ruler and for which a number is displayed. Determine		 * the minimum number of pixels that are to be left between major marks.		 * This will, in turn, help determine how many units are to be displayed		 * per major mark. A major mark should have at least enough pixels to		 * display the text and its padding. We take into the consideration the		 * max of text's width and height so that for horizontal and vertical		 * rulers that are of the same height, the number of units per major		 * mark is the same.		 */		int unitsPerMajorMark = (int) ( minPixelsBetweenMajorMarks / dotsPerUnit );		//unitsPerMajorMark = 20;		if ( minPixelsBetweenMajorMarks % dotsPerUnit != 0.0 )		{			unitsPerMajorMark++;		}		if ( interval > 0 )		{			/*			 * If the client specified how many units are to be displayed per			 * major mark, use that. If, however, showing that many units			 * wouldn't leave enough room for the text, than take its smallest			 * multiple that would leave enough room.			 */			int intervalMultiple = interval;			while ( intervalMultiple < unitsPerMajorMark )			{				intervalMultiple += interval;			}			unitsPerMajorMark = intervalMultiple;		}		else if ( unitsPerMajorMark != 1 && unitsPerMajorMark % 2 != 0 )		{			// if the number of units per major mark is calculated dynamically,			// ensure that			// it is an even number.			unitsPerMajorMark++;		}		/*		 * divsPerMajorMark indicates the number of divisions that a major mark		 * should be divided into. for eg., a value of 2 would mean that a major		 * mark would be shown as having two parts. that means that there would		 * be a marker showing the beginning and end of the major marker and		 * another right in the middle.		 */		int divsPerMajorMark;		if ( divisions > 0				&& dotsPerUnit * unitsPerMajorMark / divisions >= minPixelsBetweenMarks )		{			/*			 * If the client has specified the number of divisions per major			 * mark, use that unless it would cause the minimum space between			 * marks to be less than minPixelsBetweenMarks			 */			divsPerMajorMark = divisions;		}		else		{			/*			 * If the client hasn't specified the number of divisions per major			 * mark or the one that the client has specified is invalid, then			 * calculate it dynamically. This algorithm will try to display 10			 * divisions per CM, and 16 per INCH. However, if that puts the			 * marks too close together (i.e., the space between them is less			 * than minPixelsBetweenMarks), then it keeps decreasing the number			 * of divisions by a factor of 2 until there is enough space between			 * them.			 */			divsPerMajorMark = 2;			if ( getUnit( ) == RulerProvider.UNIT_CENTIMETERS )			{				divsPerMajorMark = 10;			}			else if ( getUnit( ) == RulerProvider.UNIT_INCHES )			{				divsPerMajorMark = 8;			}			//divsPerMajorMark = getPerMajorMark(getUnit());			while ( dotsPerUnit * unitsPerMajorMark / divsPerMajorMark < minPixelsBetweenMarks )			{				divsPerMajorMark /= 2;				if ( divsPerMajorMark == 0 )				{					break;				}			}			// This should never happen unless the client has specified a			// minPixelsBetweenMarks that is larger than			// minPixelsBetweenMajorMarks (which			// is calculated using the text's size -- size of the largest number			// to be			// displayed).			if ( divsPerMajorMark == 0 )			{				divsPerMajorMark = 1;			}		}		/*		 * mediumMarkerDivNum is used to determine which mark (line drawn to		 * indicate a point on the ruler) in a major mark will be of medium		 * size. If its value is 1 then every mark will be of medium size. If		 * its value is 5, then every 5th mark will be of medium size (the rest		 * being of small size).		 */		int mediumMarkerDivNum = 1;		switch ( divsPerMajorMark )		{			case 20 :			case 10 :			case 5 :				mediumMarkerDivNum = 5;				break;			case 16 :			case 8 :				mediumMarkerDivNum = 4;				break;			case 4 :				mediumMarkerDivNum = 2;				break;			case 2 :				mediumMarkerDivNum = 1;		}		Rectangle leftRect = transposer.t( getScaleLeftSpace( ) );		int leftMargin = leftRect.y;		/*		 * dotsPerDivision = number of pixels between each mark = number of		 * pixels in a division		 */		double dotsPerDivision = dotsPerUnit * unitsPerMajorMark				/ divsPerMajorMark;		/*		 * startMark is the division/mark from which we are going to start		 * painting. It should be the last major mark (one for which a number is		 * displayed) that is before the top of the clip rectangle.		 */		int startMark = (int) ( ( clippedBounds.y - leftMargin ) / ( dotsPerUnit * unitsPerMajorMark ) )				* divsPerMajorMark;		if ( clippedBounds.y < 0 )		{			// -2 / 10 = 0, not -1. so, if the top of the clip is negative, we			// need to move			// the startMark back by a whole major mark.			startMark -= divsPerMajorMark;		}		// endMark is the first non-visible mark (doesn't have to be a major		// mark) that is		// beyond the end of the clip region		int endMark = (int) ( ( ( clippedBounds.y + clippedBounds.height - leftMargin ) / dotsPerDivision ) ) + 1;		int leading = FigureUtilities.getFontMetrics( getFont( ) ).getLeading( );		Rectangle forbiddenZone = new Rectangle( );		for ( int div = startMark; div <= endMark; div++ )		{			// y is the vertical position of the mark			if ( leftRect.bottom( ) <= clippedBounds.bottom( ) )			{				//continue;			}			int y = (int) ( div * dotsPerDivision );			if ( div % divsPerMajorMark == 0 )			{				String num = "" + ( div / divsPerMajorMark ) * unitsPerMajorMark; //$NON-NLS-1$				if ( isHorizontal( ) )				{					Dimension numSize = FigureUtilities.getStringExtents( num,							getFont( ) );					/*					 * FigureUtilities is increasing the width reported by GC by					 * 1, so we remove it here. Also, if the actual width (the					 * one reported by the GC) is even, we want to increase it					 * by 1. This will ensure that when marks marks are erased					 * because they are too close to the number, they are erased					 * from both sides of that number.					 */					if ( numSize.width % 2 == 0 )					{						numSize.width--;					}					Point textLocation = new Point( y - ( numSize.width / 2 )							+ leftMargin, clippedBounds.x + textMargin							- leading );					forbiddenZone.setLocation( textLocation );					forbiddenZone.setSize( numSize );					forbiddenZone.expand( 1, 1 );					graphics.fillRectangle( forbiddenZone );					// Uncomment the following line of code if you want to see a					// line at					// the exact position of the major mark					//					graphics.drawLine(y, clippedBounds.x, y, clippedBounds.x					// + clippedBounds.width);					graphics.drawText( num, textLocation );				}				else				{					Image numImage = ImageUtilities.createRotatedImageOfString(							num, getFont( ), getForegroundColor( ),							getBackgroundColor( ) );					Point textLocation = new Point( clippedBounds.x							+ textMargin, y							- ( numImage.getBounds( ).height / 2 ) + leftMargin );					forbiddenZone.setLocation( textLocation );					forbiddenZone.setSize( numImage.getBounds( ).width,							numImage.getBounds( ).height );					forbiddenZone							.expand( 1,									1 + ( numImage.getBounds( ).height % 2 == 0											? 1											: 0 ) );					graphics.fillRectangle( forbiddenZone );					graphics.drawImage( numImage, textLocation );					numImage.dispose( );				}			}			else if ( ( div % divsPerMajorMark ) % mediumMarkerDivNum == 0 )			{				// this is a medium mark, so its length should be longer than				// the small marks				Point start = transposer						.t( new Point(								( clippedBounds.getRight( ).x - mediumMarkWidth ) / 2,								y + leftMargin ) );				Point end = transposer.t( new Point( ( ( clippedBounds						.getRight( ).x - mediumMarkWidth ) / 2 )						+ mediumMarkWidth, y + leftMargin ) );				if ( !forbiddenZone.contains( start ) )				{					graphics.drawLine( start, end );				}			}			else			{				// small mark				Point start = transposer						.t( new Point(								( clippedBounds.getRight( ).x - smallMarkWidth ) / 2,								y + leftMargin ) );				Point end = transposer.t( new Point( ( ( clippedBounds						.getRight( ).x - smallMarkWidth ) / 2 )						+ smallMarkWidth, y + leftMargin ) );				if ( !forbiddenZone.contains( start ) )				{					graphics.drawLine( start, end );				}			}		}		// paint the border		clippedBounds.expand( BORDER_WIDTH, 0 );		graphics.setForegroundColor( ColorConstants.buttonDarker );		graphics.drawLine( transposer.t( clippedBounds.getTopRight( )				.translate( -1, -1 ) ), transposer.t( clippedBounds				.getBottomRight( ).translate( -1, -1 ) ) );		Color c = Display.getCurrent( ).getSystemColor(				SWT.COLOR_WIDGET_BACKGROUND );		graphics.setBackgroundColor( ReportColorConstants.greyFillColor );		graphics.setBackgroundColor( c );		Rectangle rect = new Rectangle( 0, 0, clippedBounds.height,				leftMargin - 2 );		rect = transposer.t( rect );		graphics.fillRectangle( rect );		graphics.fillRectangle( getEndRect( graphics				.getClip( Rectangle.SINGLETON ) ) );	}