if ( isInteractivityEnabled( ) ) { Trigger tg; EList elTriggers = ml.getTriggers( );  if ( !elTriggers.isEmpty( ) ) { final InteractionEvent iev = (InteractionEvent) ( (EventObjectCache) idr ).getEventObject( StructureSource.createMarkerLine( ml ), InteractionEvent.class ); for ( int t = 0; t < elTriggers.size( ); t++ ) { tg = (Trigger) EcoreUtil.copy( (Trigger) elTriggers.get( t ) ); processTrigger( tg, StructureSource.createMarkerLine( ml ) ); iev.addTrigger( tg ); }  Location[] loaHotspot = new Location[4];  if ( iOrientation == Orientation.HORIZONTAL ) { loaHotspot[0] = LocationImpl.create( loStart.getX( ) - IConstants.LINE_EXPAND_SIZE, loStart.getY( ) ); loaHotspot[1] = LocationImpl.create( loStart.getX( ) + IConstants.LINE_EXPAND_SIZE, loStart.getY( ) ); loaHotspot[2] = LocationImpl.create( loEnd.getX( ) + IConstants.LINE_EXPAND_SIZE, loEnd.getY( ) ); loaHotspot[3] = LocationImpl.create( loEnd.getX( ) - IConstants.LINE_EXPAND_SIZE, loEnd.getY( ) ); } else { loaHotspot[0] = LocationImpl.create( loStart.getX( ), loStart.getY( ) - IConstants.LINE_EXPAND_SIZE ); loaHotspot[1] = LocationImpl.create( loEnd.getX( ), loEnd.getY( ) - IConstants.LINE_EXPAND_SIZE ); loaHotspot[2] = LocationImpl.create( loEnd.getX( ), loEnd.getY( ) + IConstants.LINE_EXPAND_SIZE ); loaHotspot[3] = LocationImpl.create( loStart.getX( ), loStart.getY( ) + IConstants.LINE_EXPAND_SIZE ); }  final PolygonRenderEvent pre = (PolygonRenderEvent) ( (EventObjectCache) idr ).getEventObject( StructureSource.createMarkerLine( ml ), PolygonRenderEvent.class ); pre.setPoints( loaHotspot ); iev.setHotSpot( pre ); idr.enableInteraction( iev ); } }
	private final void renderMarkerLines( OneAxis[] oaxa,			Bounds boPlotClientArea ) throws ChartException	{		Axis ax;		EList el;		int iLineCount, iAxisCount = oaxa.length;		MarkerLine ml;		LineRenderEvent lre;		DataElement deValue;		AutoScale asc;		double dCoordinate = 0;		int iOrientation;		final IDeviceRenderer idr = getDevice( );		final ScriptHandler sh = getRunTimeContext( ).getScriptHandler( );		final Location loStart = LocationImpl.create( 0, 0 );		final Location loEnd = LocationImpl.create( 0, 0 );		Anchor anc;		Orientation or;		TextRenderEvent tre = null;		Label la = null;		double dOriginalAngle = 0;		final boolean bTransposed = ( (ChartWithAxes) getModel( ) ).isTransposed( );		final PlotWithAxes pwa = (PlotWithAxes) getComputations( );		final Bounds boText = BoundsImpl.create( 0, 0, 0, 0 );		for ( int i = 0; i < iAxisCount; i++ )		{			ax = oaxa[i].getModelAxis( );			iOrientation = ax.getOrientation( ).getValue( );			if ( bTransposed ) // TOGGLE ORIENTATION			{				iOrientation = ( iOrientation == Orientation.HORIZONTAL ) ? Orientation.VERTICAL						: Orientation.HORIZONTAL;			}			asc = oaxa[i].getScale( );			el = ax.getMarkerLines( );			iLineCount = el.size( );			for ( int j = 0; j < iLineCount; j++ )			{				ml = (MarkerLine) el.get( j );				ScriptHandler.callFunction( sh,						ScriptHandler.BEFORE_DRAW_MARKER_LINE,						ax,						ml,						getRunTimeContext( ).getScriptContext( ) );				getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.BEFORE_DRAW_MARKER_LINE,						ml );				deValue = ml.getValue( );				if ( deValue == null )				{					throw new ChartException( ChartEnginePlugin.ID,							ChartException.RENDERING,							"exception.marker.line.null.value", //$NON-NLS-1$							new Object[]{								ml							},							ResourceBundle.getBundle( Messages.ENGINE,									getRunTimeContext( ).getLocale( ) ) );				}				// UPDATE THE LABEL CONTENT ASSOCIATED WITH THE MARKER LINE				la = ml.getLabel( );				try				{					la.getCaption( ).setValue( ValueFormatter.format( deValue,							ml.getFormatSpecifier( ),							oaxa[i].getRunTimeContext( ).getLocale( ),							null ) );				}				catch ( ChartException dfex )				{					throw new ChartException( ChartEnginePlugin.ID,							ChartException.RENDERING,							dfex );				}				if ( isDimension3D( ) )				{					// TODO render 3D marker line					return;				}				// COMPUTE THE LOCATION				try				{					dCoordinate = PlotWith2DAxes.getLocation( asc, deValue );				}				catch ( Exception ex )				{					logger.log( ILogger.WARNING,							Messages.getString( "exception.cannot.locate.value.marker.line", //$NON-NLS-1$									new Object[]{											deValue, ml									},									getRunTimeContext( ).getLocale( ) ) );					continue; // TRY NEXT MARKER RANGE				}				lre = (LineRenderEvent) ( (EventObjectCache) idr ).getEventObject( StructureSource.createMarkerLine( ml ),						LineRenderEvent.class );				if ( iOrientation == Orientation.HORIZONTAL )				{					// RESTRICT RIGHT EDGE					if ( dCoordinate > boPlotClientArea.getLeft( )							+ boPlotClientArea.getWidth( ) )					{						dCoordinate = boPlotClientArea.getLeft( )								+ boPlotClientArea.getWidth( );					}					// RESTRICT LEFT EDGE					if ( dCoordinate < boPlotClientArea.getLeft( ) )					{						dCoordinate = boPlotClientArea.getLeft( );					}					// SETUP THE TWO POINTS					loStart.set( dCoordinate, boPlotClientArea.getTop( ) );					loEnd.set( dCoordinate, boPlotClientArea.getTop( )							+ boPlotClientArea.getHeight( ) );				}				else				{					// RESTRICT TOP EDGE					if ( dCoordinate < boPlotClientArea.getTop( ) )					{						dCoordinate = boPlotClientArea.getTop( );					}					// RESTRICT BOTTOM EDGE					if ( dCoordinate > boPlotClientArea.getTop( )							+ boPlotClientArea.getHeight( ) )					{						dCoordinate = boPlotClientArea.getTop( )								+ boPlotClientArea.getHeight( );					}					// SETUP THE TWO POINTS					loStart.set( boPlotClientArea.getLeft( ), dCoordinate );					loEnd.set( boPlotClientArea.getLeft( )							+ boPlotClientArea.getWidth( ), dCoordinate );				}				// ADJUST FOR 2D PLOTS AS NEEDED				if ( pwa.getDimension( ) == IConstants.TWO_5_D )				{					if ( iOrientation == Orientation.HORIZONTAL )					{						loStart.translate( 0, pwa.getSeriesThickness( ) );						loEnd.translate( 0, pwa.getSeriesThickness( ) );					}					else					{						loStart.translate( -pwa.getSeriesThickness( ), 0 );						loEnd.translate( -pwa.getSeriesThickness( ), 0 );					}				}				// DRAW THE MARKER LINE				lre.setStart( loStart );				lre.setEnd( loEnd );				lre.setLineAttributes( ml.getLineAttributes( ) );				idr.drawLine( lre );				// DRAW THE MARKER LINE LABEL AT THE APPROPRIATE LOCATION				if ( la.isVisible( ) )				{					// DETERMINE THE LABEL ANCHOR (TRANSPOSE IF NEEDED)					anc = ml.getLabelAnchor( );					if ( bTransposed )					{						or = ax.getOrientation( ) == Orientation.HORIZONTAL_LITERAL ? Orientation.VERTICAL_LITERAL								: Orientation.HORIZONTAL_LITERAL;						la = ml.getLabel( );						dOriginalAngle = la.getCaption( )								.getFont( )								.getRotation( );						try						{							la.getCaption( )									.getFont( )									.setRotation( pwa.getTransposedAngle( dOriginalAngle ) );							anc = pwa.transposedAnchor( or, anc );						}						catch ( IllegalArgumentException uiex )						{							throw new ChartException( ChartEnginePlugin.ID,									ChartException.RENDERING,									uiex );						}					}					BoundingBox bb = null;					try					{						bb = Methods.computeBox( idr.getDisplayServer( ),								IConstants.LEFT,								la,								0,								0 );					}					catch ( IllegalArgumentException uiex )					{						throw new ChartException( ChartEnginePlugin.ID,								ChartException.RENDERING,								uiex );					}					boText.set( 0, 0, bb.getWidth( ), bb.getHeight( ) );					if ( iOrientation == Orientation.VERTICAL )					{						if ( anc != null )						{							switch ( anc.getValue( ) )							{								case Anchor.NORTH :								case Anchor.NORTH_EAST :								case Anchor.NORTH_WEST :									boText.setTop( loStart.getY( )											- boText.getHeight( ) );									break;								case Anchor.SOUTH :								case Anchor.SOUTH_EAST :								case Anchor.SOUTH_WEST :									boText.setTop( loStart.getY( ) );									break;								default :									boText.setTop( loStart.getY( )											+ ( loEnd.getY( ) - loStart.getY( ) - boText.getHeight( ) )											/ 2 );									break;							}							switch ( anc.getValue( ) )							{								case Anchor.NORTH_EAST :								case Anchor.SOUTH_EAST :								case Anchor.EAST :									boText.setLeft( loEnd.getX( )											- boText.getWidth( ) );									break;								case Anchor.NORTH_WEST :								case Anchor.SOUTH_WEST :								case Anchor.WEST :									boText.setLeft( loStart.getX( ) );									break;								default :									boText.setLeft( loStart.getX( )											+ ( loEnd.getX( ) - loStart.getX( ) - boText.getWidth( ) )											/ 2 );									break;							}						}						else						// CENTER ANCHORED						{							boText.setLeft( loStart.getX( )									+ ( loEnd.getX( ) - loStart.getX( ) - boText.getWidth( ) )									/ 2 );							boText.setTop( loStart.getY( )									+ ( loEnd.getY( ) - loStart.getY( ) - boText.getHeight( ) )									/ 2 );						}					}					else					{						if ( anc != null )						{							switch ( anc.getValue( ) )							{								case Anchor.NORTH :								case Anchor.NORTH_EAST :								case Anchor.NORTH_WEST :									boText.setTop( loStart.getY( ) );									break;								case Anchor.SOUTH :								case Anchor.SOUTH_EAST :								case Anchor.SOUTH_WEST :									boText.setTop( loEnd.getY( )											- boText.getHeight( ) );									break;								default :									boText.setTop( loStart.getY( )											+ ( loEnd.getY( ) - loStart.getY( ) - boText.getHeight( ) )											/ 2 );									break;							}							switch ( anc.getValue( ) )							{								case Anchor.NORTH_EAST :								case Anchor.SOUTH_EAST :								case Anchor.EAST :									boText.setLeft( loStart.getX( ) );									break;								case Anchor.NORTH_WEST :								case Anchor.SOUTH_WEST :								case Anchor.WEST :									boText.setLeft( loEnd.getX( )											- boText.getWidth( ) );									break;								default :									boText.setLeft( loStart.getX( )											+ ( loEnd.getX( ) - loStart.getX( ) - boText.getWidth( ) )											/ 2 );									break;							}						}						else						// CENTER ANCHORED						{							boText.setLeft( loStart.getX( )									+ ( loEnd.getX( ) - loStart.getX( ) - boText.getWidth( ) )									/ 2 );							boText.setTop( loStart.getY( )									+ ( loEnd.getY( ) - loStart.getY( ) - boText.getHeight( ) )									/ 2 );						}					}					// NOW THAT WE COMPUTED THE BOUNDS, RENDER THE ACTUAL TEXT					tre = (TextRenderEvent) ( (EventObjectCache) idr ).getEventObject( StructureSource.createMarkerLine( ml ),							TextRenderEvent.class );					tre.setBlockBounds( boText );					tre.setBlockAlignment( null );					tre.setLabel( la );					tre.setAction( TextRenderEvent.RENDER_TEXT_IN_BLOCK );					idr.drawText( tre );					if ( bTransposed ) // RESTORE FONT ANGLE IF TRANSPOSED					{						la.getCaption( )								.getFont( )								.setRotation( dOriginalAngle );					}				}				ScriptHandler.callFunction( sh,						ScriptHandler.AFTER_DRAW_MARKER_LINE,						ax,						ml,						getRunTimeContext( ).getScriptContext( ) );				getRunTimeContext( ).notifyStructureChange( IStructureDefinitionListener.AFTER_DRAW_MARKER_LINE,						ml );			}		}	}