sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi.memory/src/com/nokia/carbide/cpp/pi/memory/MemTraceGraph.java
changeset 12 ae255c9aa552
parent 5 844b047e260d
equal deleted inserted replaced
11:5b9d4d8641ce 12:ae255c9aa552
    50 import org.eclipse.swt.layout.FillLayout;
    50 import org.eclipse.swt.layout.FillLayout;
    51 import org.eclipse.swt.layout.FormAttachment;
    51 import org.eclipse.swt.layout.FormAttachment;
    52 import org.eclipse.swt.layout.FormData;
    52 import org.eclipse.swt.layout.FormData;
    53 import org.eclipse.swt.layout.FormLayout;
    53 import org.eclipse.swt.layout.FormLayout;
    54 import org.eclipse.swt.layout.GridData;
    54 import org.eclipse.swt.layout.GridData;
       
    55 import org.eclipse.swt.widgets.Combo;
    55 import org.eclipse.swt.widgets.Composite;
    56 import org.eclipse.swt.widgets.Composite;
    56 import org.eclipse.swt.widgets.Display;
    57 import org.eclipse.swt.widgets.Display;
    57 import org.eclipse.swt.widgets.Event;
    58 import org.eclipse.swt.widgets.Event;
    58 import org.eclipse.swt.widgets.Listener;
    59 import org.eclipse.swt.widgets.Listener;
    59 import org.eclipse.swt.widgets.Menu;
    60 import org.eclipse.swt.widgets.Menu;
   397 		while(iterator.hasNext()){
   398 		while(iterator.hasNext()){
   398 			MemSampleByTime msbt = iterator.next();	
   399 			MemSampleByTime msbt = iterator.next();	
   399 			// calculate new x coord's value and round it to integer
   400 			// calculate new x coord's value and round it to integer
   400 			int xCoord = (int) ((msbt.getTime()/getScale()) + 0.5);
   401 			int xCoord = (int) ((msbt.getTime()/getScale()) + 0.5);
   401 			int maxBytes;
   402 			int maxBytes;
   402 			if (dynamicMemoryVisualisation)
   403 			if (dynamicMemoryVisualisation) {
   403 				maxBytes = maxChunks;
   404 				if (paintMode == UsageType.CHUNKS) {
   404 			else
   405 					maxBytes = maxChunks;
   405 				maxBytes = memTrace.getTraceMaxChunks();
   406 				} else if (paintMode == UsageType.HEAPSTACK) {
       
   407 					maxBytes = maxStack;
       
   408 				} else {
       
   409 					maxBytes = maxStackHeap;
       
   410 				}
       
   411 			} else {
       
   412 				if (paintMode == UsageType.CHUNKS) {				
       
   413 					maxBytes = memTrace.getTraceMaxChunks();					
       
   414 				} else if (paintMode == UsageType.HEAPSTACK) {
       
   415 					maxBytes = memTrace.getTraceMaxStackHeap();
       
   416 				} else {
       
   417 					maxBytes = memTrace.getTraceMaxTotal();		
       
   418 				}
       
   419 			}
       
   420 				
   406 			int yMultiplier = prettyMaxBytes(maxBytes) / height;
   421 			int yMultiplier = prettyMaxBytes(maxBytes) / height;
   407 			// calculate new y-coord's value and round it to integer
   422 			// calculate new y-coord's value and round it to integer
   408 			int yCoord = (int) (((double) height - (double) msbt.getUsedMemory()
   423 			int yCoord = (int) (((double) height - (double) msbt.getUsedMemory()
   409 					/ yMultiplier) + 0.5);				
   424 					/ yMultiplier) + 0.5);				
   410 			pl.addPoint(xCoord,yCoord);
   425 			pl.addPoint(xCoord,yCoord);
  1260 		if (this.leftFigureCanvas == null)
  1275 		if (this.leftFigureCanvas == null)
  1261 			this.leftFigureCanvas = figureCanvas;
  1276 			this.leftFigureCanvas = figureCanvas;
  1262 
  1277 
  1263 		Rectangle rect = ((GraphComposite) figureCanvas.getParent()).figureCanvas
  1278 		Rectangle rect = ((GraphComposite) figureCanvas.getParent()).figureCanvas
  1264 				.getClientArea();
  1279 				.getClientArea();
       
  1280 		
       
  1281 		Combo titleCombo = ((GraphComposite) figureCanvas.getParent())
       
  1282 			.getTitleBarCombo();
  1265 
  1283 
  1266 		double visY = rect.height - MemTraceGraph.xLegendHeight;
  1284 		double visY = rect.height - MemTraceGraph.xLegendHeight;
  1267 
  1285 
  1268 		gc.setForeground(ColorPalette.getColor(new RGB(100, 100, 100)));
  1286 		gc.setForeground(ColorPalette.getColor(new RGB(100, 100, 100)));
  1269 		gc.setBackground(ColorPalette.getColor(new RGB(255, 255, 255)));
  1287 		gc.setBackground(ColorPalette.getColor(new RGB(255, 255, 255)));
  1273 		if (paintMode == UsageType.CHUNKS) {
  1291 		if (paintMode == UsageType.CHUNKS) {
  1274 			if (dynamicMemoryVisualisation)
  1292 			if (dynamicMemoryVisualisation)
  1275 				maxBytes = maxChunks;
  1293 				maxBytes = maxChunks;
  1276 			else
  1294 			else
  1277 				maxBytes = memTrace.getTraceMaxChunks();
  1295 				maxBytes = memTrace.getTraceMaxChunks();
       
  1296 			titleCombo.select(0);
  1278 		} else if (paintMode == UsageType.HEAPSTACK) {
  1297 		} else if (paintMode == UsageType.HEAPSTACK) {
  1279 			if (dynamicMemoryVisualisation)
  1298 			if (dynamicMemoryVisualisation)
  1280 				maxBytes = maxStack;
  1299 				maxBytes = maxStack;
  1281 			else
  1300 			else
  1282 				maxBytes = memTrace.getTraceMaxStackHeap();
  1301 				maxBytes = memTrace.getTraceMaxStackHeap();
       
  1302 			titleCombo.select(1);
  1283 		} else {
  1303 		} else {
  1284 			if (dynamicMemoryVisualisation)
  1304 			if (dynamicMemoryVisualisation)
  1285 				maxBytes = maxChunks > maxStack ? maxChunks : maxStack;
  1305 				maxBytes = maxChunks > maxStack ? maxChunks : maxStack;
  1286 			else
  1306 			else
  1287 				maxBytes = memTrace.getTraceMaxChunks() > memTrace
  1307 				maxBytes = memTrace.getTraceMaxChunks() > memTrace
  1288 						.getTraceMaxStackHeap() ? memTrace.getTraceMaxChunks()
  1308 						.getTraceMaxStackHeap() ? memTrace.getTraceMaxChunks()
  1289 						: memTrace.getTraceMaxStackHeap();
  1309 						: memTrace.getTraceMaxStackHeap();
       
  1310 			titleCombo.select(2);
  1290 		}
  1311 		}
  1291 
  1312 
  1292 		double multiplier = 0;
  1313 		double multiplier = 0;
  1293 
  1314 
  1294 		if (true)// !dynamicMemoryVisualisation)
  1315 		if (true)// !dynamicMemoryVisualisation)
  1623 				for (int i = 0; i < 3; i++) {
  1644 				for (int i = 0; i < 3; i++) {
  1624 					MemTraceGraph graph = (MemTraceGraph) memTrace
  1645 					MemTraceGraph graph = (MemTraceGraph) memTrace
  1625 							.getTraceGraph(i);
  1646 							.getTraceGraph(i);
  1626 					graph.action("chunk_on"); //$NON-NLS-1$
  1647 					graph.action("chunk_on"); //$NON-NLS-1$
  1627 				}
  1648 				}
       
  1649 				MemoryPlugin.getDefault().updateMenuItems();
  1628 			}
  1650 			}
  1629 		};
  1651 		};
  1630 		actionShowChunk.setText(Messages.getString("MemoryPlugin.showChunks")); //$NON-NLS-1$
  1652 		actionShowChunk.setText(Messages.getString("MemoryPlugin.showChunks")); //$NON-NLS-1$
  1631 
  1653 
  1632 		// Action for showing only heap/stack
  1654 		// Action for showing only heap/stack
  1640 				for (int i = 0; i < 3; i++) {
  1662 				for (int i = 0; i < 3; i++) {
  1641 					MemTraceGraph graph = (MemTraceGraph) memTrace
  1663 					MemTraceGraph graph = (MemTraceGraph) memTrace
  1642 							.getTraceGraph(i);
  1664 							.getTraceGraph(i);
  1643 					graph.action("heapstack_on"); //$NON-NLS-1$
  1665 					graph.action("heapstack_on"); //$NON-NLS-1$
  1644 				}
  1666 				}
       
  1667 				MemoryPlugin.getDefault().updateMenuItems();
  1645 			}
  1668 			}
  1646 		};
  1669 		};
  1647 		actionShowHeap
  1670 		actionShowHeap
  1648 				.setText(Messages.getString("MemoryPlugin.showHeapStack")); //$NON-NLS-1$
  1671 				.setText(Messages.getString("MemoryPlugin.showHeapStack")); //$NON-NLS-1$
  1649 
  1672 
  1658 				for (int i = 0; i < 3; i++) {
  1681 				for (int i = 0; i < 3; i++) {
  1659 					MemTraceGraph graph = (MemTraceGraph) memTrace
  1682 					MemTraceGraph graph = (MemTraceGraph) memTrace
  1660 							.getTraceGraph(i);
  1683 							.getTraceGraph(i);
  1661 					graph.action("chunk_heapstack_on"); //$NON-NLS-1$
  1684 					graph.action("chunk_heapstack_on"); //$NON-NLS-1$
  1662 				}
  1685 				}
       
  1686 				MemoryPlugin.getDefault().updateMenuItems();
  1663 			}
  1687 			}
  1664 		};
  1688 		};
  1665 		actionShowBothItem.setText(Messages.getString("MemoryPlugin.showAll")); //$NON-NLS-1$
  1689 		actionShowBothItem.setText(Messages.getString("MemoryPlugin.showAll")); //$NON-NLS-1$
  1666 
  1690 
  1667 		actionArrayList.add(actionShowChunk);
  1691 		actionArrayList.add(actionShowChunk);