Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/lttng
diff options
context:
space:
mode:
authorMatthew Khouzam2012-07-04 19:45:27 +0000
committerMatthew Khouzam2012-07-12 20:18:48 +0000
commitda0234583d43a00d0eff8c95ecd87dce7e5a49cf (patch)
tree19d4e33018cf53c8ac1bb1a71c74d36aacc287a1 /lttng
parentca2e1ebf9f9ab0b598be1f9e7dd07f362ce80665 (diff)
downloadorg.eclipse.linuxtools-da0234583d43a00d0eff8c95ecd87dce7e5a49cf.tar.gz
org.eclipse.linuxtools-da0234583d43a00d0eff8c95ecd87dce7e5a49cf.tar.xz
org.eclipse.linuxtools-da0234583d43a00d0eff8c95ecd87dce7e5a49cf.zip
Fix minor bugs with histogram time range entry.
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Diffstat (limited to 'lttng')
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramUtils.java81
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java30
2 files changed, 67 insertions, 44 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramUtils.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramUtils.java
index bf203842a5..f0516fda75 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramUtils.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramUtils.java
@@ -1,11 +1,11 @@
/*******************************************************************************
* Copyright (c) 2009, 2011, 2012 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* William Bourque - Initial API and implementation
* Francois Chouinard - Cleanup and refactoring
@@ -19,10 +19,10 @@ import org.eclipse.swt.widgets.Composite;
/**
* Bunch of conversion utilities.
- *
+ *
* @version 1.0
* @author Francois Chouinard
- * <p>
+ * <p>
*/
public abstract class HistogramUtils {
@@ -34,8 +34,9 @@ public abstract class HistogramUtils {
* Format a long representing nanoseconds into a string of the form
* "[seconds].[nanoseconds]" with the appropriate zero-padding.
* <p>
- *
- * @param ns the timestamp in nanoseconds
+ *
+ * @param ns
+ * the timestamp in nanoseconds
* @return the formatted string
*/
public static String nanosecondsToString(long ns) {
@@ -45,7 +46,8 @@ public abstract class HistogramUtils {
int length = time.length();
if (time.length() > 9) {
// Just insert the decimal dot
- time = time.substring(0, length - 9) + "." + time.substring(length - 9); //$NON-NLS-1$
+ time = time.substring(0, length - 9)
+ + "." + time.substring(length - 9); //$NON-NLS-1$
return time;
}
@@ -60,8 +62,9 @@ public abstract class HistogramUtils {
/**
* Convert a string representing a time to the corresponding long.
* <p>
- *
- * @param time the string to convert
+ *
+ * @param time
+ * the string to convert
* @return the corresponding nanoseconds value
*/
public static long stringToNanoseconds(String time) {
@@ -72,27 +75,39 @@ public abstract class HistogramUtils {
try {
int dot = buffer.indexOf("."); //$NON-NLS-1$
- // Prepend a "." if none was found (assume ns)
+ // if no . was found, assume ns
if (dot == -1) {
- buffer.insert(0, "."); //$NON-NLS-1$
- dot = 0;
+ // nanoseconds are the base unit.
+ if (time.length() > 9) {
+ long nanos = Long
+ .parseLong(time.substring(time.length() - 9));
+ long secs = Long.parseLong(time.substring(0,
+ time.length() - 9));
+ result = (secs * 1000000000) + nanos;
+ } else {
+ result = Long.parseLong(time);
+ }
+
+ } else {
+ // Zero-pad the string for nanoseconds
+ for (int i = buffer.length() - dot - 1; i < 9; i++) {
+ buffer.append("0"); //$NON-NLS-1$
+ }
+
+ // Remove the extra decimals if present
+ int nbDecimals = buffer.substring(dot + 1).length();
+ if (nbDecimals > 9) {
+ buffer.delete(buffer.substring(0, dot + 1 + 9).length(),
+ buffer.length());
+ }
+
+ // Do the conversion
+ long seconds = (dot > 0) ? Long.parseLong(buffer.substring(0,
+ dot)) : 0;
+ seconds = Math.abs(seconds);
+ long nanosecs = Long.parseLong(buffer.substring(dot + 1));
+ result = (seconds * 1000000000) + nanosecs;
}
-
- // Zero-pad the string for nanoseconds
- for (int i = buffer.length() - dot - 1; i < 9; i++)
- buffer.append("0"); //$NON-NLS-1$
-
- // Remove the extra decimals if present
- int nbDecimals = buffer.substring(dot + 1).length();
- if (nbDecimals > 9)
- buffer.delete(buffer.substring(0, dot + 1 + 9).length(), buffer.length());
-
- // Do the conversion
- long seconds = (dot > 0) ? Long.parseLong(buffer.substring(0, dot)) : 0;
- seconds = Math.abs(seconds);
- long nanosecs = Long.parseLong(buffer.substring(dot + 1));
- result = seconds * 1000000000 + nanosecs;
-
} catch (NumberFormatException e) {
// TODO: Find something interesting to say
}
@@ -103,10 +118,12 @@ public abstract class HistogramUtils {
/**
* Calculate the width of a String.
* <p>
- *
- * @param parent The control used as reference
- * @param text The Text to measure
- *
+ *
+ * @param parent
+ * The control used as reference
+ * @param text
+ * The Text to measure
+ *
* @return The result size
*/
public static int getTextSizeInControl(Composite parent, String text) {
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java
index 6ad857d434..0601b5eb00 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java
@@ -1,15 +1,15 @@
/*******************************************************************************
* Copyright (c) 2009, 2010, 2011, 2012 Ericsson
- *
+ *
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* William Bourque - Initial API and implementation
* Yuriy Vashchuk - GUI reorganisation, simplification and some related code improvements.
- * Yuriy Vashchuk - Histograms optimisation.
+ * Yuriy Vashchuk - Histograms optimisation.
* Yuriy Vashchuk - Histogram Canvas Heritage correction
* Francois Chouinard - Cleanup and refactoring
* Francois Chouinard - Moved from LTTng to TMF
@@ -114,10 +114,10 @@ public class HistogramView extends TmfView {
@Override
public void dispose() {
- if (fTimeRangeRequest != null && !fTimeRangeRequest.isCompleted()) {
+ if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
fTimeRangeRequest.cancel();
}
- if (fFullTraceRequest != null && !fFullTraceRequest.isCompleted()) {
+ if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
fFullTraceRequest.cancel();
}
fFullTraceHistogram.dispose();
@@ -246,8 +246,9 @@ public class HistogramView extends TmfView {
// Load the experiment if present
fCurrentExperiment = (TmfExperiment<ITmfEvent>) TmfExperiment.getCurrentExperiment();
- if (fCurrentExperiment != null)
+ if (fCurrentExperiment != null) {
loadExperiment();
+ }
}
@Override
@@ -326,21 +327,26 @@ public class HistogramView extends TmfView {
public synchronized void updateTimeRange(long newDuration) {
if (fCurrentExperiment != null) {
long delta = newDuration - fWindowSpan;
- long newStartTime = fWindowStartTime + delta / 2;
+ long newStartTime = fWindowStartTime + (delta / 2);
setNewRange(newStartTime, newDuration);
}
}
private void setNewRange(long startTime, long duration) {
- if (startTime < fExperimentStartTime)
+ if (startTime < fExperimentStartTime) {
startTime = fExperimentStartTime;
+ }
long endTime = startTime + duration;
+ if( endTime < startTime ) {
+ endTime = fExperimentEndTime;
+ startTime = fExperimentStartTime;
+ }
if (endTime > fExperimentEndTime) {
endTime = fExperimentEndTime;
- if (endTime - duration > fExperimentStartTime)
+ if ((endTime - duration) > fExperimentStartTime) {
startTime = endTime - duration;
- else {
+ } else {
startTime = fExperimentStartTime;
}
}
@@ -508,7 +514,7 @@ public class HistogramView extends TmfView {
}
private void sendTimeRangeRequest(long startTime, long endTime) {
- if (fTimeRangeRequest != null && !fTimeRangeRequest.isCompleted()) {
+ if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
fTimeRangeRequest.cancel();
}
TmfTimestamp startTS = new TmfTimestamp(startTime, TIME_SCALE);
@@ -524,7 +530,7 @@ public class HistogramView extends TmfView {
}
private void sendFullRangeRequest(TmfTimeRange fullRange) {
- if (fFullTraceRequest != null && !fFullTraceRequest.isCompleted()) {
+ if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
fFullTraceRequest.cancel();
}
int cacheSize = fCurrentExperiment.getCacheSize();

Back to the top