sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/internal/ui/graph/AnalyzeToolGraph.java
changeset 6 f65f740e69f9
parent 1 1050670c6980
child 15 0367d2db2c06
equal deleted inserted replaced
5:844b047e260d 6:f65f740e69f9
     1 /*
     1 /*
     2  * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
     3  * All rights reserved.
     3  * All rights reserved.
     4  * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5  * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6  * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
   236 		}
   236 		}
   237 
   237 
   238 		graphics.setForegroundColor(ColorUtil.COLOR_100);
   238 		graphics.setForegroundColor(ColorUtil.COLOR_100);
   239 		graphics.setBackgroundColor(ColorUtil.WHITE);
   239 		graphics.setBackgroundColor(ColorUtil.WHITE);
   240 		
   240 		
   241 		int alignedLeftEdge = ((int)(canvasRect.x / 50))*50;
   241 		int alignedLeftEdge = (canvasRect.x / 50)*50;
   242 
   242 
   243 		// vertical lines (one darker, one lighter vertical line in turns every
   243 		// vertical lines (one darker, one lighter vertical line in turns every
   244 		// 50 points in width)
   244 		// 50 points in width)
   245 		if (width > 0) {
   245 		if (width > 0) {
   246 			for (int x = alignedLeftEdge ; x <= canvasRect.x + canvasRect.width; x += 50) {
   246 			for (int x = alignedLeftEdge ; x <= canvasRect.x + canvasRect.width; x += 50) {
   432 		setZoomedSize(0);
   432 		setZoomedSize(0);
   433 	}
   433 	}
   434 
   434 
   435 	/**
   435 	/**
   436 	 * Returns the current scaling factor for the graph's width
   436 	 * Returns the current scaling factor for the graph's width
   437 	 * @return
   437 	 * @return Scale
   438 	 */
   438 	 */
   439 	public double getScale() {
   439 	public double getScale() {
   440 		return scale;
   440 		return scale;
   441 	}
   441 	}
   442 
   442 
   443 	/**
   443 	/**
   444 	 * Sets the scaling factor for the graph's width
   444 	 * Sets the scaling factor for the graph's width
   445 	 * @param scale
   445 	 * @param newScale 
   446 	 */
   446 	 */
   447 	public void setScale(double newScale) {
   447 	public void setScale(double newScale) {
   448 		this.scale = newScale;
   448 		this.scale = newScale;
   449 	}
   449 	}
   450 
   450 
   451 	/**
   451 	/**
   452 	 * Returns the highest time value of the current graph in milliseconds
   452 	 * Returns the highest time value of the current graph in milliseconds
   453 	 * @return
   453 	 * @return Last time 
   454 	 */
   454 	 */
   455 	public long getLastTimeValueInMilliSeconds() {
   455 	public long getLastTimeValueInMilliSeconds() {
   456 		return model.getLastProcessTime() - model.getFirstProcessTime();
   456 		return model.getLastProcessTime() - model.getFirstProcessTime();
   457 	}
   457 	}
   458 
   458 
   465 		return getLastTimeValueInMilliSeconds() + (int) (getLastTimeValueInMilliSeconds() * 0.01);
   465 		return getLastTimeValueInMilliSeconds() + (int) (getLastTimeValueInMilliSeconds() * 0.01);
   466 	}
   466 	}
   467 
   467 
   468 	/**
   468 	/**
   469 	 * Adds a new model to this class 
   469 	 * Adds a new model to this class 
   470 	 * @param model the IMemoryActivityModel to use
   470 	 * @param newModel the IMemoryActivityModel to use
   471 	 */
   471 	 */
   472 	public void setInput(IMemoryActivityModel newModel) {
   472 	public void setInput(IMemoryActivityModel newModel) {
   473 		if (this.model != null){
   473 		if (this.model != null){
   474 			this.model.removeListener(this);
   474 			this.model.removeListener(this);
   475 		}
   475 		}
   506 		final org.eclipse.swt.widgets.ScrollBar horizontalBar = getHorizontalBar();
   506 		final org.eclipse.swt.widgets.ScrollBar horizontalBar = getHorizontalBar();
   507 
   507 
   508 		horizontalBar.addSelectionListener(new SelectionListener() {
   508 		horizontalBar.addSelectionListener(new SelectionListener() {
   509 
   509 
   510 			public void widgetDefaultSelected(SelectionEvent arg0) {
   510 			public void widgetDefaultSelected(SelectionEvent arg0) {
   511 
   511 				//do nothing by design
   512 			}
   512 			}
   513 
   513 
   514 			public void widgetSelected(SelectionEvent event) {
   514 			public void widgetSelected(SelectionEvent event) {
   515 				AnalyzeToolGraph.this.redraw();
   515 				AnalyzeToolGraph.this.redraw();
   516 			}
   516 			}
   635 		 * @see
   635 		 * @see
   636 		 * org.eclipse.draw2d.MouseMotionListener#mouseEntered(org.eclipse.draw2d
   636 		 * org.eclipse.draw2d.MouseMotionListener#mouseEntered(org.eclipse.draw2d
   637 		 * .MouseEvent)
   637 		 * .MouseEvent)
   638 		 */
   638 		 */
   639 		public void mouseEntered(MouseEvent e) {
   639 		public void mouseEntered(MouseEvent e) {
       
   640 			//do nothing by design
   640 		}
   641 		}
   641 
   642 
   642 		/*
   643 		/*
   643 		 * (non-Javadoc)
   644 		 * (non-Javadoc)
   644 		 * 
   645 		 * 
   645 		 * @see
   646 		 * @see
   646 		 * org.eclipse.draw2d.MouseMotionListener#mouseExited(org.eclipse.draw2d
   647 		 * org.eclipse.draw2d.MouseMotionListener#mouseExited(org.eclipse.draw2d
   647 		 * .MouseEvent)
   648 		 * .MouseEvent)
   648 		 */
   649 		 */
   649 		public void mouseExited(MouseEvent e) {
   650 		public void mouseExited(MouseEvent e) {
       
   651 			//do nothing by design
   650 		}
   652 		}
   651 
   653 
   652 		/*
   654 		/*
   653 		 * (non-Javadoc)
   655 		 * (non-Javadoc)
   654 		 * 
   656 		 * 
   669 		 * @see
   671 		 * @see
   670 		 * org.eclipse.draw2d.MouseMotionListener#mouseMoved(org.eclipse.draw2d
   672 		 * org.eclipse.draw2d.MouseMotionListener#mouseMoved(org.eclipse.draw2d
   671 		 * .MouseEvent)
   673 		 * .MouseEvent)
   672 		 */
   674 		 */
   673 		public void mouseMoved(MouseEvent e) {
   675 		public void mouseMoved(MouseEvent e) {
       
   676 			//do nothing by design
   674 		}
   677 		}
   675 
   678 
   676 		/*
   679 		/*
   677 		 * (non-Javadoc)
   680 		 * (non-Javadoc)
   678 		 * 
   681 		 * 
   753 					}
   756 					}
   754 				}
   757 				}
   755 			} else if (me.button == 1) {
   758 			} else if (me.button == 1) {
   756 				BaseInfo info = findClosest(me.x, me.y);
   759 				BaseInfo info = findClosest(me.x, me.y);
   757 				if (info != null) {
   760 				if (info != null) {
   758 					iDotsSelecProv.setSelection(new StructuredSelection(new MemOpDescriptor(model.getFirstProcessTime(), info, iCurrentProject, iSymReader, cppFileNames)));
   761 					iDotsSelecProv.setSelection(new StructuredSelection(new MemOpDescriptor(model.getFirstProcessTime(), info, iCurrentProject, iSymReader, cppFileNames, model.getCallstackManager())));
   759 					lastShownAlloc = info;
   762 					lastShownAlloc = info;
   760 				}
   763 				}
   761 				}
   764 				}
   762 
   765 
   763 			}
   766 			}
   764 
   767 
   765 
   768 
   766 		public void keyPressed(KeyEvent ke) {
   769 		public void keyPressed(KeyEvent ke) {
       
   770 			//do nothing by design
   767 		}
   771 		}
   768 
   772 
   769 		public void keyReleased(KeyEvent ke) {
   773 		public void keyReleased(KeyEvent ke) {
   770 			if (ke.keycode == SWT.ARROW_RIGHT || ke.keycode == SWT.ARROW_LEFT) {
   774 			if (ke.keycode == SWT.ARROW_RIGHT || ke.keycode == SWT.ARROW_LEFT) {
   771 				if (lastShownAlloc != null) {
   775 				if (lastShownAlloc != null) {
   772 					BaseInfo info = findNextAlloc(lastShownAlloc, ke.keycode == SWT.ARROW_RIGHT);
   776 					BaseInfo info = findNextAlloc(lastShownAlloc, ke.keycode == SWT.ARROW_RIGHT);
   773 					if (info != null) {
   777 					if (info != null) {
   774 						iDotsSelecProv.setSelection(new StructuredSelection(new MemOpDescriptor(model.getFirstProcessTime(), info, iCurrentProject, iSymReader, cppFileNames)));
   778 						iDotsSelecProv.setSelection(new StructuredSelection(new MemOpDescriptor(model.getFirstProcessTime(), info, iCurrentProject, iSymReader, cppFileNames, model.getCallstackManager())));
   775 						lastShownAlloc = info;
   779 						lastShownAlloc = info;
   776 						
   780 						
   777 						//if info is hidden from the visible graph area, scroll to reveal
   781 						//if info is hidden from the visible graph area, scroll to reveal
   778 						int x = getLocationOnGraph(info).x;
   782 						int x = getLocationOnGraph(info).x;
   779 						int leftEdge = getViewport().getHorizontalRangeModel().getValue();
   783 						int leftEdge = getViewport().getHorizontalRangeModel().getValue();