diff options
Diffstat (limited to 'traceview/src/com/android')
-rw-r--r-- | traceview/src/com/android/traceview/MainWindow.java | 10 | ||||
-rw-r--r-- | traceview/src/com/android/traceview/TimeLineView.java | 50 |
2 files changed, 57 insertions, 3 deletions
diff --git a/traceview/src/com/android/traceview/MainWindow.java b/traceview/src/com/android/traceview/MainWindow.java index 1a8e96c..b78b4f7 100644 --- a/traceview/src/com/android/traceview/MainWindow.java +++ b/traceview/src/com/android/traceview/MainWindow.java @@ -22,6 +22,7 @@ import org.eclipse.jface.window.ApplicationWindow; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @@ -34,6 +35,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.nio.channels.FileChannel; import java.util.HashMap; import java.util.Properties; @@ -41,7 +43,6 @@ import java.util.Properties; public class MainWindow extends ApplicationWindow { private final static String PING_NAME = "Traceview"; - private final static String PING_VERSION = "1.0"; private TraceReader mReader; private String mTraceName; @@ -64,6 +65,13 @@ public class MainWindow extends ApplicationWindow { protected void configureShell(Shell shell) { super.configureShell(shell); shell.setText("Traceview: " + mTraceName); + + InputStream in = getClass().getClassLoader().getResourceAsStream( + "icons/traceview-128.png"); + if (in != null) { + shell.setImage(new Image(shell.getDisplay(), in)); + } + shell.setBounds(100, 10, 1282, 900); } diff --git a/traceview/src/com/android/traceview/TimeLineView.java b/traceview/src/com/android/traceview/TimeLineView.java index 875becf..bc565dd 100644 --- a/traceview/src/com/android/traceview/TimeLineView.java +++ b/traceview/src/com/android/traceview/TimeLineView.java @@ -22,6 +22,7 @@ import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseMoveListener; +import org.eclipse.swt.events.MouseWheelListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Color; @@ -284,6 +285,12 @@ public class TimeLineView extends Composite implements Observer { } }); + mSurface.addMouseWheelListener(new MouseWheelListener() { + public void mouseScrolled(MouseEvent me) { + mSurface.mouseScrolled(me); + } + }); + mTimescale.addMouseListener(new MouseAdapter() { @Override public void mouseUp(MouseEvent me) { @@ -842,7 +849,7 @@ public class TimeLineView extends Composite implements Observer { } private static enum GraphicsState { - Normal, Marking, Scaling, Animating + Normal, Marking, Scaling, Animating, Scrolling }; private class Surface extends Canvas { @@ -966,7 +973,8 @@ public class TimeLineView extends Composite implements Observer { int xdim = dim.x - TotalXMargin; mScaleInfo.setNumPixels(xdim); boolean forceEndPoints = (mGraphicsState == GraphicsState.Scaling - || mGraphicsState == GraphicsState.Animating); + || mGraphicsState == GraphicsState.Animating + || mGraphicsState == GraphicsState.Scrolling); mScaleInfo.computeTicks(forceEndPoints); mCachedMinVal = mScaleInfo.getMinVal(); mCachedMaxVal = mScaleInfo.getMaxVal(); @@ -1687,6 +1695,44 @@ public class TimeLineView extends Composite implements Observer { update(); } + private void mouseScrolled(MouseEvent me) { + mGraphicsState = GraphicsState.Scrolling; + double tMin = mScaleInfo.getMinVal(); + double tMax = mScaleInfo.getMaxVal(); + double zoomFactor = 2; + double tMinRef = mLimitMinVal; + double tMaxRef = mLimitMaxVal; + double t; // the fixed point + double tMinNew; + double tMaxNew; + if (me.count > 0) { + // we zoom in + Point dim = mSurface.getSize(); + int x = me.x; + if (x < LeftMargin) + x = LeftMargin; + if (x > dim.x - RightMargin) + x = dim.x - RightMargin; + double ppr = mScaleInfo.getPixelsPerRange(); + t = tMin + ((x - LeftMargin) / ppr); + tMinNew = Math.max(tMinRef, t - (t - tMin) / zoomFactor); + tMaxNew = Math.min(tMaxRef, t + (tMax - t) / zoomFactor); + } else { + // we zoom out + double factor = (tMax - tMin) / (tMaxRef - tMinRef); + if (factor < 1) { + t = (factor * tMinRef - tMin) / (factor - 1); + tMinNew = Math.max(tMinRef, t - zoomFactor * (t - tMin)); + tMaxNew = Math.min(tMaxRef, t + zoomFactor * (tMax - t)); + } else { + return; + } + } + mScaleInfo.setMinVal(tMinNew); + mScaleInfo.setMaxVal(tMaxNew); + mSurface.redraw(); + } + // No defined behavior yet for double-click. private void mouseDoubleClick(MouseEvent me) { } |