if (elm != null) { for (int x = 0; x < triggers.length; x++) { Trigger tg = triggers[x];  final StructureSource src = (StructureSource) ie.getSource( );  switch (tg.getAction().getType().getValue()) { case ActionType.SHOW_TOOLTIP: String tooltipText = ((TooltipValue) tg.getAction().getValue()).getText();  if ((tooltipText != null) && (tooltipText.trim().length() > 0)){ Element title = svggc.dom.createElement("title"); title.appendChild(svggc.dom .createTextNode(tooltipText)); elm.appendChild(title); elm.setAttribute("onmouseout", "TM.remove()"); elm.setAttribute("onmousemove", "TM.show(evt)"); } break; case ActionType.URL_REDIRECT: URLValue urlValue = ((URLValue) tg.getAction().getValue());  if ( urlValue.getBaseUrl().startsWith("#")){ Element aLink = ((SVGGraphics2D)_g2d).createElement("g"); aLink.setAttribute("onclick", "top.document.location.hash='"+urlValue.getBaseUrl()+"';"); aLink.setAttribute("style", "cursor:pointer"); aLink.appendChild(elm); elm = aLink; } else{ Element aLink = ((SVGGraphics2D)_g2d).createElement("a");  aLink.setAttribute("xlink:href", urlValue.getBaseUrl()); if (urlValue.getTarget() != null) aLink.setAttribute("target", urlValue.getTarget()); aLink.appendChild(elm); elm = aLink; } break;  case ActionType.TOGGLE_VISIBILITY :  if ( src.getType( ) == StructureType.SERIES ) { final Series seRT = (Series) src.getSource( ); logger.log( ILogger.INFORMATION, Messages.getString( "info.toggle.visibility", getULocale() ) + seRT ); Series seDT = null; try {     seDT = findDesignTimeSeries( seRT ); cacheSeriesHotspots.put(elm, seDT); } catch ( ChartException oosx ) { logger.log( oosx ); return; } } break;  case ActionType.TOGGLE_DATA_POINT_VISIBILITY : if ( src.getType( ) == StructureType.SERIES ) {  final Series seRT = (Series) src.getSource( ); logger.log( ILogger.INFORMATION, Messages.getString( "info.toggle.datapoint.visibility", getULocale() ) + seRT ); Series seDT = null; try { seDT = findDesignTimeSeries( seRT ); } catch ( ChartException oosx ) { logger.log( oosx ); return; } if (seDT != null) cacheHotspots.put(elm, seDT);  } break;  case ActionType.HIGHLIGHT :  if ( src.getType( ) == StructureType.SERIES ) { final Series seRT = (Series) src.getSource( ); logger.log( ILogger.INFORMATION, Messages.getString( "info.toggle.visibility", getULocale() ) + seRT ); String scriptEvent = getJsScriptEvent(tg.getCondition().getValue()); if (scriptEvent != null){  Series seDT = null; try {     seDT = findDesignTimeSeries( seRT ); List components = (List)componentPrimitives.get(seDT); if (components != null){ Iterator iter = components.iterator(); StringBuffer sb = new StringBuffer(); sb.append(seDT.hashCode()); if (iter.hasNext()) sb.append(",new Array("); while (iter.hasNext()){ sb.append("'").append(iter.next()).append("'"); if (iter.hasNext()) sb.append(","); } if (components.size() > 0) sb.append(")"); elm.setAttribute(scriptEvent, "highlight(evt, " + sb.toString() + ")");   if (tg.getCondition().getValue() == TriggerCondition.ONMOUSEOVER){ elm.setAttribute("onmouseout", "highlight(evt, null, null)"); } setCursor(elm);   ((SVGGraphics2D)_g2d).addCSSStyle(".class"+seDT.hashCode(), "visibility", "visible"); } } catch ( ChartException oosx ) { logger.log( oosx ); return; } } } break; case ActionType.INVOKE_SCRIPT: final StructureSource sructSource = (StructureSource) ie.getSource( );  if (tg.getCondition().equals(TriggerCondition.ACCESSIBILITY_LITERAL)){ AccessibilityValue accessValue = ((AccessibilityValue) tg.getAction().getValue()); if (accessValue.getText() != null){ Element title = ((SVGGraphics2D)_g2d).createElement("title"); title.appendChild(svggc.dom .createTextNode(accessValue.getText())); elm.appendChild(title); } if (accessValue.getAccessibility() != null){ Element description = ((SVGGraphics2D)_g2d).createElement("desc"); description.appendChild(svggc.dom .createTextNode(accessValue.getAccessibility())); elm.appendChild(description); }  } else{ String scriptEvent = getJsScriptEvent(tg.getCondition().getValue()); if (scriptEvent != null){ String script = ((ScriptValue) tg.getAction().getValue()).getScript(); String callbackFunction = "callback"+Math.abs(script.hashCode())+"(evt,"+sructSource.getSource().hashCode()+");"; elm.setAttribute(scriptEvent, callbackFunction); setCursor(elm); if (!(scripts.contains(script))){  ((SVGGraphics2D)_g2d).addScript("function callback"+Math.abs(script.hashCode())+"(evt,source)" +"{"+script+"}"); scripts.add(script); } } } break;   } }  hotspotLayer.appendChild( elm ); }
ivRenderer.prepareInteractiveEvent( elm, ie, triggers );
	public void enableInteraction( InteractionEvent ie ) throws ChartException	{		if ( _iun == null )		{			logger.log( ILogger.WARNING,					Messages.getString( "exception.missing.component.interaction", getULocale( ) ) ); //$NON-NLS-1$			return;		}				Trigger[] triggers = ie.getTriggers( );		if ( triggers == null )		{			return;		}		///////////////////////////////////////////////		//Create the hotspot and add the hotspot on 		//the SVG hotspot layer		///////////////////////////////////////////////		final PrimitiveRenderEvent pre = ie.getHotSpot( );		Element elm = null;		if ( pre instanceof PolygonRenderEvent )		{			final Location[] loa = ( (PolygonRenderEvent) pre ).getPoints( );			int[][] pa = getCoordinatesAsInts( loa );			elm = svggc.createPolygon( pa[0], pa[1], pa[0].length );		}		else if ( pre instanceof OvalRenderEvent )		{			final Bounds boEllipse = ( (OvalRenderEvent) pre ).getBounds( );			elm = svggc.createOval( boEllipse.getLeft( ),					boEllipse.getTop( ),					boEllipse.getWidth( ),					boEllipse.getHeight( ) );		}		else if ( pre instanceof RectangleRenderEvent )		{			final Bounds boRect = ( (RectangleRenderEvent) pre ).getBounds( );			elm = svggc.createRect(boRect.getLeft(), boRect.getTop(), boRect.getWidth(), boRect.getHeight());		}		else if ( pre instanceof AreaRenderEvent )		{					AreaRenderEvent are = (AreaRenderEvent)pre;									final GeneralPath gp = new GeneralPath( );			PrimitiveRenderEvent subPre;						for ( int i = 0; i < are.getElementCount( ); i++ )			{				subPre = are.getElement( i );				if ( subPre instanceof ArcRenderEvent )				{					final ArcRenderEvent acre = (ArcRenderEvent) subPre;					final Arc2D.Double a2d = new Arc2D.Double( acre.getTopLeft( )							.getX( ),							acre.getTopLeft( ).getY( ),							acre.getWidth( ),							acre.getHeight( ),							acre.getStartAngle( ),							acre.getAngleExtent( ),							toSwingArcType( acre.getStyle( ) ) );					gp.append( a2d, true );				}				else if ( subPre instanceof LineRenderEvent )				{					final LineRenderEvent lre = (LineRenderEvent) subPre;					final Line2D.Double l2d = new Line2D.Double( lre.getStart( )							.getX( ),							lre.getStart( ).getY( ),							lre.getEnd( ).getX( ),							lre.getEnd( ).getY( ) );					gp.append( l2d, true );				}			}			elm = svggc.createGeneralPath(gp);		}					else if ( pre instanceof ArcRenderEvent )		{			final ArcRenderEvent are = (ArcRenderEvent) pre;						if ( are.getInnerRadius( ) >= 0					&& are.getOuterRadius( ) > 0					&& are.getInnerRadius( ) < are.getOuterRadius( ) )			{				Shape outerArc = new Arc2D.Double( are.getTopLeft( ).getX( )						+ ( are.getWidth( ) - 2 * are.getOuterRadius( ) )						/ 2,						are.getTopLeft( ).getY( )								+ ( are.getHeight( ) - 2 * are.getOuterRadius( ) )								/ 2,						2 * are.getOuterRadius( ),						2 * are.getOuterRadius( ),						are.getStartAngle( ),						are.getAngleExtent( ),						Arc2D.PIE );				Shape innerArc = new Arc2D.Double( are.getTopLeft( ).getX( )						+ ( are.getWidth( ) - 2 * are.getInnerRadius( ) )						/ 2,						are.getTopLeft( ).getY( )								+ ( are.getHeight( ) - 2 * are.getInnerRadius( ) )								/ 2,						2 * are.getInnerRadius( ),						2 * are.getInnerRadius( ),						are.getStartAngle( ),						are.getAngleExtent( ),						Arc2D.PIE );				Area fArea = new Area( outerArc );				fArea.exclusiveOr( new Area( innerArc ) );//				Shape prevClip = _g2d.getClip( );//				_g2d.setClip( fArea );				elm = svggc.createGeneralPath( fArea );//				_g2d.setClip( prevClip );			}					else			{				elm = svggc.createGeneralPath( new Arc2D.Double( are.getTopLeft( ).getX( ),						are.getTopLeft( ).getY( ),						are.getWidth( ),						are.getHeight( ),						are.getStartAngle( ),						are.getAngleExtent( ),						toSwingArcType( are.getStyle( ) ) ) );			}					}				//////////////////////////////////////		//Add event handling to the hotspot		//////////////////////////////////////				if (elm != null) {			for (int x = 0; x < triggers.length; x++) {				Trigger tg = triggers[x];								final StructureSource src = (StructureSource) ie.getSource( );								switch (tg.getAction().getType().getValue()) {				case ActionType.SHOW_TOOLTIP:					String tooltipText = ((TooltipValue) tg.getAction().getValue()).getText();					//make sure the tooltip text is not empty					if ((tooltipText != null) && (tooltipText.trim().length() > 0)){						Element title = svggc.dom.createElement("title"); //$NON-NLS-1$						title.appendChild(svggc.dom								.createTextNode(tooltipText));						elm.appendChild(title);						elm.setAttribute("onmouseout", "TM.remove()"); //$NON-NLS-1$ //$NON-NLS-2$						elm.setAttribute("onmousemove", "TM.show(evt)"); //$NON-NLS-1$ //$NON-NLS-2$					}					break;				case ActionType.URL_REDIRECT:					URLValue urlValue = ((URLValue) tg.getAction().getValue());					//See if this is an internal anchor link					if ( urlValue.getBaseUrl().startsWith("#")){ //$NON-NLS-1$						Element aLink = ((SVGGraphics2D)_g2d).createElement("g"); //$NON-NLS-1$						aLink.setAttribute("onclick", "top.document.location.hash='"+urlValue.getBaseUrl()+"';"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$						aLink.setAttribute("style", "cursor:pointer"); //$NON-NLS-1$ //$NON-NLS-2$						aLink.appendChild(elm);						elm = aLink;					}					else{						Element aLink = ((SVGGraphics2D)_g2d).createElement("a"); //$NON-NLS-1$													aLink.setAttribute("xlink:href", urlValue.getBaseUrl()); //$NON-NLS-1$						if (urlValue.getTarget() != null)							aLink.setAttribute("target", urlValue.getTarget()); //$NON-NLS-1$ 						aLink.appendChild(elm);						elm = aLink;					}										break;				case ActionType.TOGGLE_VISIBILITY :										if ( src.getType( ) == StructureType.SERIES )					{						final Series seRT = (Series) src.getSource( );											logger.log( ILogger.INFORMATION,								Messages.getString( "info.toggle.visibility", //$NON-NLS-1$										getULocale() )										+ seRT );						Series seDT = null;						try						{							// THE							// CORRESPONDING							// DESIGN-TIME							// SERIES														seDT = findDesignTimeSeries( seRT ); // LOCATE							cacheSeriesHotspots.put(elm, seDT);						}						catch ( ChartException oosx )						{							logger.log( oosx );							return;						}					}					break;									case ActionType.TOGGLE_DATA_POINT_VISIBILITY :					if ( src.getType( ) == StructureType.SERIES )					{												final Series seRT = (Series) src.getSource( );						logger.log( ILogger.INFORMATION,								Messages.getString( "info.toggle.datapoint.visibility", //$NON-NLS-1$										getULocale() )										+ seRT );						Series seDT = null;						try						{							seDT = findDesignTimeSeries( seRT );						}						catch ( ChartException oosx )						{							logger.log( oosx );							return;						}						if (seDT != null)							cacheHotspots.put(elm, seDT);											}					break;									case ActionType.HIGHLIGHT :										if ( src.getType( ) == StructureType.SERIES )					{						final Series seRT = (Series) src.getSource( );											logger.log( ILogger.INFORMATION,								Messages.getString( "info.toggle.visibility", //$NON-NLS-1$										getULocale() )										+ seRT );						String scriptEvent = getJsScriptEvent(tg.getCondition().getValue());						if (scriptEvent != null){														Series seDT = null;							try							{								// THE								// CORRESPONDING								// DESIGN-TIME								// SERIES															seDT = findDesignTimeSeries( seRT ); // LOCATE								List components = (List)componentPrimitives.get(seDT);								if (components != null){									Iterator iter = components.iterator();									StringBuffer sb = new StringBuffer();									sb.append(seDT.hashCode());									if (iter.hasNext())										sb.append(",new Array(");							 //$NON-NLS-1$									while (iter.hasNext()){										sb.append("'").append(iter.next()).append("'"); //$NON-NLS-1$ //$NON-NLS-2$										if (iter.hasNext())											sb.append(","); //$NON-NLS-1$									}									if (components.size() > 0)										sb.append(")"); //$NON-NLS-1$									elm.setAttribute(scriptEvent, //$NON-NLS-1$											"highlight(evt, " //$NON-NLS-1$													+ sb.toString() + ")"); //$NON-NLS-1$										//see if this is on mouse over event.  Then we should have a on mouse out event to correctly reset									//the highlight color									if (tg.getCondition().getValue() == TriggerCondition.ONMOUSEOVER){										elm.setAttribute("onmouseout", //$NON-NLS-1$												"highlight(evt, null, null)"); //$NON-NLS-1$										}									setCursor(elm);											//should define style class and set the visibility to visible									((SVGGraphics2D)_g2d).addCSSStyle(".class"+seDT.hashCode(), "visibility", "visible"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$								}							}							catch ( ChartException oosx )							{								logger.log( oosx );								return;							}						}					}					break;									case ActionType.INVOKE_SCRIPT:					final StructureSource sructSource = (StructureSource) ie.getSource( );					//lets see if we need to add accessibility					if (tg.getCondition().equals(TriggerCondition.ACCESSIBILITY_LITERAL)){						AccessibilityValue accessValue = ((AccessibilityValue) tg.getAction().getValue());						if (accessValue.getText() != null){							Element title = ((SVGGraphics2D)_g2d).createElement("title"); //$NON-NLS-1$							title.appendChild(svggc.dom									.createTextNode(accessValue.getText()));							elm.appendChild(title);						}						if (accessValue.getAccessibility() != null){							Element description = ((SVGGraphics2D)_g2d).createElement("desc"); //$NON-NLS-1$							description.appendChild(svggc.dom									.createTextNode(accessValue.getAccessibility()));							elm.appendChild(description);						}											}					else{					String scriptEvent = getJsScriptEvent(tg.getCondition().getValue());					if (scriptEvent != null){						String script = ((ScriptValue) tg.getAction().getValue()).getScript();						String callbackFunction = "callback"+Math.abs(script.hashCode())+"(evt,"+sructSource.getSource().hashCode()+");"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$						elm.setAttribute(scriptEvent, callbackFunction); 						setCursor(elm);						if (!(scripts.contains(script))){														((SVGGraphics2D)_g2d).addScript("function callback"+Math.abs(script.hashCode())+"(evt,source)" +"{"+script+"}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$							scripts.add(script);						}					}					}					break;														}			}			hotspotLayer.appendChild( elm );		}			}