: dY - IConstants.TICK_SIZE ) : dY; double dYMinorTick2 = ( ( iMinorTickStyle & IConstants.TICK_BELOW ) == IConstants.TICK_BELOW ) ? ( bRendering3D ? dY - IConstants.TICK_SIZE : dY + IConstants.TICK_SIZE )
	public final void renderEachAxis( IPrimitiveRenderer ipr, Plot pl,			OneAxis ax, int iWhatToDraw ) throws ChartException	{		final RunTimeContext rtc = getRunTimeContext( );		final Axis axModel = ax.getModelAxis( );		final PlotWithAxes pwa = (PlotWithAxes) getComputations( );		final Insets insCA = pwa.getAxes( ).getInsets( );		final ScriptHandler sh = getRunTimeContext( ).getScriptHandler( );		double dLocation = ax.getAxisCoordinate( );		double dAngleInDegrees = ax.getLabel( )				.getCaption( )				.getFont( )				.getRotation( );		AutoScale sc = ax.getScale( );		IntersectionValue iv = ax.getIntersectionValue( );		int iMajorTickStyle = ax.getGrid( ).getTickStyle( IConstants.MAJOR );		int iMinorTickStyle = ax.getGrid( ).getTickStyle( IConstants.MINOR );		int iLabelLocation = ax.getLabelPosition( );		int iOrientation = ax.getOrientation( );		Label la = ax.getLabel( );		final IDisplayServer xs = this.getDevice( ).getDisplayServer( );		double[] daEndPoints = sc.getEndPoints( );		double[] da = sc.getTickCordinates( );		double[] daMinor = sc.getMinorCoordinates( ax.getGrid( )				.getMinorCountPerMajor( ) );		String sText = null;		int iDimension = pwa.getDimension( );		double dSeriesThickness = pwa.getSeriesThickness( );		final NumberDataElement nde = NumberDataElementImpl.create( 0 );		final FormatSpecifier fs = ax.getModelAxis( ).getFormatSpecifier( );		final double dStaggeredLabelOffset = sc.computeStaggeredAxisLabelOffset( xs,				la,				iOrientation );		final boolean bAxisLabelStaggered = sc.isAxisLabelStaggered( );		DecimalFormat df = null;		LineAttributes lia = ax.getLineAttributes( );		LineAttributes liaMajorTick = ax.getGrid( )				.getTickAttributes( IConstants.MAJOR );		LineAttributes liaMinorTick = ax.getGrid( )				.getTickAttributes( IConstants.MINOR );		if ( !lia.isSetVisible( ) )		{			throw new ChartException( ChartEnginePlugin.ID,					ChartException.RENDERING,					"exception.unset.axis.visibility", //$NON-NLS-1$					ResourceBundle.getBundle( Messages.ENGINE,							getRunTimeContext( ).getLocale( ) ) );		}		final boolean bRenderAxisLabels = ( ( iWhatToDraw & IConstants.LABELS ) == IConstants.LABELS && la.isVisible( ) );		final boolean bRenderAxisTitle = ( ( iWhatToDraw & IConstants.LABELS ) == IConstants.LABELS );		Location lo = LocationImpl.create( 0, 0 );		final TransformationEvent trae = (TransformationEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),				TransformationEvent.class );		final TextRenderEvent tre = (TextRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),				TextRenderEvent.class );		tre.setLabel( la );		tre.setTextPosition( iLabelLocation );		tre.setLocation( lo );		final LineRenderEvent lre = (LineRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),				LineRenderEvent.class );		lre.setLineAttributes( lia );		lre.setStart( LocationImpl.create( 0, 0 ) );		lre.setEnd( LocationImpl.create( 0, 0 ) );		// Prepare 3D rendering variables.		final boolean bRendering3D = iDimension == IConstants.THREE_D;		final boolean bRenderOrthogonal3DAxis = ( iWhatToDraw & IConstants.ORTHOGONAL_AXIS ) == IConstants.ORTHOGONAL_AXIS				&& bRendering3D;		final boolean bRenderBase3DAxis = ( iWhatToDraw & IConstants.BASE_AXIS ) == IConstants.BASE_AXIS				&& bRendering3D;		final boolean bRenderAncillary3DAxis = ( iWhatToDraw & IConstants.ANCILLARY_AXIS ) == IConstants.ANCILLARY_AXIS				&& bRendering3D;		final DeferredCache dc = getDeferredCache( );		final int axisType = ax.getAxisType( );		double[] daEndPoints3D = null;		double[] da3D = null;		Location3D lo3d = null;		Text3DRenderEvent t3dre = null;		Line3DRenderEvent l3dre = null;		double dXStart = 0;		double dZStart = 0;		double dXEnd = 0;		double dZEnd = 0;		if ( iDimension == IConstants.THREE_D )		{			AllAxes aax = pwa.getAxes( );			dXEnd = aax.getPrimaryBase( ).getScale( ).getNormalizedEnd( );			dZEnd = aax.getAncillaryBase( ).getScale( ).getNormalizedEnd( );			dXStart = aax.getPrimaryBase( ).getScale( ).getNormalizedStart( );			dZStart = aax.getAncillaryBase( ).getScale( ).getNormalizedStart( );			daEndPoints3D = sc.getNormalizedEndPoints( );			da3D = sc.getNormalizedTickCoordinates( );			lo3d = Location3DImpl.create( 0, 0, 0 );			t3dre = (Text3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),					Text3DRenderEvent.class );			t3dre.setLabel( la );			t3dre.setAction( Text3DRenderEvent.RENDER_TEXT_AT_LOCATION );			t3dre.setTextPosition( iLabelLocation );			t3dre.setLocation3D( lo3d );			l3dre = (Line3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),					Line3DRenderEvent.class );			l3dre.setLineAttributes( lia );			l3dre.setStart3D( Location3DImpl.create( 0, 0, 0 ) );			l3dre.setEnd3D( Location3DImpl.create( 0, 0, 0 ) );		}		if ( iOrientation == IConstants.VERTICAL )		{			int y;			int y3d = 0;			double dX = dLocation;			double dZ = 0;			if ( bRendering3D )			{				Location3D l3d = ax.getAxisCoordinate3D( );				dX = l3d.getX( );				dZ = l3d.getZ( );			}			if ( iv != null					&& iv.getType( ) == IntersectionValue.MAX					&& iDimension == IConstants.TWO_5_D )			{				trae.setTransform( TransformationEvent.TRANSLATE );				trae.setTranslation( dSeriesThickness, -dSeriesThickness );				ipr.applyTransformation( trae );			}			double dXTick1 = ( ( iMajorTickStyle & IConstants.TICK_LEFT ) == IConstants.TICK_LEFT ) ? ( dX - IConstants.TICK_SIZE )					: dX;			double dXTick2 = ( ( iMajorTickStyle & IConstants.TICK_RIGHT ) == IConstants.TICK_RIGHT ) ? dX					+ IConstants.TICK_SIZE					: dX;			if ( ( iWhatToDraw & IConstants.AXIS ) == IConstants.AXIS					&& lia.isVisible( ) )			{				if ( bRenderOrthogonal3DAxis )				{					final double dStart = daEndPoints3D[0];					final double dEnd = daEndPoints3D[1];					l3dre.setLineAttributes( lia );					// center					l3dre.setStart3D( dX, dStart, dZ );					l3dre.setEnd3D( dX, dEnd, dZ );					dc.addLine( l3dre );					// left					l3dre.setStart3D( dXStart, dStart, dZEnd );					l3dre.setEnd3D( dXStart, dEnd, dZEnd );					dc.addLine( l3dre );					// right					l3dre.setStart3D( dXEnd, dStart, dZStart );					l3dre.setEnd3D( dXEnd, dEnd, dZStart );					dc.addLine( l3dre );				}				else				{					final double dStart = daEndPoints[0] + insCA.getBottom( ), dEnd = daEndPoints[1]							- insCA.getTop( );					if ( iv != null							&& iv.getType( ) == IntersectionValue.VALUE							&& iDimension == IConstants.TWO_5_D )					{						final Location[] loa = new Location[4];						loa[0] = LocationImpl.create( dX, dStart );						loa[1] = LocationImpl.create( dX + dSeriesThickness,								dStart - dSeriesThickness );						loa[2] = LocationImpl.create( dX + dSeriesThickness,								dEnd - dSeriesThickness );						loa[3] = LocationImpl.create( dX, dEnd );						final PolygonRenderEvent pre = (PolygonRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),								PolygonRenderEvent.class );						pre.setPoints( loa );						pre.setBackground( ColorDefinitionImpl.create( 255,								255,								255,								127 ) );						pre.setOutline( lia );						ipr.fillPolygon( pre );					}					lre.setLineAttributes( lia );					lre.getStart( ).set( dX, dStart );					lre.getEnd( ).set( dX, dEnd );					ipr.drawLine( lre );				}			}			if ( ( sc.getType( ) & IConstants.TEXT ) == IConstants.TEXT					|| sc.isCategoryScale( ) )			{				double dAngleInRadians = ( -dAngleInDegrees * Math.PI ) / 180;				double dSineTheta = Math.abs( Math.sin( dAngleInRadians ) );				double dCosTheta = Math.abs( Math.cos( dAngleInRadians ) );				double dOffset = 0, dW, dH, dHCosTheta;				double dUnitSize = sc.getUnitSize( );				DataSetIterator dsi = sc.getData( );				final int iDateTimeUnit = ( sc.getType( ) == IConstants.DATE_TIME ) ? CDateTime.computeUnit( dsi )						: IConstants.UNDEFINED;				final ITextMetrics itmText = xs.getTextMetrics( la );				if ( dAngleInDegrees == 90 || dAngleInDegrees == 0 )				{					dOffset = -dUnitSize / 2;				}				double x = ( iLabelLocation == IConstants.LEFT ) ? dXTick1 - 1						: dXTick2 + 1;				dsi.reset( );				for ( int i = 0; i < da.length - 1; i++ )				{					if ( bRenderAxisLabels )					{						la.getCaption( )								.setValue( sc.formatCategoryValue( sc.getType( ),										dsi.next( ),										iDateTimeUnit ) );						if ( sc.isTickLabelVisible( i ) )						{							ScriptHandler.callFunction( sh,									ScriptHandler.BEFORE_DRAW_AXIS_LABEL,									axModel,									la );							getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.BEFORE_DRAW_AXIS_LABEL,									la );							itmText.reuse( la ); // RECYCLED							dH = itmText.getFullHeight( );							dW = itmText.getFullWidth( );							dHCosTheta = dH * dCosTheta;							if ( dAngleInDegrees > 0 && dAngleInDegrees < 90 )							{								if ( iLabelLocation == IConstants.LEFT )								{									dOffset = ( dHCosTheta + dW * dSineTheta - dUnitSize )											/ 2											- dW											* dSineTheta;								}								else if ( iLabelLocation == IConstants.RIGHT )								{									dOffset = ( dHCosTheta + dW * dSineTheta - dUnitSize )											/ 2											- dHCosTheta;								}							}							else if ( dAngleInDegrees < 0									&& dAngleInDegrees > -90 )							{								if ( iLabelLocation == IConstants.LEFT )								{									dOffset = ( dHCosTheta + dW * dSineTheta - dUnitSize )											/ 2											- dHCosTheta;								}								else if ( iLabelLocation == IConstants.RIGHT )								{									dOffset = ( dHCosTheta + dW * dSineTheta - dUnitSize )											/ 2											- dW											* dSineTheta;								}							}							else if ( dAngleInDegrees == 0									|| dAngleInDegrees == 90									|| dAngleInDegrees == -90 )							{								dOffset = -dUnitSize / 2;							}						}					}					y = (int) da[i];					if ( bRendering3D )					{						y3d = (int) da3D[i];					}					if ( ( iWhatToDraw & IConstants.AXIS ) == IConstants.AXIS )					{						double dXMinorTick1 = ( ( iMinorTickStyle & IConstants.TICK_LEFT ) == IConstants.TICK_LEFT ) ? ( dX - IConstants.TICK_SIZE )								: dX;						double dXMinorTick2 = ( ( iMinorTickStyle & IConstants.TICK_RIGHT ) == IConstants.TICK_RIGHT ) ? dX								+ IConstants.TICK_SIZE								: dX;						if ( dXMinorTick1 != dXMinorTick2 )						{							// RENDER THE MINOR TICKS FIRST (For ALL but the							// last Major tick)							if ( i != da.length - 1 )							{								if ( bRenderOrthogonal3DAxis )								{									Line3DRenderEvent l3dreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										l3dreMinor = (Line3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												Line3DRenderEvent.class );										l3dreMinor.setLineAttributes( liaMinorTick );										l3dreMinor.setStart3D( Location3DImpl.create( dXMinorTick1,												y3d + daMinor[k],												dZ ) );										l3dreMinor.setEnd3D( Location3DImpl.create( dXMinorTick2,												y3d + daMinor[k],												dZ ) );										dc.addLine( l3dreMinor );									}								}								else								{									LineRenderEvent lreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										lreMinor = (LineRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												LineRenderEvent.class );										lreMinor.setLineAttributes( liaMinorTick );										lreMinor.setStart( LocationImpl.create( dXMinorTick1,												y - daMinor[k] ) );										lreMinor.setEnd( LocationImpl.create( dXMinorTick2,												y - daMinor[k] ) );										ipr.drawLine( lreMinor );									}								}							}						}						if ( dXTick1 != dXTick2 )						{							if ( bRenderOrthogonal3DAxis )							{								l3dre.setLineAttributes( liaMajorTick );								l3dre.setStart3D( dXTick1, y3d, dZ );								l3dre.setEnd3D( dXTick2, y3d, dZ );								dc.addLine( l3dre );							}							else							{								lre.setLineAttributes( liaMajorTick );								lre.getStart( ).set( dXTick1, y );								lre.getEnd( ).set( dXTick2, y );								ipr.drawLine( lre );							}							if ( iv != null									&& iDimension == IConstants.TWO_5_D									&& iv.getType( ) == IntersectionValue.VALUE )							{								lre.setStart( LocationImpl.create( dX, y ) );								lre.setEnd( LocationImpl.create( dX										+ dSeriesThickness, y										- dSeriesThickness ) );								ipr.drawLine( lre );							}						}					}					if ( bRenderAxisLabels && sc.isTickLabelVisible( i ) )					{						double sx = x;						double sx2 = dXEnd;						if ( bAxisLabelStaggered && i % 2 == 1 )						{							if ( iLabelLocation == IConstants.LEFT )							{								sx -= dStaggeredLabelOffset;								sx2 -= dStaggeredLabelOffset;							}							else							{								sx += dStaggeredLabelOffset;								sx2 += dStaggeredLabelOffset;							}						}						if ( bRendering3D )						{							// Left wall							lo3d.set( sx, y3d + dOffset, dZEnd );							t3dre.setLocation3D( lo3d );							t3dre.setTextPosition( TextRenderEvent.LEFT );							t3dre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							dc.addLabel( t3dre );							// Right wall							lo3d.set( sx2, y3d + dOffset, dZ );							t3dre.setLocation3D( lo3d );							t3dre.setTextPosition( TextRenderEvent.RIGHT );							t3dre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							dc.addLabel( t3dre );						}						else						{							lo.set( sx, y + dOffset );							tre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							ipr.drawText( tre );						}						ScriptHandler.callFunction( sh,								ScriptHandler.AFTER_DRAW_AXIS_LABEL,								axModel,								la );						getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.AFTER_DRAW_AXIS_LABEL,								la );					}				}				y = (int) da[da.length - 1];				if ( bRendering3D )				{					y3d = (int) da3D[da3D.length - 1];				}				if ( dXTick1 != dXTick2 )				{					if ( bRenderOrthogonal3DAxis )					{						l3dre.setLineAttributes( liaMajorTick );						l3dre.setStart3D( dXTick1, y3d, dZ );						l3dre.setEnd3D( dXTick2, y3d, dZ );						dc.addLine( l3dre );					}					else					{						lre.setLineAttributes( liaMajorTick );						lre.getStart( ).set( dXTick1, y );						lre.getEnd( ).set( dXTick2, y );						ipr.drawLine( lre );					}					if ( iv != null							&& iDimension == IConstants.TWO_5_D							&& iv.getType( ) == IntersectionValue.VALUE )					{						lre.setStart( LocationImpl.create( dX, y ) );						lre.setEnd( LocationImpl.create( dX + dSeriesThickness,								y - dSeriesThickness ) );						ipr.drawLine( lre );					}				}				itmText.dispose( );// DISPOSED			}			else if ( ( sc.getType( ) & IConstants.LOGARITHMIC ) == IConstants.LOGARITHMIC )			{				double dAxisValue = Methods.asDouble( sc.getMinimum( ) )						.doubleValue( );				final double dAxisStep = Methods.asDouble( sc.getStep( ) )						.doubleValue( );				dAxisValue = Methods.asDouble( sc.getMinimum( ) ).doubleValue( ); // RESET				double x = ( iLabelLocation == IConstants.LEFT ) ? dXTick1 - 1						: dXTick2 + 1;				for ( int i = 0; i < da.length; i++ )				{					if ( bRenderAxisLabels ) // PERFORM COMPUTATIONS ONLY IF					// AXIS LABEL IS VISIBLE					{						if ( fs == null )						{							df = new DecimalFormat( sc.getNumericPattern( dAxisValue ) );						}						nde.setValue( dAxisValue );						try						{							sText = ValueFormatter.format( nde,									fs,									ax.getRunTimeContext( ).getLocale( ),									df );						}						catch ( ChartException dfex )						{							logger.log( dfex );							sText = IConstants.NULL_STRING;						}					}					y = (int) da[i];					if ( bRendering3D )					{						y3d = (int) da3D[i];					}					if ( ( iWhatToDraw & IConstants.AXIS ) == IConstants.AXIS )					{						double dXMinorTick1 = ( ( iMinorTickStyle & IConstants.TICK_LEFT ) == IConstants.TICK_LEFT ) ? ( dX - IConstants.TICK_SIZE )								: dX;						double dXMinorTick2 = ( ( iMinorTickStyle & IConstants.TICK_RIGHT ) == IConstants.TICK_RIGHT ) ? dX								+ IConstants.TICK_SIZE								: dX;						if ( dXMinorTick1 != dXMinorTick2 )						{							// RENDER THE MINOR TICKS FIRST (For ALL but the							// last Major tick)							if ( i != da.length - 1 )							{								if ( bRenderOrthogonal3DAxis )								{									Line3DRenderEvent l3dreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										l3dreMinor = (Line3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												Line3DRenderEvent.class );										l3dreMinor.setLineAttributes( liaMinorTick );										l3dreMinor.setStart3D( Location3DImpl.create( dXMinorTick1,												y3d + daMinor[k],												dZ ) );										l3dreMinor.setEnd3D( Location3DImpl.create( dXMinorTick2,												y3d + daMinor[k],												dZ ) );										dc.addLine( l3dreMinor );									}								}								else								{									LineRenderEvent lreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										lreMinor = (LineRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												LineRenderEvent.class );										lreMinor.setLineAttributes( liaMinorTick );										lreMinor.setStart( LocationImpl.create( dXMinorTick1,												y - daMinor[k] ) );										lreMinor.setEnd( LocationImpl.create( dXMinorTick2,												y - daMinor[k] ) );										ipr.drawLine( lreMinor );									}								}							}						}						if ( dXTick1 != dXTick2 )						{							if ( bRenderOrthogonal3DAxis )							{								l3dre.setLineAttributes( liaMajorTick );								l3dre.setStart3D( dXTick1, y3d, dZ );								l3dre.setEnd3D( dXTick2, y3d, dZ );								dc.addLine( l3dre );							}							else							{								lre.setLineAttributes( liaMajorTick );								lre.getStart( ).set( dXTick1, y );								lre.getEnd( ).set( dXTick2, y );								ipr.drawLine( lre );							}							if ( iv != null									&& iDimension == IConstants.TWO_5_D									&& iv.getType( ) == IntersectionValue.VALUE )							{								lre.setLineAttributes( lia );								lre.setStart( LocationImpl.create( dX, y ) );								lre.setEnd( LocationImpl.create( dX										+ dSeriesThickness, y										- dSeriesThickness ) );								ipr.drawLine( lre );							}						}					}					if ( bRenderAxisLabels ) // RENDER LABELS ONLY IF					// REQUESTED					{						double sx = x;						double sx2 = dXEnd;						if ( bAxisLabelStaggered && i % 2 == 1 )						{							if ( iLabelLocation == IConstants.LEFT )							{								sx -= dStaggeredLabelOffset;								sx2 -= dStaggeredLabelOffset;							}							else							{								sx += dStaggeredLabelOffset;								sx2 += dStaggeredLabelOffset;							}						}						ScriptHandler.callFunction( sh,								ScriptHandler.BEFORE_DRAW_AXIS_LABEL,								axModel,								la );						getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.BEFORE_DRAW_AXIS_LABEL,								la );						if ( bRendering3D )						{							// Left wall							lo3d.set( sx, y3d, dZEnd );							la.getCaption( ).setValue( sText );							t3dre.setLocation3D( lo3d );							t3dre.setTextPosition( TextRenderEvent.LEFT );							t3dre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							dc.addLabel( t3dre );							// Right wall							lo3d.set( sx2, y3d, dZ );							la.getCaption( ).setValue( sText );							t3dre.setLocation3D( lo3d );							t3dre.setTextPosition( TextRenderEvent.RIGHT );							t3dre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							dc.addLabel( t3dre );						}						else						{							lo.set( sx, y );							la.getCaption( ).setValue( sText );							tre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							ipr.drawText( tre );						}						ScriptHandler.callFunction( sh,								ScriptHandler.AFTER_DRAW_AXIS_LABEL,								axModel,								la );						getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.AFTER_DRAW_AXIS_LABEL,								la );					}					dAxisValue *= dAxisStep;				}			}			else if ( ( sc.getType( ) & IConstants.LINEAR ) == IConstants.LINEAR )			{				double dAxisValue = Methods.asDouble( sc.getMinimum( ) )						.doubleValue( );				final double dAxisStep = Methods.asDouble( sc.getStep( ) )						.doubleValue( );				if ( fs == null )				{					df = new DecimalFormat( sc.getNumericPattern( ) );				}				dAxisValue = Methods.asDouble( sc.getMinimum( ) ).doubleValue( ); // RESET				double x = ( iLabelLocation == IConstants.LEFT ) ? dXTick1 - 1						: dXTick2 + 1;				for ( int i = 0; i < da.length; i++ )				{					nde.setValue( dAxisValue );					try					{						sText = ValueFormatter.format( nde,								fs,								ax.getRunTimeContext( ).getLocale( ),								df );					}					catch ( ChartException dfex )					{						logger.log( dfex );						sText = IConstants.NULL_STRING;					}					y = (int) da[i];					if ( bRendering3D )					{						y3d = (int) da3D[i];					}					if ( ( iWhatToDraw & IConstants.AXIS ) == IConstants.AXIS )					{						double dXMinorTick1 = ( ( iMinorTickStyle & IConstants.TICK_LEFT ) == IConstants.TICK_LEFT ) ? ( dX - IConstants.TICK_SIZE )								: dX, dXMinorTick2 = ( ( iMinorTickStyle & IConstants.TICK_RIGHT ) == IConstants.TICK_RIGHT ) ? dX								+ IConstants.TICK_SIZE								: dX;						if ( dXMinorTick1 != dXMinorTick2 )						{							// RENDER THE MINOR TICKS FIRST (For ALL but the							// last Major tick)							if ( i != da.length - 1 )							{								if ( bRenderOrthogonal3DAxis )								{									Line3DRenderEvent l3dreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										l3dreMinor = (Line3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												Line3DRenderEvent.class );										l3dreMinor.setLineAttributes( liaMinorTick );										l3dreMinor.setStart3D( Location3DImpl.create( dXMinorTick1,												y3d + daMinor[k],												dZ ) );										l3dreMinor.setEnd3D( Location3DImpl.create( dXMinorTick2,												y3d + daMinor[k],												dZ ) );										dc.addLine( l3dreMinor );									}								}								else								{									LineRenderEvent lreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										lreMinor = (LineRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												LineRenderEvent.class );										lreMinor.setLineAttributes( liaMinorTick );										lreMinor.setStart( LocationImpl.create( dXMinorTick1,												y - daMinor[k] ) );										lreMinor.setEnd( LocationImpl.create( dXMinorTick2,												y - daMinor[k] ) );										ipr.drawLine( lreMinor );									}								}							}						}						if ( dXTick1 != dXTick2 )						{							if ( bRenderOrthogonal3DAxis )							{								l3dre.setLineAttributes( liaMajorTick );								l3dre.setStart3D( dXTick1, y3d, dZ );								l3dre.setEnd3D( dXTick2, y3d, dZ );								dc.addLine( l3dre );							}							else							{								lre.setLineAttributes( liaMajorTick );								lre.getStart( ).set( dXTick1, y );								lre.getEnd( ).set( dXTick2, y );								ipr.drawLine( lre );							}							if ( iv != null									&& iDimension == IConstants.TWO_5_D									&& iv.getType( ) == IntersectionValue.VALUE )							{								lre.setLineAttributes( lia );								lre.setStart( LocationImpl.create( dX, y ) );								lre.setEnd( LocationImpl.create( dX										+ dSeriesThickness, y										- dSeriesThickness ) );								ipr.drawLine( lre );							}						}					}					if ( bRenderAxisLabels )					{						double sx = x;						double sx2 = dXEnd;						if ( bAxisLabelStaggered && i % 2 == 1 )						{							if ( iLabelLocation == IConstants.LEFT )							{								sx -= dStaggeredLabelOffset;								sx2 -= dStaggeredLabelOffset;							}							else							{								sx += dStaggeredLabelOffset;								sx2 += dStaggeredLabelOffset;							}						}						ScriptHandler.callFunction( sh,								ScriptHandler.BEFORE_DRAW_AXIS_LABEL,								axModel,								la );						getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.BEFORE_DRAW_AXIS_LABEL,								la );						if ( bRendering3D )						{							// Left wall							lo3d.set( sx, y3d, dZEnd );							la.getCaption( ).setValue( sText );							t3dre.setLocation3D( lo3d );							t3dre.setTextPosition( TextRenderEvent.LEFT );							t3dre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							dc.addLabel( t3dre );							// Right wall							lo3d.set( sx2, y3d, dZ );							la.getCaption( ).setValue( sText );							t3dre.setLocation3D( lo3d );							t3dre.setTextPosition( TextRenderEvent.RIGHT );							t3dre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							dc.addLabel( t3dre );						}						else						{							lo.set( sx, y );							la.getCaption( ).setValue( sText );							tre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							ipr.drawText( tre );						}						ScriptHandler.callFunction( sh,								ScriptHandler.AFTER_DRAW_AXIS_LABEL,								axModel,								la );						getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.AFTER_DRAW_AXIS_LABEL,								la );					}					dAxisValue += dAxisStep;				}			}			else if ( ( sc.getType( ) & IConstants.DATE_TIME ) == IConstants.DATE_TIME )			{				CDateTime cdt, cdtAxisValue = Methods.asDateTime( sc.getMinimum( ) );				final int iUnit = Methods.asInteger( sc.getUnit( ) );				final int iStep = Methods.asInteger( sc.getStep( ) );				SimpleDateFormat sdf = null;				if ( fs == null )				{					sdf = new SimpleDateFormat( CDateTime.getPreferredFormat( iUnit ) );				}				cdt = cdtAxisValue;				double x = ( iLabelLocation == IConstants.LEFT ) ? dXTick1 - 1						: dXTick2 + 1;				for ( int i = 0; i < da.length; i++ )				{					try					{						sText = ValueFormatter.format( cdt,								ax.getFormatSpecifier( ),								ax.getRunTimeContext( ).getLocale( ),								sdf );					}					catch ( ChartException dfex )					{						logger.log( dfex );						sText = IConstants.NULL_STRING;					}					y = (int) da[i];					if ( bRendering3D )					{						y3d = (int) da3D[i];					}					if ( ( iWhatToDraw & IConstants.AXIS ) == IConstants.AXIS )					{						double dXMinorTick1 = ( ( iMinorTickStyle & IConstants.TICK_LEFT ) == IConstants.TICK_LEFT ) ? ( dX - IConstants.TICK_SIZE )								: dX, dXMinorTick2 = ( ( iMinorTickStyle & IConstants.TICK_RIGHT ) == IConstants.TICK_RIGHT ) ? dX								+ IConstants.TICK_SIZE								: dX;						if ( dXMinorTick1 != dXMinorTick2 )						{							// RENDER THE MINOR TICKS FIRST (For ALL but the							// last Major tick)							if ( i != da.length - 1 )							{								if ( bRenderOrthogonal3DAxis )								{									Line3DRenderEvent l3dreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										l3dreMinor = (Line3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												Line3DRenderEvent.class );										l3dreMinor.setLineAttributes( liaMinorTick );										l3dreMinor.setStart3D( Location3DImpl.create( dXMinorTick1,												y3d + daMinor[k],												dZ ) );										l3dreMinor.setEnd3D( Location3DImpl.create( dXMinorTick2,												y3d + daMinor[k],												dZ ) );										dc.addLine( l3dreMinor );									}								}								else								{									LineRenderEvent lreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										lreMinor = (LineRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												LineRenderEvent.class );										lreMinor.setLineAttributes( liaMinorTick );										lreMinor.setStart( LocationImpl.create( dXMinorTick1,												y - daMinor[k] ) );										lreMinor.setEnd( LocationImpl.create( dXMinorTick2,												y - daMinor[k] ) );										ipr.drawLine( lreMinor );									}								}							}						}						if ( dXTick1 != dXTick2 )						{							if ( bRenderOrthogonal3DAxis )							{								l3dre.setLineAttributes( liaMajorTick );								l3dre.setStart3D( dXTick1, y3d, dZ );								l3dre.setEnd3D( dXTick2, y3d, dZ );								dc.addLine( l3dre );							}							else							{								lre.setLineAttributes( liaMajorTick );								lre.getStart( ).set( dXTick1, y );								lre.getEnd( ).set( dXTick2, y );								ipr.drawLine( lre );							}							if ( iv != null									&& iDimension == IConstants.TWO_5_D									&& iv.getType( ) == IntersectionValue.VALUE )							{								lre.setStart( LocationImpl.create( dX, y ) );								lre.setEnd( LocationImpl.create( dX										+ dSeriesThickness, y										- dSeriesThickness ) );								ipr.drawLine( lre );							}						}					}					if ( bRenderAxisLabels )					{						double sx = x;						double sx2 = dXEnd;						if ( bAxisLabelStaggered && i % 2 == 1 )						{							if ( iLabelLocation == IConstants.LEFT )							{								sx -= dStaggeredLabelOffset;								sx2 -= dStaggeredLabelOffset;							}							else							{								sx += dStaggeredLabelOffset;								sx2 += dStaggeredLabelOffset;							}						}						ScriptHandler.callFunction( sh,								ScriptHandler.BEFORE_DRAW_AXIS_LABEL,								axModel,								la );						getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.BEFORE_DRAW_AXIS_LABEL,								la );						if ( bRendering3D )						{							// Left wall							lo3d.set( sx, y3d, dZEnd );							la.getCaption( ).setValue( sText );							t3dre.setLocation3D( lo3d );							t3dre.setTextPosition( TextRenderEvent.LEFT );							t3dre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							dc.addLabel( t3dre );							// Right wall							lo3d.set( sx2, y3d, dZ );							la.getCaption( ).setValue( sText );							t3dre.setLocation3D( lo3d );							t3dre.setTextPosition( TextRenderEvent.RIGHT );							t3dre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							dc.addLabel( t3dre );						}						else						{							lo.set( sx, y );							la.getCaption( ).setValue( sText );							tre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							ipr.drawText( tre );						}						ScriptHandler.callFunction( sh,								ScriptHandler.AFTER_DRAW_AXIS_LABEL,								axModel,								la );						getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.AFTER_DRAW_AXIS_LABEL,								la );					}					cdt = cdtAxisValue.forward( iUnit, iStep * ( i + 1 ) ); // ALWAYS					// W.R.T					// START					// VALUE				}			}			la = ax.getTitle( ); // TEMPORARILY USE FOR AXIS TITLE			if ( la.isVisible( ) && bRenderAxisTitle )			{				ScriptHandler.callFunction( sh,						ScriptHandler.BEFORE_DRAW_AXIS_TITLE,						axModel,						la );				getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.BEFORE_DRAW_AXIS_TITLE,						la );				final String sRestoreValue = la.getCaption( ).getValue( );				la.getCaption( )						.setValue( rtc.externalizedMessage( sRestoreValue ) );				BoundingBox bb = null;				try				{					bb = Methods.computeBox( xs,							ax.getTitlePosition( ),							la,							0,							0 );				}				catch ( IllegalArgumentException uiex )				{					throw new ChartException( ChartEnginePlugin.ID,							ChartException.RENDERING,							uiex );				}				if ( bRendering3D )				{					Bounds cbo = getPlotBounds( );					tre.setBlockBounds( BoundsImpl.create( cbo.getLeft( )							+ ( cbo.getWidth( ) / 3d - bb.getWidth( ) )							/ 2d,							cbo.getTop( ) + 30,							bb.getWidth( ),							bb.getHeight( ) ) );					tre.setLabel( la );					tre.setBlockAlignment( null );					tre.setAction( TextRenderEvent.RENDER_TEXT_IN_BLOCK );					ipr.drawText( tre );					tre.setBlockBounds( BoundsImpl.create( cbo.getLeft( )							+ cbo.getWidth( )							- bb.getWidth( ),							cbo.getTop( ) + 30 * 2,							bb.getWidth( ),							bb.getHeight( ) ) );					ipr.drawText( tre );				}				else				{					final Bounds bo = BoundsImpl.create( ax.getTitleCoordinate( ),							daEndPoints[1],							bb.getWidth( ),							daEndPoints[0] - daEndPoints[1] );					tre.setBlockBounds( bo );					tre.setLabel( la );					tre.setBlockAlignment( null );					tre.setAction( TextRenderEvent.RENDER_TEXT_IN_BLOCK );					ipr.drawText( tre );				}				la.getCaption( ).setValue( sRestoreValue );				ScriptHandler.callFunction( sh,						ScriptHandler.AFTER_DRAW_AXIS_TITLE,						axModel,						la );				getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.AFTER_DRAW_AXIS_TITLE,						la );			}			la = ax.getLabel( );			if ( iv != null					&& iv.getType( ) == IntersectionValue.MAX					&& iDimension == IConstants.TWO_5_D )			{				trae.setTranslation( -dSeriesThickness, dSeriesThickness );				ipr.applyTransformation( trae );			}		}		else if ( iOrientation == IConstants.HORIZONTAL )		{			int x;			int x3d = 0;			int z3d = 0;			double dY = dLocation;			double dX = 0;			double dZ = 0;			if ( bRendering3D )			{				Location3D l3d = ax.getAxisCoordinate3D( );				dX = l3d.getX( );				dY = l3d.getY( );				dZ = l3d.getZ( );			}			double dYTick1 = ( ( iMajorTickStyle & IConstants.TICK_ABOVE ) == IConstants.TICK_ABOVE ) ? ( dY - IConstants.TICK_SIZE )					: dY;			double dYTick2 = ( ( iMajorTickStyle & IConstants.TICK_BELOW ) == IConstants.TICK_BELOW ) ? dY					+ IConstants.TICK_SIZE					: dY;			if ( iv != null					&& iv.getType( ) == IntersectionValue.MAX					&& iDimension == IConstants.TWO_5_D )			{				trae.setTransform( TransformationEvent.TRANSLATE );				trae.setTranslation( dSeriesThickness, -dSeriesThickness );				ipr.applyTransformation( trae );			}			if ( ( iWhatToDraw & IConstants.AXIS ) == IConstants.AXIS					&& lia.isVisible( ) )			{				if ( bRenderBase3DAxis )				{					final double dStart = daEndPoints3D[0];					final double dEnd = daEndPoints3D[1];					l3dre.setLineAttributes( lia );					l3dre.setStart3D( dStart, dY, dZ );					l3dre.setEnd3D( dEnd, dY, dZ );					dc.addLine( l3dre );				}				else if ( bRenderAncillary3DAxis )				{					final double dStart = daEndPoints3D[0];					final double dEnd = daEndPoints3D[1];					l3dre.setLineAttributes( lia );					l3dre.setStart3D( dX, dY, dStart );					l3dre.setEnd3D( dX, dY, dEnd );					dc.addLine( l3dre );				}				else				{					final double dStart = daEndPoints[0] - insCA.getLeft( ), dEnd = daEndPoints[1]							+ insCA.getRight( );					if ( iv != null							&& iv.getType( ) == IntersectionValue.VALUE							&& iDimension == IConstants.TWO_5_D )					{						// Zero plane.						final Location[] loa = new Location[4];						loa[0] = LocationImpl.create( dStart, dY );						loa[1] = LocationImpl.create( dStart + dSeriesThickness,								dY - dSeriesThickness );						loa[2] = LocationImpl.create( dEnd + dSeriesThickness,								dY - dSeriesThickness );						loa[3] = LocationImpl.create( dEnd, dY );						final PolygonRenderEvent pre = (PolygonRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),								PolygonRenderEvent.class );						pre.setPoints( loa );						pre.setBackground( ColorDefinitionImpl.create( 255,								255,								255,								127 ) );						pre.setOutline( lia );						ipr.fillPolygon( pre );					}					lre.setLineAttributes( lia );					lre.getStart( ).set( dStart, dY );					lre.getEnd( ).set( dEnd, dY );					ipr.drawLine( lre );				}			}			if ( ( sc.getType( ) & IConstants.TEXT ) == IConstants.TEXT					|| sc.isCategoryScale( ) )			{				double dAngleInRadians = ( -dAngleInDegrees * Math.PI ) / 180;				double dSineTheta = Math.abs( Math.sin( dAngleInRadians ) );				double dCosTheta = Math.abs( Math.cos( dAngleInRadians ) );				double dOffset = 0, dW, dH, dHSineTheta;				double dUnitSize = sc.getUnitSize( );				DataSetIterator dsi = sc.getData( );				final int iDateTimeUnit = ( sc.getType( ) == IConstants.DATE_TIME ) ? CDateTime.computeUnit( dsi )						: IConstants.UNDEFINED;				final ITextMetrics itmText = xs.getTextMetrics( la );				if ( dAngleInDegrees == 90 || dAngleInDegrees == 0 )				{					dOffset = dUnitSize / 2;				}				double y = ( iLabelLocation == IConstants.ABOVE ) ? dYTick1 - 1						: dYTick2 + 1;				dsi.reset( );				for ( int i = 0; i < da.length - 1; i++ )				{					x = (int) da[i];					if ( bRendering3D )					{						x3d = (int) da3D[i];						z3d = (int) da3D[i];					}					if ( ( iWhatToDraw & IConstants.AXIS ) == IConstants.AXIS )					{						double dYMinorTick1 = ( ( iMinorTickStyle & IConstants.TICK_ABOVE ) == IConstants.TICK_ABOVE ) ? ( dY - IConstants.TICK_SIZE )								: dY, dYMinorTick2 = ( ( iMinorTickStyle & IConstants.TICK_BELOW ) == IConstants.TICK_BELOW ) ? dY								+ IConstants.TICK_SIZE								: dY;						if ( dYMinorTick1 != -dYMinorTick2 )						{							// RENDER THE MINOR TICKS FIRST (For ALL but the							// last Major tick)							if ( i != da.length - 1 )							{								if ( bRenderBase3DAxis )								{									Line3DRenderEvent l3dreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										l3dreMinor = (Line3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												Line3DRenderEvent.class );										l3dreMinor.setLineAttributes( liaMinorTick );										l3dreMinor.setStart3D( Location3DImpl.create( x3d												+ daMinor[k],												dYMinorTick1,												dZ ) );										l3dreMinor.setEnd3D( Location3DImpl.create( x3d												+ daMinor[k],												dYMinorTick2,												dZ ) );										dc.addLine( l3dreMinor );									}								}								else if ( bRenderAncillary3DAxis )								{									Line3DRenderEvent l3dreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										l3dreMinor = (Line3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												Line3DRenderEvent.class );										l3dreMinor.setLineAttributes( liaMinorTick );										l3dreMinor.setStart3D( Location3DImpl.create( dX,												dYMinorTick1,												z3d + daMinor[k] ) );										l3dreMinor.setEnd3D( Location3DImpl.create( dX,												dYMinorTick2,												z3d + daMinor[k] ) );										dc.addLine( l3dreMinor );									}								}								else								{									LineRenderEvent lreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										lreMinor = (LineRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												LineRenderEvent.class );										lreMinor.setLineAttributes( liaMinorTick );										lreMinor.setStart( LocationImpl.create( x												+ daMinor[k],												dYMinorTick1 ) );										lreMinor.setEnd( LocationImpl.create( x												+ daMinor[k], dYMinorTick2 ) );										ipr.drawLine( lreMinor );									}								}							}						}						if ( dYTick1 != dYTick2 )						{							if ( bRenderBase3DAxis )							{								l3dre.setLineAttributes( liaMajorTick );								l3dre.setStart3D( x3d, dYTick1, dZ );								l3dre.setEnd3D( x3d, dYTick2, dZ );								dc.addLine( l3dre );							}							else if ( bRenderAncillary3DAxis )							{								l3dre.setLineAttributes( liaMajorTick );								l3dre.setStart3D( dX, dYTick1, z3d );								l3dre.setEnd3D( dX, dYTick2, z3d );								dc.addLine( l3dre );							}							else							{								lre.setLineAttributes( liaMajorTick );								lre.getStart( ).set( x, dYTick1 );								lre.getEnd( ).set( x, dYTick2 );								ipr.drawLine( lre );							}							if ( iv != null									&& iDimension == IConstants.TWO_5_D									&& iv.getType( ) == IntersectionValue.VALUE )							{								lre.getStart( ).set( x, dY );								lre.getEnd( ).set( x + dSeriesThickness,										dY - dSeriesThickness );								ipr.drawLine( lre );							}						}					}					if ( bRenderAxisLabels )					{						la.getCaption( )								.setValue( sc.formatCategoryValue( sc.getType( ),										dsi.next( ), // step to next value.										iDateTimeUnit ) );						if ( sc.isTickLabelVisible( i ) )						{							ScriptHandler.callFunction( sh,									ScriptHandler.BEFORE_DRAW_AXIS_LABEL,									axModel,									la );							getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.BEFORE_DRAW_AXIS_LABEL,									la );							itmText.reuse( la );// RECYCLED							dH = itmText.getFullHeight( );							dW = itmText.getFullWidth( );							dHSineTheta = dH * dSineTheta;							if ( dAngleInDegrees > 0 && dAngleInDegrees < 90 )							{								if ( iLabelLocation == IConstants.ABOVE )								{									dOffset = dUnitSize											/ 2											- ( dW * dCosTheta + dHSineTheta )											/ 2											+ dHSineTheta;								}								else if ( iLabelLocation == IConstants.BELOW )								{									dOffset = dUnitSize											+ dHSineTheta											- ( dUnitSize - dW * dCosTheta + dHSineTheta )											/ 2											- dHSineTheta;								}							}							else if ( dAngleInDegrees < 0									&& dAngleInDegrees > -90 )							{								if ( iLabelLocation == IConstants.ABOVE )								{									dOffset = dUnitSize											/ 2											- dHSineTheta											/ 2											+ ( dW * dCosTheta + dHSineTheta )											/ 2;								}								else if ( iLabelLocation == IConstants.BELOW )								{									dOffset = ( dUnitSize - dW * dCosTheta + dHSineTheta ) / 2;								}							}							else if ( dAngleInDegrees == 0									|| dAngleInDegrees == 90									|| dAngleInDegrees == -90 )							{								dOffset = dUnitSize / 2;							}							double sy = y;							if ( bAxisLabelStaggered && i % 2 == 1 )							{								if ( iLabelLocation == IConstants.ABOVE )								{									sy -= dStaggeredLabelOffset;								}								else								{									sy += dStaggeredLabelOffset;								}							}							if ( bRendering3D )							{								if ( axisType == IConstants.BASE_AXIS )								{									lo3d.set( x3d + dOffset, sy, dZEnd );								}								else								{									lo3d.set( dXEnd, sy, z3d + dOffset );								}								t3dre.setLocation3D( lo3d );								t3dre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );								dc.addLabel( t3dre );							}							else							{								lo.set( x + dOffset, sy );								tre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );								ipr.drawText( tre );							}							ScriptHandler.callFunction( sh,									ScriptHandler.AFTER_DRAW_AXIS_LABEL,									axModel,									la );							getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.AFTER_DRAW_AXIS_LABEL,									la );						}					}				}				// ONE LAST TICK				x = (int) da[da.length - 1];				if ( ( iWhatToDraw & IConstants.AXIS ) == IConstants.AXIS )				{					if ( dYTick1 != dYTick2 )					{						if ( bRenderBase3DAxis )						{							l3dre.setLineAttributes( liaMajorTick );							l3dre.setStart3D( x3d, dYTick1, dZ );							l3dre.setEnd3D( x3d, dYTick2, dZ );							dc.addLine( l3dre );						}						else if ( bRenderAncillary3DAxis )						{							l3dre.setLineAttributes( liaMajorTick );							l3dre.setStart3D( dX, dYTick1, z3d );							l3dre.setEnd3D( dX, dYTick2, z3d );							dc.addLine( l3dre );						}						else						{							lre.setLineAttributes( liaMajorTick );							lre.getStart( ).set( x, dYTick1 );							lre.getEnd( ).set( x, dYTick2 );							ipr.drawLine( lre );						}						if ( iv != null								&& iDimension == IConstants.TWO_5_D								&& iv.getType( ) == IntersectionValue.VALUE )						{							lre.getStart( ).set( x, dY );							lre.getEnd( ).set( x + dSeriesThickness,									dY - dSeriesThickness );							ipr.drawLine( lre );						}					}				}				itmText.dispose( ); // DISPOSED			}			else if ( ( sc.getType( ) & IConstants.LINEAR ) == IConstants.LINEAR )			{				double dAxisValue = Methods.asDouble( sc.getMinimum( ) )						.doubleValue( );				final double dAxisStep = Methods.asDouble( sc.getStep( ) )						.doubleValue( );				if ( fs == null )				{					df = new DecimalFormat( sc.getNumericPattern( ) );				}				dAxisValue = Methods.asDouble( sc.getMinimum( ) ).doubleValue( ); // RESET				double y = ( iLabelLocation == IConstants.ABOVE ) ? dYTick1 - 1						: dYTick2 + 1;				for ( int i = 0; i < da.length; i++ )				{					x = (int) da[i];					if ( bRendering3D )					{						x3d = (int) da3D[i];						z3d = (int) da3D[i];					}					if ( ( iWhatToDraw & IConstants.AXIS ) == IConstants.AXIS )					{						double dYMinorTick1 = ( ( iMinorTickStyle & IConstants.TICK_ABOVE ) == IConstants.TICK_ABOVE ) ? ( dY - IConstants.TICK_SIZE )								: dY, dYMinorTick2 = ( ( iMinorTickStyle & IConstants.TICK_BELOW ) == IConstants.TICK_BELOW ) ? dY								+ IConstants.TICK_SIZE								: dY;						if ( dYMinorTick1 != -dYMinorTick2 )						{							// RENDER THE MINOR TICKS FIRST (For ALL but the							// last Major tick)							if ( i != da.length - 1 )							{								if ( bRenderBase3DAxis )								{									Line3DRenderEvent l3dreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										l3dreMinor = (Line3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												Line3DRenderEvent.class );										l3dreMinor.setLineAttributes( liaMinorTick );										l3dreMinor.setStart3D( Location3DImpl.create( x3d												+ daMinor[k],												dYMinorTick1,												dZ ) );										l3dreMinor.setEnd3D( Location3DImpl.create( x3d												+ daMinor[k],												dYMinorTick2,												dZ ) );										dc.addLine( l3dreMinor );									}								}								else if ( bRenderAncillary3DAxis )								{									Line3DRenderEvent l3dreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										l3dreMinor = (Line3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												Line3DRenderEvent.class );										l3dreMinor.setLineAttributes( liaMinorTick );										l3dreMinor.setStart3D( Location3DImpl.create( dX,												dYMinorTick1,												z3d + daMinor[k] ) );										l3dreMinor.setEnd3D( Location3DImpl.create( dX,												dYMinorTick2,												z3d + daMinor[k] ) );										dc.addLine( l3dreMinor );									}								}								else								{									LineRenderEvent lreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										lreMinor = (LineRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												LineRenderEvent.class );										lreMinor.setLineAttributes( liaMinorTick );										lreMinor.setStart( LocationImpl.create( x												+ daMinor[k],												dYMinorTick1 ) );										lreMinor.setEnd( LocationImpl.create( x												+ daMinor[k], dYMinorTick2 ) );										ipr.drawLine( lreMinor );									}								}							}						}						if ( dYTick1 != dYTick2 )						{							if ( bRenderBase3DAxis )							{								l3dre.setLineAttributes( liaMajorTick );								l3dre.setStart3D( x3d, dYTick1, dZ );								l3dre.setEnd3D( x3d, dYTick2, dZ );								dc.addLine( l3dre );							}							else if ( bRenderAncillary3DAxis )							{								l3dre.setLineAttributes( liaMajorTick );								l3dre.setStart3D( dX, dYTick1, z3d );								l3dre.setEnd3D( dX, dYTick2, z3d );								dc.addLine( l3dre );							}							else							{								lre.setLineAttributes( liaMajorTick );								lre.getStart( ).set( x, dYTick1 );								lre.getEnd( ).set( x, dYTick2 );								ipr.drawLine( lre );							}							if ( iv != null									&& iDimension == IConstants.TWO_5_D									&& iv.getType( ) == IntersectionValue.VALUE )							{								lre.getStart( ).set( x, dY );								lre.getEnd( ).set( x + dSeriesThickness,										dY - dSeriesThickness );								ipr.drawLine( lre );							}						}					}					if ( bRenderAxisLabels ) // OPTIMIZED: ONLY PROCESS IF					// AXES					// LABELS ARE VISIBLE OR REQUESTED					// FOR					{						nde.setValue( dAxisValue );						try						{							sText = ValueFormatter.format( nde,									ax.getFormatSpecifier( ),									ax.getRunTimeContext( ).getLocale( ),									df );						}						catch ( ChartException dfex )						{							logger.log( dfex );							sText = IConstants.NULL_STRING;						}						ScriptHandler.callFunction( sh,								ScriptHandler.BEFORE_DRAW_AXIS_LABEL,								axModel,								la );						getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.BEFORE_DRAW_AXIS_LABEL,								la );						double sy = y;						if ( bAxisLabelStaggered && i % 2 == 1 )						{							if ( iLabelLocation == IConstants.ABOVE )							{								sy -= dStaggeredLabelOffset;							}							else							{								sy += dStaggeredLabelOffset;							}						}						if ( bRendering3D )						{							if ( axisType == IConstants.BASE_AXIS )							{								lo3d.set( x3d, sy, dZEnd );							}							else							{								lo3d.set( dXEnd, sy, z3d );							}							la.getCaption( ).setValue( sText );							t3dre.setLocation3D( lo3d );							t3dre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							dc.addLabel( t3dre );						}						else						{							lo.set( x, sy );							la.getCaption( ).setValue( sText );							tre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							ipr.drawText( tre );						}						ScriptHandler.callFunction( sh,								ScriptHandler.AFTER_DRAW_AXIS_LABEL,								axModel,								la );						getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.AFTER_DRAW_AXIS_LABEL,								la );					}					dAxisValue += dAxisStep;				}			}			else if ( ( sc.getType( ) & IConstants.LOGARITHMIC ) == IConstants.LOGARITHMIC )			{				double dAxisValue = Methods.asDouble( sc.getMinimum( ) )						.doubleValue( );				final double dAxisStep = Methods.asDouble( sc.getStep( ) )						.doubleValue( );				dAxisValue = Methods.asDouble( sc.getMinimum( ) ).doubleValue( ); // RESET				double y = ( iLabelLocation == IConstants.ABOVE ) ? dYTick1 - 1						: dYTick2 + 1;				for ( int i = 0; i < da.length; i++ )				{					x = (int) da[i];					if ( bRendering3D )					{						x3d = (int) da3D[i];						z3d = (int) da3D[i];					}					if ( ( iWhatToDraw & IConstants.AXIS ) == IConstants.AXIS )					{						double dYMinorTick1 = ( ( iMinorTickStyle & IConstants.TICK_ABOVE ) == IConstants.TICK_ABOVE ) ? ( dY - IConstants.TICK_SIZE )								: dY, dYMinorTick2 = ( ( iMinorTickStyle & IConstants.TICK_BELOW ) == IConstants.TICK_BELOW ) ? dY								+ IConstants.TICK_SIZE								: dY;						if ( dYMinorTick1 != -dYMinorTick2 )						{							// RENDER THE MINOR TICKS FIRST (For ALL but the							// last Major tick)							if ( i != da.length - 1 )							{								if ( bRenderBase3DAxis )								{									Line3DRenderEvent l3dreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										l3dreMinor = (Line3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												Line3DRenderEvent.class );										l3dreMinor.setLineAttributes( liaMinorTick );										l3dreMinor.setStart3D( Location3DImpl.create( x3d												+ daMinor[k],												dYMinorTick1,												dZ ) );										l3dreMinor.setEnd3D( Location3DImpl.create( x3d												+ daMinor[k],												dYMinorTick2,												dZ ) );										dc.addLine( l3dreMinor );									}								}								else if ( bRenderAncillary3DAxis )								{									Line3DRenderEvent l3dreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										l3dreMinor = (Line3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												Line3DRenderEvent.class );										l3dreMinor.setLineAttributes( liaMinorTick );										l3dreMinor.setStart3D( Location3DImpl.create( dX,												dYMinorTick1,												z3d + daMinor[k] ) );										l3dreMinor.setEnd3D( Location3DImpl.create( dX,												dYMinorTick2,												z3d + daMinor[k] ) );										dc.addLine( l3dreMinor );									}								}								else								{									LineRenderEvent lreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										lreMinor = (LineRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												LineRenderEvent.class );										lreMinor.setLineAttributes( liaMinorTick );										lreMinor.setStart( LocationImpl.create( x												+ daMinor[k],												dYMinorTick1 ) );										lreMinor.setEnd( LocationImpl.create( x												+ daMinor[k], dYMinorTick2 ) );										ipr.drawLine( lreMinor );									}								}							}						}						if ( dYTick1 != dYTick2 )						{							if ( bRenderBase3DAxis )							{								l3dre.setLineAttributes( liaMajorTick );								l3dre.setStart3D( x3d, dYTick1, dZ );								l3dre.setEnd3D( x3d, dYTick2, dZ );								dc.addLine( l3dre );							}							else if ( bRenderAncillary3DAxis )							{								l3dre.setLineAttributes( liaMajorTick );								l3dre.setStart3D( dX, dYTick1, z3d );								l3dre.setEnd3D( dX, dYTick2, z3d );								dc.addLine( l3dre );							}							else							{								lre.setLineAttributes( lia );								lre.getStart( ).set( x, dYTick1 );								lre.getEnd( ).set( x, dYTick2 );								ipr.drawLine( lre );							}							if ( iv != null									&& iDimension == IConstants.TWO_5_D									&& iv.getType( ) == IntersectionValue.VALUE )							{								lre.getStart( ).set( x, dY );								lre.getEnd( ).set( x + dSeriesThickness,										dY - dSeriesThickness );								ipr.drawLine( lre );							}						}					}					if ( bRenderAxisLabels ) // OPTIMIZED: ONLY PROCESS IF					// AXES					// LABELS ARE VISIBLE OR REQUESTED					// FOR					{						if ( fs == null )						{							df = new DecimalFormat( sc.getNumericPattern( dAxisValue ) );						}						nde.setValue( dAxisValue );						try						{							sText = ValueFormatter.format( nde,									ax.getFormatSpecifier( ),									ax.getRunTimeContext( ).getLocale( ),									df );						}						catch ( ChartException dfex )						{							logger.log( dfex );							sText = IConstants.NULL_STRING;						}						ScriptHandler.callFunction( sh,								ScriptHandler.BEFORE_DRAW_AXIS_LABEL,								axModel,								la );						getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.BEFORE_DRAW_AXIS_LABEL,								la );						double sy = y;						if ( bAxisLabelStaggered && i % 2 == 1 )						{							if ( iLabelLocation == IConstants.ABOVE )							{								sy -= dStaggeredLabelOffset;							}							else							{								sy += dStaggeredLabelOffset;							}						}						if ( bRendering3D )						{							if ( axisType == IConstants.BASE_AXIS )							{								lo3d.set( x3d, sy, dZEnd );							}							else							{								lo3d.set( dXEnd, sy, z3d );							}							la.getCaption( ).setValue( sText );							t3dre.setLocation3D( lo3d );							t3dre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							dc.addLabel( t3dre );						}						else						{							lo.set( x, sy );							la.getCaption( ).setValue( sText );							tre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							ipr.drawText( tre );						}						ScriptHandler.callFunction( sh,								ScriptHandler.AFTER_DRAW_AXIS_LABEL,								axModel,								la );						getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.AFTER_DRAW_AXIS_LABEL,								la );					}					dAxisValue *= dAxisStep;				}			}			else if ( ( sc.getType( ) & IConstants.DATE_TIME ) == IConstants.DATE_TIME )			{				CDateTime cdt, cdtAxisValue = Methods.asDateTime( sc.getMinimum( ) );				final int iUnit = Methods.asInteger( sc.getUnit( ) );				final int iStep = Methods.asInteger( sc.getStep( ) );				SimpleDateFormat sdf = null;				if ( fs == null )				{					sdf = new SimpleDateFormat( CDateTime.getPreferredFormat( iUnit ) );				}				cdt = cdtAxisValue;				double y = ( iLabelLocation == IConstants.ABOVE ) ? dYTick1 - 1						: dYTick2 + 1;				for ( int i = 0; i < da.length; i++ )				{					x = (int) da[i];					if ( bRendering3D )					{						x3d = (int) da3D[i];						z3d = (int) da3D[i];					}					if ( ( iWhatToDraw & IConstants.AXIS ) == IConstants.AXIS )					{						double dYMinorTick1 = ( ( iMinorTickStyle & IConstants.TICK_ABOVE ) == IConstants.TICK_ABOVE ) ? ( dY - IConstants.TICK_SIZE )								: dY, dYMinorTick2 = ( ( iMinorTickStyle & IConstants.TICK_BELOW ) == IConstants.TICK_BELOW ) ? dY								+ IConstants.TICK_SIZE								: dY;						if ( dYMinorTick1 != -dYMinorTick2 )						{							// RENDER THE MINOR TICKS FIRST (For ALL but the							// last Major tick)							if ( i != da.length - 1 )							{								if ( bRenderBase3DAxis )								{									Line3DRenderEvent l3dreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										l3dreMinor = (Line3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												Line3DRenderEvent.class );										l3dreMinor.setLineAttributes( liaMinorTick );										l3dreMinor.setStart3D( Location3DImpl.create( x3d												+ daMinor[k],												dYMinorTick1,												dZ ) );										l3dreMinor.setEnd3D( Location3DImpl.create( x3d												+ daMinor[k],												dYMinorTick2,												dZ ) );										dc.addLine( l3dreMinor );									}								}								else if ( bRenderAncillary3DAxis )								{									Line3DRenderEvent l3dreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										l3dreMinor = (Line3DRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												Line3DRenderEvent.class );										l3dreMinor.setLineAttributes( liaMinorTick );										l3dreMinor.setStart3D( Location3DImpl.create( dX,												dYMinorTick1,												z3d + daMinor[k] ) );										l3dreMinor.setEnd3D( Location3DImpl.create( dX,												dYMinorTick2,												z3d + daMinor[k] ) );										dc.addLine( l3dreMinor );									}								}								else								{									LineRenderEvent lreMinor = null;									for ( int k = 0; k < daMinor.length - 1; k++ )									{										lreMinor = (LineRenderEvent) ( (EventObjectCache) ipr ).getEventObject( StructureSource.createAxis( axModel ),												LineRenderEvent.class );										lreMinor.setLineAttributes( liaMinorTick );										lreMinor.setStart( LocationImpl.create( x												+ daMinor[k],												dYMinorTick1 ) );										lreMinor.setEnd( LocationImpl.create( x												+ daMinor[k], dYMinorTick2 ) );										ipr.drawLine( lreMinor );									}								}							}						}						if ( dYTick1 != dYTick2 )						{							if ( bRenderBase3DAxis )							{								l3dre.setLineAttributes( liaMajorTick );								l3dre.setStart3D( x3d, dYTick1, dZ );								l3dre.setEnd3D( x3d, dYTick2, dZ );								dc.addLine( l3dre );							}							else if ( bRenderAncillary3DAxis )							{								l3dre.setLineAttributes( liaMajorTick );								l3dre.setStart3D( dX, dYTick1, z3d );								l3dre.setEnd3D( dX, dYTick2, z3d );								dc.addLine( l3dre );							}							else							{								lre.setLineAttributes( liaMajorTick );								lre.getStart( ).set( x, dYTick1 );								lre.getEnd( ).set( x, dYTick2 );								ipr.drawLine( lre );							}							if ( iv != null									&& iDimension == IConstants.TWO_5_D									&& iv.getType( ) == IntersectionValue.VALUE )							{								lre.getStart( ).set( x, dY );								lre.getEnd( ).set( x + dSeriesThickness,										dY - dSeriesThickness );								ipr.drawLine( lre );							}						}					}					if ( bRenderAxisLabels ) // OPTIMIZED: ONLY PROCESS IF					// AXES					// LABELS ARE VISIBLE OR REQUESTED					// FOR					{						try						{							sText = ValueFormatter.format( cdt,									ax.getFormatSpecifier( ),									ax.getRunTimeContext( ).getLocale( ),									sdf );						}						catch ( ChartException dfex )						{							logger.log( dfex );							sText = IConstants.NULL_STRING;						}						ScriptHandler.callFunction( sh,								ScriptHandler.BEFORE_DRAW_AXIS_LABEL,								axModel,								la );						getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.BEFORE_DRAW_AXIS_LABEL,								la );						double sy = y;						if ( bAxisLabelStaggered && i % 2 == 1 )						{							if ( iLabelLocation == IConstants.ABOVE )							{								sy -= dStaggeredLabelOffset;							}							else							{								sy += dStaggeredLabelOffset;							}						}						if ( bRendering3D )						{							if ( axisType == IConstants.BASE_AXIS )							{								lo3d.set( x3d, sy, dZEnd );							}							else							{								lo3d.set( dXEnd, sy, z3d );							}							la.getCaption( ).setValue( sText );							t3dre.setLocation3D( lo3d );							t3dre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							dc.addLabel( t3dre );						}						else						{							lo.set( x, sy );							la.getCaption( ).setValue( sText );							tre.setAction( TextRenderEvent.RENDER_TEXT_AT_LOCATION );							ipr.drawText( tre );						}						ScriptHandler.callFunction( sh,								ScriptHandler.AFTER_DRAW_AXIS_LABEL,								axModel,								la );						getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.AFTER_DRAW_AXIS_LABEL,								la );					}					cdt = cdtAxisValue.forward( iUnit, iStep * ( i + 1 ) ); // ALWAYS					// W.R.T					// START					// VALUE				}			}			// RENDER THE AXIS TITLE			la = ax.getTitle( ); // TEMPORARILY USE FOR AXIS TITLE			if ( la.isVisible( ) && bRenderAxisTitle )			{				ScriptHandler.callFunction( sh,						ScriptHandler.BEFORE_DRAW_AXIS_TITLE,						axModel,						la );				getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.BEFORE_DRAW_AXIS_TITLE,						la );				final String sRestoreValue = la.getCaption( ).getValue( );				la.getCaption( )						.setValue( rtc.externalizedMessage( sRestoreValue ) ); // EXTERNALIZE				BoundingBox bb = null;				try				{					bb = Methods.computeBox( xs,							ax.getTitlePosition( ),							la,							0,							0 );				}				catch ( IllegalArgumentException uiex )				{					throw new ChartException( ChartEnginePlugin.ID,							ChartException.RENDERING,							uiex );				}				if ( bRendering3D )				{					Bounds cbo = getPlotBounds( );					if ( axisType == IConstants.BASE_AXIS )					{						tre.setBlockBounds( BoundsImpl.create( cbo.getLeft( )								+ ( cbo.getWidth( ) / 3d - bb.getWidth( ) ),								cbo.getTop( )										+ cbo.getHeight( )										- Math.min( bb.getHeight( ),												bb.getWidth( ) )										- 30,								bb.getWidth( ),								bb.getHeight( ) ) );					}					else					{						tre.setBlockBounds( BoundsImpl.create( cbo.getLeft( )								+ cbo.getWidth( )								* 2								/ 3d								+ ( cbo.getWidth( ) / 3d - bb.getWidth( ) )								/ 2d, cbo.getTop( )								+ cbo.getHeight( )								- Math.min( bb.getHeight( ), bb.getWidth( ) )								- 30								* 2, bb.getWidth( ), bb.getHeight( ) ) );					}					tre.setLabel( la );					tre.setBlockAlignment( null );					tre.setAction( TextRenderEvent.RENDER_TEXT_IN_BLOCK );					ipr.drawText( tre );				}				else				{					final Bounds bo = BoundsImpl.create( daEndPoints[0],							ax.getTitleCoordinate( ),							daEndPoints[1] - daEndPoints[0],							bb.getHeight( ) );					tre.setBlockBounds( bo );					tre.setLabel( la );					tre.setBlockAlignment( null );					tre.setAction( TextRenderEvent.RENDER_TEXT_IN_BLOCK );					ipr.drawText( tre );				}				la.getCaption( ).setValue( sRestoreValue ); // RESTORE				ScriptHandler.callFunction( sh,						ScriptHandler.AFTER_DRAW_AXIS_TITLE,						axModel,						la );				getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.AFTER_DRAW_AXIS_TITLE,						la );			}			la = ax.getLabel( ); // RESTORE BACK TO AXIS LABEL			if ( iv != null					&& iv.getType( ) == IntersectionValue.MAX					&& iDimension == IConstants.TWO_5_D )			{				trae.setTranslation( -dSeriesThickness, dSeriesThickness );				ipr.applyTransformation( trae );			}		}	}