rtc.getLocale( ) ) );
rtc.getULocale( ).toLocale( ) ) );
	final void computeAxisStartEndShifts( IDisplayServer xs, Label la,			int iOrientation, int iLocation, AllAxes aax )			throws ChartException	{		final double dMaxSS = ( aax != null && iOrientation == aax.getOrientation( ) ) ? aax.getMaxStartShift( )				: 0;		final double dMaxES = ( aax != null && iOrientation == aax.getOrientation( ) ) ? aax.getMaxEndShift( )				: 0;		if ( !la.isVisible( ) )		{			dStartShift = dMaxSS;			dEndShift = dMaxES;			return;		}		if ( getType( ) == TEXT || bCategoryScale )		{			// COMPUTE THE BOUNDING BOXES FOR FIRST AND LAST LABEL TO ADJUST			// START/END OF X-AXIS			final double dUnitSize = getUnitSize( );			final DataSetIterator dsi = getData( );			final int iDateTimeUnit;			BoundingBox bb = null;			try			{				iDateTimeUnit = ( getType( ) == IConstants.DATE_TIME ) ? CDateTime.computeUnit( dsi )						: IConstants.UNDEFINED;			}			catch ( ClassCastException e )			{				// Happens when data in dsi is not of DateTime format				throw new ChartException( ChartEnginePlugin.ID,						ChartException.GENERATION,						"exception.dataset.non.datetime", //$NON-NLS-1$						ResourceBundle.getBundle( Messages.ENGINE,								rtc.getLocale( ) ) );			}			final double rotation = la.getCaption( ).getFont( ).getRotation( );			final boolean bCenter = rotation == 0					|| rotation == 90					|| rotation == -90;			// TODO check first visible label shift.			if ( !isTickLabelVisible( 0 ) )			{				dStartShift = dMaxSS;			}			else			{				// ADJUST THE START POSITION				la.getCaption( ).setValue( formatCategoryValue( getType( ),						dsi.first( ),						iDateTimeUnit ) );				try				{					bb = computeBox( xs, iLocation, la, 0, 0 );				}				catch ( IllegalArgumentException uiex )				{					throw new ChartException( ChartEnginePlugin.ID,							ChartException.GENERATION,							uiex );				}				if ( iOrientation == VERTICAL ) // VERTICAL AXIS				{					if ( bCenter )					{						dStartShift = Math.max( dMaxSS,								( dUnitSize > bb.getHeight( ) ) ? 0										: ( bb.getHeight( ) - dUnitSize ) / 2 );					}					else if ( iScaleDirection == FORWARD )					{						dStartShift = Math.max( dMaxSS, bb.getHotPoint( )								- dUnitSize								/ 2 );					}					else					{						dStartShift = Math.max( dMaxSS, bb.getHeight( )								- bb.getHotPoint( )								- dUnitSize								/ 2 );					}				}				else if ( iOrientation == HORIZONTAL ) // HORIZONTAL AXIS				{					if ( bCenter )					{						dStartShift = Math.max( dMaxSS,								( dUnitSize > bb.getWidth( ) ) ? 0										: ( bb.getWidth( ) - dUnitSize ) / 2 );					}					else if ( iScaleDirection == BACKWARD )					{						dStartShift = Math.max( dMaxSS, bb.getWidth( )								- bb.getHotPoint( )								- dUnitSize								/ 2 );					}					else					{						dStartShift = Math.max( dMaxSS, bb.getHotPoint( )								- dUnitSize								/ 2 );					}				}			}			// TODO check last visible label shift.			if ( !isTickLabelVisible( dsi.size( ) - 1 ) )			{				dEndShift = dMaxES;			}			else			{				// ADJUST THE END POSITION				la.getCaption( ).setValue( formatCategoryValue( getType( ),						dsi.last( ),						iDateTimeUnit ) );				try				{					bb = computeBox( xs, iLocation, la, 0, dEnd );				}				catch ( IllegalArgumentException uiex )				{					throw new ChartException( ChartEnginePlugin.ID,							ChartException.GENERATION,							uiex );				}				if ( iOrientation == VERTICAL ) // VERTICAL AXIS				{					if ( bCenter )					{						dEndShift = Math.max( dMaxES,								( dUnitSize > bb.getHeight( ) ) ? 0										: ( bb.getHeight( ) - dUnitSize ) / 2 );					}					else if ( iScaleDirection == FORWARD )					{						dEndShift = Math.max( dMaxES, bb.getHeight( )								- bb.getHotPoint( )								- dUnitSize								/ 2 );					}					else					{						dEndShift = Math.max( dMaxES, bb.getHotPoint( )								- dUnitSize								/ 2 );					}				}				else if ( iOrientation == HORIZONTAL ) // HORIZONTAL AXIS				{					if ( bCenter )					{						dEndShift = Math.max( dMaxES,								( dUnitSize > bb.getWidth( ) ) ? 0										: ( bb.getWidth( ) - dUnitSize ) / 2 );					}					else if ( iScaleDirection == BACKWARD )					{						dEndShift = Math.max( dMaxES, bb.getHotPoint( )								- dUnitSize								/ 2 );					}					else					{						dEndShift = Math.max( dMaxES, bb.getWidth( )								- bb.getHotPoint( )								- dUnitSize								/ 2 );					}				}			}		}		else if ( ( iType & NUMERICAL ) == NUMERICAL )		{			if ( ( iType & LINEAR ) == LINEAR )			{				// ADJUST THE START POSITION				DecimalFormat df = null;				if ( fs == null ) // ONLY COMPUTE INTERNALLY IF FORMAT				// SPECIFIER				// ISN'T DEFINED				{					df = new DecimalFormat( getNumericPattern( ) );				}				String sValue = null;				try				{					sValue = ValueFormatter.format( getMinimum( ),							fs,							rtc.getLocale( ),							df );				}				catch ( ChartException dfex )				{					logger.log( dfex );					sValue = IConstants.NULL_STRING;				}				la.getCaption( ).setValue( sValue );				BoundingBox bb = null;				try				{					bb = computeBox( xs, iLocation, la, 0, 0 );				}				catch ( IllegalArgumentException uiex )				{					throw new ChartException( ChartEnginePlugin.ID,							ChartException.GENERATION,							uiex );				}				if ( iOrientation == VERTICAL ) // VERTICAL AXIS				{					dStartShift = Math.max( dMaxSS,							( bb.getHeight( ) - bb.getHotPoint( ) ) );				}				else if ( iOrientation == HORIZONTAL )				{					dStartShift = Math.max( dMaxSS, bb.getHotPoint( ) );				}				// ADJUST THE END POSITION				try				{					sValue = ValueFormatter.format( getMaximum( ),							fs,							rtc.getLocale( ),							df );				}				catch ( ChartException dfex )				{					logger.log( dfex );					sValue = IConstants.NULL_STRING;				}				la.getCaption( ).setValue( sValue );				try				{					bb = computeBox( xs, iLocation, la, 0, 0 );				}				catch ( IllegalArgumentException uiex )				{					throw new ChartException( ChartEnginePlugin.ID,							ChartException.GENERATION,							uiex );				}				if ( iOrientation == VERTICAL ) // VERTICAL AXIS				{					dEndShift = Math.max( dMaxES, bb.getHotPoint( ) );				}				else if ( iOrientation == HORIZONTAL )				{					dEndShift = Math.max( dMaxES,							( bb.getWidth( ) - bb.getHotPoint( ) ) );				}			}			else if ( ( iType & LOGARITHMIC ) == LOGARITHMIC )			{				// ADJUST THE START POSITION				final double dMinimum = asDouble( getMinimum( ) ).doubleValue( );				DecimalFormat df = null;				if ( fs == null ) // ONLY COMPUTE INTERNALLY IF FORMAT				// SPECIFIER				// ISN'T DEFINED				{					df = new DecimalFormat( getNumericPattern( dMinimum ) );				}				String sValue = null;				try				{					sValue = ValueFormatter.format( getMinimum( ),							fs,							rtc.getLocale( ),							df );				}				catch ( ChartException dfex )				{					logger.log( dfex );					sValue = IConstants.NULL_STRING;				}				la.getCaption( ).setValue( sValue );				BoundingBox bb = null;				try				{					bb = computeBox( xs, iLocation, la, 0, 0 );				}				catch ( IllegalArgumentException uiex )				{					throw new ChartException( ChartEnginePlugin.ID,							ChartException.GENERATION,							uiex );				}				if ( iOrientation == VERTICAL ) // VERTICAL AXIS				{					dStartShift = Math.max( dMaxSS,							( bb.getHeight( ) - bb.getHotPoint( ) ) );				}				else if ( iOrientation == HORIZONTAL )				{					dStartShift = Math.max( dMaxSS, bb.getHotPoint( ) );				}				// ADJUST THE END POSITION				final double dMaximum = asDouble( getMaximum( ) ).doubleValue( );				if ( fs == null ) // ONLY COMPUTE INTERNALLY (DIFFERENT FROM				// MINIMUM) IF FORMAT SPECIFIER ISN'T DEFINED				{					df = new DecimalFormat( getNumericPattern( dMaximum ) );				}				try				{					sValue = ValueFormatter.format( getMaximum( ),							fs,							rtc.getLocale( ),							df );				}				catch ( ChartException dfex )				{					logger.log( dfex );					sValue = IConstants.NULL_STRING;				}				la.getCaption( ).setValue( sValue );				try				{					bb = computeBox( xs, iLocation, la, 0, 0 );				}				catch ( IllegalArgumentException uiex )				{					throw new ChartException( ChartEnginePlugin.ID,							ChartException.GENERATION,							uiex );				}				if ( iOrientation == VERTICAL ) // VERTICAL AXIS				{					dEndShift = Math.max( dMaxES, bb.getHotPoint( ) );				}				else if ( iOrientation == HORIZONTAL )				{					dEndShift = Math.max( dMaxES,							( bb.getWidth( ) - bb.getHotPoint( ) ) );				}			}		}		else if ( getType( ) == DATE_TIME )		{			// COMPUTE THE BOUNDING BOXES FOR FIRST AND LAST LABEL TO ADJUST			// START/END OF X-AXIS			CDateTime cdt = asDateTime( getMinimum( ) );			final int iUnit = asInteger( oUnit );			SimpleDateFormat sdf = null;			String sText = null;			if ( fs != null ) // ONLY COMPUTE INTERNALLY IF FORMAT SPECIFIER			// ISN'T DEFINED			{				sdf = new SimpleDateFormat( CDateTime.getPreferredFormat( iUnit ) );			}			// ADJUST THE START POSITION			try			{				sText = ValueFormatter.format( cdt, fs, rtc.getLocale( ), sdf );			}			catch ( ChartException dfex )			{				logger.log( dfex );				sText = IConstants.NULL_STRING;			}			la.getCaption( ).setValue( sText );			BoundingBox bb = null;			try			{				bb = computeBox( xs, iLocation, la, 0, 0 );			}			catch ( IllegalArgumentException uiex )			{				throw new ChartException( ChartEnginePlugin.ID,						ChartException.GENERATION,						uiex );			}			if ( iOrientation == VERTICAL ) // VERTICAL AXIS			{				dStartShift = Math.max( dMaxSS,						( bb.getHeight( ) - bb.getHotPoint( ) ) );			}			else if ( iOrientation == HORIZONTAL )			{				dStartShift = Math.max( dMaxSS, bb.getHotPoint( ) );			}			// ADJUST THE END POSITION			cdt = asDateTime( getMaximum( ) );			try			{				sText = ValueFormatter.format( cdt, fs, rtc.getLocale( ), sdf );			}			catch ( ChartException dfex )			{				logger.log( dfex );				sText = IConstants.NULL_STRING;			}			la.getCaption( ).setValue( sText );			try			{				bb = computeBox( xs, iLocation, la, 0, dEnd );			}			catch ( IllegalArgumentException uiex )			{				throw new ChartException( ChartEnginePlugin.ID,						ChartException.GENERATION,						uiex );			}			if ( iOrientation == VERTICAL ) // VERTICAL AXIS			{				dEndShift = Math.max( dMaxES, bb.getHotPoint( ) );			}			else if ( iOrientation == HORIZONTAL )			{				dEndShift = Math.max( dMaxES,						( bb.getWidth( ) - bb.getHotPoint( ) ) );			}		}	}