sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi.power/src/com/nokia/carbide/cpp/pi/power/PowerTraceGraph.java
changeset 5 844b047e260d
parent 2 b9ab3b238396
child 12 ae255c9aa552
equal deleted inserted replaced
4:615035072f7e 5:844b047e260d
    29 import org.eclipse.draw2d.FigureCanvas;
    29 import org.eclipse.draw2d.FigureCanvas;
    30 import org.eclipse.draw2d.Graphics;
    30 import org.eclipse.draw2d.Graphics;
    31 import org.eclipse.draw2d.MouseEvent;
    31 import org.eclipse.draw2d.MouseEvent;
    32 import org.eclipse.draw2d.MouseMotionListener;
    32 import org.eclipse.draw2d.MouseMotionListener;
    33 import org.eclipse.draw2d.Panel;
    33 import org.eclipse.draw2d.Panel;
       
    34 import org.eclipse.jface.action.Action;
    34 import org.eclipse.swt.SWT;
    35 import org.eclipse.swt.SWT;
    35 import org.eclipse.swt.events.SelectionAdapter;
    36 import org.eclipse.swt.events.SelectionAdapter;
    36 import org.eclipse.swt.events.SelectionEvent;
    37 import org.eclipse.swt.events.SelectionEvent;
    37 import org.eclipse.swt.graphics.Color;
    38 import org.eclipse.swt.graphics.Color;
    38 import org.eclipse.swt.graphics.GC;
    39 import org.eclipse.swt.graphics.GC;
    47 import com.nokia.carbide.cpp.internal.pi.actions.SaveSamples;
    48 import com.nokia.carbide.cpp.internal.pi.actions.SaveSamples;
    48 import com.nokia.carbide.cpp.internal.pi.analyser.NpiInstanceRepository;
    49 import com.nokia.carbide.cpp.internal.pi.analyser.NpiInstanceRepository;
    49 import com.nokia.carbide.cpp.internal.pi.interfaces.ISaveSamples;
    50 import com.nokia.carbide.cpp.internal.pi.interfaces.ISaveSamples;
    50 import com.nokia.carbide.cpp.internal.pi.model.GenericSampledTrace;
    51 import com.nokia.carbide.cpp.internal.pi.model.GenericSampledTrace;
    51 import com.nokia.carbide.cpp.internal.pi.plugin.model.IContextMenu;
    52 import com.nokia.carbide.cpp.internal.pi.plugin.model.IContextMenu;
       
    53 import com.nokia.carbide.cpp.internal.pi.plugin.model.ITitleBarMenu;
    52 import com.nokia.carbide.cpp.internal.pi.power.actions.PowerSettingsDialog;
    54 import com.nokia.carbide.cpp.internal.pi.power.actions.PowerSettingsDialog;
    53 import com.nokia.carbide.cpp.internal.pi.power.actions.PowerStatisticsDialog;
    55 import com.nokia.carbide.cpp.internal.pi.power.actions.PowerStatisticsDialog;
    54 import com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph;
    56 import com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph;
    55 import com.nokia.carbide.cpp.internal.pi.visual.GraphComposite;
    57 import com.nokia.carbide.cpp.internal.pi.visual.GraphComposite;
    56 import com.nokia.carbide.cpp.internal.pi.visual.PICompositePanel;
    58 import com.nokia.carbide.cpp.internal.pi.visual.PICompositePanel;
    58 import com.nokia.carbide.cpp.internal.pi.visual.PIEventListener;
    60 import com.nokia.carbide.cpp.internal.pi.visual.PIEventListener;
    59 import com.nokia.carbide.cpp.pi.address.GppSample;
    61 import com.nokia.carbide.cpp.pi.address.GppSample;
    60 import com.nokia.carbide.cpp.pi.address.GppTrace;
    62 import com.nokia.carbide.cpp.pi.address.GppTrace;
    61 import com.nokia.carbide.cpp.pi.editors.PIPageEditor;
    63 import com.nokia.carbide.cpp.pi.editors.PIPageEditor;
    62 import com.nokia.carbide.cpp.pi.util.ColorPalette;
    64 import com.nokia.carbide.cpp.pi.util.ColorPalette;
       
    65 import com.nokia.carbide.cpp.pi.visual.IGenericTraceGraph;
    63 
    66 
    64 
    67 
    65 public class PowerTraceGraph extends GenericTraceGraph implements ActionListener,
    68 public class PowerTraceGraph extends GenericTraceGraph implements ActionListener,
    66 																  PIEventListener,
    69 																  PIEventListener,
    67 																  MouseMotionListener,
    70 																  MouseMotionListener,
    68 																  IContextMenu
    71 																  IContextMenu,
       
    72 																  ITitleBarMenu
    69 {
    73 {
    70 	
    74 	
    71     private int[] DTrace; // used for synchronizing the power and gpptraces.
    75     private int[] DTrace; // used for synchronizing the power and gpptraces.
    72 	private int[] DPower;
    76 	private int[] DPower;
    73 	
    77 	
   339         	this.parentComponent.getSashForm().redraw();
   343         	this.parentComponent.getSashForm().redraw();
   340 			break;
   344 			break;
   341 
   345 
   342 		case PIEvent.SCROLLED:
   346 		case PIEvent.SCROLLED:
   343 			Event event = ((Event)be.getValueObject());
   347 			Event event = ((Event)be.getValueObject());
   344 			this.parentComponent.setScrolledOrigin(event.x, event.y);
   348 			this.parentComponent.setScrolledOrigin(event.x, event.y, (FigureCanvas)event.data);
   345 			this.repaint();
   349 			this.repaint();
   346 			break;
   350 			break;
   347 
   351 
   348 		default:
   352 		default:
   349         	break;
   353         	break;
   350 	    }
   354 	    }
   351 	}
       
   352 	
       
   353 	public void refreshDataFromTrace()
       
   354 	{
       
   355 	}
   355 	}
   356 
   356 
   357 	public void enablePowerLine( boolean state )
   357 	public void enablePowerLine( boolean state )
   358 	{
   358 	{
   359 		mShowPowerLine = state;
   359 		mShowPowerLine = state;
   700 
   700 
   701 		strValue = PowerTraceGraph.powerFormat.format((int)(powerValue + 0.5));
   701 		strValue = PowerTraceGraph.powerFormat.format((int)(powerValue + 0.5));
   702 
   702 
   703 		// this does cause some overhead and could be removed since it only provides some aesthetics.
   703 		// this does cause some overhead and could be removed since it only provides some aesthetics.
   704 		updateVisibleBorders();
   704 		updateVisibleBorders();
   705 		leftBorder = this.parentComponent.getScrolledOrigin().x;
   705 		leftBorder = this.parentComponent.getScrolledOrigin(this).x;
   706 //		leftBorder = this.getVisibleLeftBorder();
   706 //		leftBorder = this.getVisibleLeftBorder();
   707 		if( leftBorder < 0 )
   707 		if( leftBorder < 0 )
   708 			leftBorder = 0;	
   708 			leftBorder = 0;	
   709 		
   709 		
   710 		// draw the average power line with a width of 3
   710 		// draw the average power line with a width of 3
   912 			count++;
   912 			count++;
   913 			if( histogram.put( new String(sample.thread.process.name + Messages.getString("PowerTraceGraph.histogram1") //$NON-NLS-1$
   913 			if( histogram.put( new String(sample.thread.process.name + Messages.getString("PowerTraceGraph.histogram1") //$NON-NLS-1$
   914 						                  + (sample.thread.threadName != null ? sample.thread.threadName
   914 						                  + (sample.thread.threadName != null ? sample.thread.threadName
   915 											   : Messages.getString("PowerTraceGraph.11")) + Messages.getString("PowerTraceGraph.12") //$NON-NLS-1$ //$NON-NLS-2$
   915 											   : Messages.getString("PowerTraceGraph.11")) + Messages.getString("PowerTraceGraph.12") //$NON-NLS-1$ //$NON-NLS-2$
   916 					   							   + sample.thread.threadId + Messages.getString("PowerTraceGraph.13") //$NON-NLS-1$
   916 					   							   + sample.thread.threadId + Messages.getString("PowerTraceGraph.13") //$NON-NLS-1$
   917 					   							   + sample.currentFunctionSym.functionName + Messages.getString("PowerTraceGraph.14") //$NON-NLS-1$
   917 					   							   + sample.getCurrentFunctionSym().getFunctionName() + Messages.getString("PowerTraceGraph.14") //$NON-NLS-1$
   918 					   							   + Long.toHexString(sample.currentFunctionSym.startAddress.longValue()) ),
   918 					   							   + Long.toHexString(sample.getCurrentFunctionSym().getStartAddress().longValue()) ),
   919 					   			Messages.getString("PowerTraceGraph.15") ) == null ) //$NON-NLS-1$
   919 					   			Messages.getString("PowerTraceGraph.15") ) == null ) //$NON-NLS-1$
   920 			{
   920 			{
   921 				numTransitions++;
   921 				numTransitions++;
   922 			}
   922 			}
   923 		}
   923 		}
  1136 			// construct the text for each scale
  1136 			// construct the text for each scale
  1137 			legend = (int)maxPower + Messages.getString("PowerTraceGraph.24"); //$NON-NLS-1$
  1137 			legend = (int)maxPower + Messages.getString("PowerTraceGraph.24"); //$NON-NLS-1$
  1138 			
  1138 			
  1139 			Point extent = gc.stringExtent(legend);
  1139 			Point extent = gc.stringExtent(legend);
  1140 			
  1140 			
  1141 			gc.drawLine(GenericTraceGraph.yLegendWidth - 3, (int)y + 1, GenericTraceGraph.yLegendWidth, (int)y + 1);
  1141 			gc.drawLine(IGenericTraceGraph.Y_LEGEND_WIDTH - 3, (int)y + 1, IGenericTraceGraph.Y_LEGEND_WIDTH, (int)y + 1);
  1142 
  1142 
  1143 			if (y >= previousBottom)
  1143 			if (y >= previousBottom)
  1144 			{
  1144 			{
  1145 				gc.drawString(legend, GenericTraceGraph.yLegendWidth - extent.x - 4, (int)y);
  1145 				gc.drawString(legend, IGenericTraceGraph.Y_LEGEND_WIDTH - extent.x - 4, (int)y);
  1146 				previousBottom = (int)y + extent.y;
  1146 				previousBottom = (int)y + extent.y;
  1147 			}
  1147 			}
  1148 		}
  1148 		}
  1149 
  1149 
  1150 		if (localGC == null) {
  1150 		if (localGC == null) {
  1151 			gc.dispose();
  1151 			gc.dispose();
  1152 			figureCanvas.redraw();
  1152 			figureCanvas.redraw();
  1153 		}
  1153 		}
  1154 	}
  1154 	}
       
  1155 
       
  1156 	/* (non-Javadoc)
       
  1157 	 * @see com.nokia.carbide.cpp.pi.visual.IGenericTraceGraph#getTitle()
       
  1158 	 */
       
  1159 	@Override
       
  1160 	public String getTitle() {
       
  1161 		return Messages.getString("PowerPlugin.pluginTitle"); //$NON-NLS-1$
       
  1162 	}
       
  1163 
       
  1164 	/* (non-Javadoc)
       
  1165 	 * @see com.nokia.carbide.cpp.internal.pi.plugin.model.ITitleBarMenu#addTitleBarMenuItems()
       
  1166 	 */
       
  1167 	public Action[] addTitleBarMenuItems() {
       
  1168 		return null;
       
  1169 	}
       
  1170 
       
  1171 	/* (non-Javadoc)
       
  1172 	 * @see com.nokia.carbide.cpp.internal.pi.plugin.model.ITitleBarMenu#getContextHelpId()
       
  1173 	 */
       
  1174 	public String getContextHelpId() {
       
  1175 		return PowerPlugin.HELP_CONTEXT_ID_MAIN_PAGE;
       
  1176 	}
  1155 }
  1177 }