(no commit message)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / common / AbsTRangeUpdate.java
1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors: Alvaro Sanchez-Leon - Initial implementation
10 *******************************************************************************/
11 package org.eclipse.linuxtools.lttng.ui.views.common;
12
13 import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor;
14 import org.eclipse.linuxtools.lttng.state.evProcessor.state.AbsStateProcessing;
15 import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
16 import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
17
18 public abstract class AbsTRangeUpdate extends AbsStateProcessing implements
19 ILttngEventProcessor {
20
21 private static final long MINORBITS = 20;
22
23 // ========================================================================
24 // General methods
25 // =======================================================================
26
27 /**
28 * Get the mkdev node id<br>
29 * <br>
30 * This is an implementation of a KERNEL macro used in Lttv
31 *
32 */
33 public long getMkdevId(long major, long minor) {
34 return (((major) << MINORBITS) | (minor));
35 }
36
37 /**
38 * Get the pixels per Nano second, either from active widgets or initialise
39 * with the experiment time range values
40 *
41 * @param traceSt
42 * @param params
43 *
44 * @return double
45 */
46 protected double getPixelsPerNs(LttngTraceState traceSt, ParamsUpdater params) {
47 double pixPerNs = params.getPixelsPerNs();
48 if (pixPerNs == 0) {
49 TmfTimeRange tsetRange = traceSt.getContext().getExperimentTimeWindow();
50
51 long startTime = tsetRange.getStartTime().getValue();
52 long endTime = tsetRange.getEndTime().getValue();
53 long delta = endTime - startTime;
54
55 if (delta > 0) {
56 pixPerNs = (double) params.getWidth() / (double) delta;
57 params.setPixelsPerNs(pixPerNs);
58 }
59 }
60 return pixPerNs;
61 }
62
63 }
This page took 0.033413 seconds and 6 git commands to generate.