Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Tasse2013-11-08 11:36:31 -0500
committerPatrick Tasse2013-11-27 13:34:53 -0500
commit67e74334535b0fed8f5fd782f7d5db23d85861e1 (patch)
tree0d35d281971e82337d261efea8e57019d3d4f7ae
parent031af9262f4616a356467ca2bd8632fb376aa0a6 (diff)
downloadorg.eclipse.linuxtools-67e74334535b0fed8f5fd782f7d5db23d85861e1.tar.gz
org.eclipse.linuxtools-67e74334535b0fed8f5fd782f7d5db23d85861e1.tar.xz
org.eclipse.linuxtools-67e74334535b0fed8f5fd782f7d5db23d85861e1.zip
tmf: Fix time range histogram to show its full range
- Set the end time of the time range histogram to the time range end time (instead of the last event time) - Display the time range text controls even when model has no events - Snap selection to the end time - Draw the delimiter to the right of the end time instead of last event time - Fill the area to the right of the delimiter with the background color - Draw selection range anywhere in the histogram range regardless of last event time Change-Id: I913d22a20d79a3ca138902acd0d9cc815918cbc9 Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com> Reviewed-on: https://git.eclipse.org/r/18307 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com> IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com> Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com> Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java49
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramDataModel.java37
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java1
3 files changed, 53 insertions, 34 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java
index 4c67921579..d2690bef07 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/Histogram.java
@@ -100,6 +100,7 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
private final Color fLastEventColor = Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED);
private final Color fHistoBarColor = new Color(Display.getDefault(), 74, 112, 139);
private final Color fLostEventColor = new Color(Display.getCurrent(), 208, 62, 120);
+ private final Color fFillColor = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
// ------------------------------------------------------------------------
// Attributes
@@ -509,15 +510,8 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
synchronized (fDataModel) {
if (fScaledData != null) {
fCanvas.redraw();
- if (fDataModel.getNbEvents() != 0) {
- // Display histogram and update X-,Y-axis
- // labels
- fTimeRangeStartText.setText(TmfTimestampFormat.getDefaulTimeFormat().format(fDataModel.getFirstBucketTime()));
- fTimeRangeEndText.setText(TmfTimestampFormat.getDefaulTimeFormat().format(fDataModel.getEndTime()));
- } else {
- fTimeRangeStartText.setText(""); //$NON-NLS-1$
- fTimeRangeEndText.setText(""); //$NON-NLS-1$
- }
+ // Display histogram and update X-,Y-axis labels
+ updateRangeTextControls();
long maxNbEvents = HistogramScaledData.hideLostEvents ? fScaledData.fMaxValue : fScaledData.fMaxCombinedValue;
fMaxNbEventsText.setText(Long.toString(maxNbEvents));
// The Y-axis area might need to be re-sized
@@ -553,9 +547,24 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
// ------------------------------------------------------------------------
private void updateSelectionTime() {
+ fSelectionBegin = Math.min(fSelectionBegin, fDataModel.getEndTime());
+ fSelectionEnd = Math.min(fSelectionEnd, fDataModel.getEndTime());
((HistogramView) fParentView).updateSelectionTime(fSelectionBegin, fSelectionEnd);
}
+ /**
+ * Update the range text controls
+ */
+ private void updateRangeTextControls() {
+ if (fDataModel != null && fDataModel.getStartTime() < fDataModel.getEndTime()) {
+ fTimeRangeStartText.setText(TmfTimestampFormat.getDefaulTimeFormat().format(fDataModel.getStartTime()));
+ fTimeRangeEndText.setText(TmfTimestampFormat.getDefaulTimeFormat().format(fDataModel.getEndTime()));
+ } else {
+ fTimeRangeStartText.setText(""); //$NON-NLS-1$
+ fTimeRangeEndText.setText(""); //$NON-NLS-1$
+ }
+ }
+
// ------------------------------------------------------------------------
// PaintListener
// ------------------------------------------------------------------------
@@ -630,13 +639,13 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
}
}
- // Add a dashed line as a delimiter (at the right of the last bar)
- int lastEventIndex = limit - 1;
- while (lastEventIndex >= 0 && scaledData.fData[lastEventIndex] == 0) {
- lastEventIndex--;
- }
- lastEventIndex += (lastEventIndex < limit - 1) ? 1 : 0;
- drawDelimiter(imageGC, fLastEventColor, height, lastEventIndex);
+ // Add a dashed line as a delimiter
+ int delimiterIndex = (int) ((getDataModel().getEndTime() - scaledData.getFirstBucketTime()) / scaledData.fBucketDuration) + 1;
+ drawDelimiter(imageGC, fLastEventColor, height, delimiterIndex);
+
+ // Fill the area to the right of delimiter with background color
+ imageGC.setBackground(fFillColor);
+ imageGC.fillRectangle(delimiterIndex + 1, 0, width - (delimiterIndex + 1), height);
// Draw the selection bars
int alpha = imageGC.getAlpha();
@@ -647,7 +656,7 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
if (beginBucket >= 0 && beginBucket < limit) {
imageGC.drawLine(beginBucket, 0, beginBucket, height);
}
- final int endBucket = Math.min(lastEventIndex, scaledData.fSelectionEndBucket);
+ final int endBucket = scaledData.fSelectionEndBucket;
if (endBucket >= 0 && endBucket < limit && endBucket != beginBucket) {
imageGC.drawLine(endBucket, 0, endBucket, height);
}
@@ -804,11 +813,7 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
return;
}
- String newTS = TmfTimestampFormat.getDefaulTimeFormat().format(fDataModel.getFirstBucketTime());
- fTimeRangeStartText.setText(newTS);
-
- newTS = TmfTimestampFormat.getDefaulTimeFormat().format(fDataModel.getEndTime());
- fTimeRangeEndText.setText(newTS);
+ updateRangeTextControls();
fComposite.layout();
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramDataModel.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramDataModel.java
index d1336642a8..7f4a9b6ff4 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramDataModel.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramDataModel.java
@@ -96,7 +96,7 @@ public class HistogramDataModel implements IHistogramDataModel {
// Timestamps
private long fFirstBucketTime; // could be negative when analyzing events with descending order!!!
private long fFirstEventTime;
- private long fLastEventTime;
+ private long fEndTime;
private long fSelectionBegin;
private long fSelectionEnd;
private long fTimeLimit;
@@ -146,7 +146,7 @@ public class HistogramDataModel implements IHistogramDataModel {
* @since 2.0
*/
public HistogramDataModel(long startTime, int nbBuckets) {
- fFirstBucketTime = fFirstEventTime = fLastEventTime = startTime;
+ fFirstBucketTime = fFirstEventTime = fEndTime = startTime;
fNbBuckets = nbBuckets;
fBuckets = new long[nbBuckets];
fLostEventsBuckets = new long[nbBuckets];
@@ -169,7 +169,7 @@ public class HistogramDataModel implements IHistogramDataModel {
fLastBucket = other.fLastBucket;
fFirstBucketTime = other.fFirstBucketTime;
fFirstEventTime = other.fFirstEventTime;
- fLastEventTime = other.fLastEventTime;
+ fEndTime = other.fEndTime;
fSelectionBegin = other.fSelectionBegin;
fSelectionEnd = other.fSelectionEnd;
fTimeLimit = other.fTimeLimit;
@@ -239,7 +239,7 @@ public class HistogramDataModel implements IHistogramDataModel {
* @since 2.0
*/
public void setTimeRange(long startTime, long endTime) {
- fFirstBucketTime = fFirstEventTime = fLastEventTime = startTime;
+ fFirstBucketTime = fFirstEventTime = fEndTime = startTime;
fBucketDuration = 1;
updateEndTime();
while (endTime >= fTimeLimit) {
@@ -248,12 +248,25 @@ public class HistogramDataModel implements IHistogramDataModel {
}
/**
- * Returns the time of the last event in the model.
+ * Set the end time. Setting this ensures that the corresponding bucket is
+ * displayed regardless of the event counts.
*
- * @return the time of last event.
+ * @param endTime
+ * the time of the last used bucket
+ * @since 2.2
+ */
+ public void setEndTime(long endTime) {
+ fEndTime = endTime;
+ fLastBucket = (int) ((endTime - fFirstBucketTime) / fBucketDuration);
+ }
+
+ /**
+ * Returns the end time.
+ *
+ * @return the time of the last used bucket
*/
public long getEndTime() {
- return fLastEventTime;
+ return fEndTime;
}
/**
@@ -357,7 +370,7 @@ public class HistogramDataModel implements IHistogramDataModel {
Arrays.fill(fLostEventsBuckets, 0);
fNbEvents = 0;
fFirstBucketTime = 0;
- fLastEventTime = 0;
+ fEndTime = 0;
fSelectionBegin = 0;
fSelectionEnd = 0;
fLastBucket = 0;
@@ -451,8 +464,8 @@ public class HistogramDataModel implements IHistogramDataModel {
fFirstEventTime = timestamp;
}
- if (fLastEventTime < timestamp) {
- fLastEventTime = timestamp;
+ if (fEndTime < timestamp) {
+ fEndTime = timestamp;
}
if (timestamp >= fFirstBucketTime) {
@@ -603,14 +616,14 @@ public class HistogramDataModel implements IHistogramDataModel {
// Set selection begin and end index in the scaled histogram
if (fSelectionBegin < fFirstBucketTime) {
result.fSelectionBeginBucket = -1;
- } else if (fSelectionBegin > fLastEventTime) {
+ } else if (fSelectionBegin > fEndTime) {
result.fSelectionBeginBucket = fLastBucket;
} else {
result.fSelectionBeginBucket = (int) ((fSelectionBegin - fFirstBucketTime) / fBucketDuration) / bucketsPerBar;
}
if (fSelectionEnd < fFirstBucketTime) {
result.fSelectionEndBucket = -1;
- } else if (fSelectionEnd > fLastEventTime) {
+ } else if (fSelectionEnd > fEndTime) {
result.fSelectionEndBucket = fLastBucket;
} else {
result.fSelectionEndBucket = (int) ((fSelectionEnd - fFirstBucketTime) / fBucketDuration) / bucketsPerBar;
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java
index 3e4300e5b3..58b784c934 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/TimeRangeHistogram.java
@@ -77,6 +77,7 @@ public class TimeRangeHistogram extends Histogram {
fZoom.setNewRange(startTime, duration);
if (getDataModel().getNbEvents() == 0) {
getDataModel().setTimeRange(startTime, startTime + duration);
+ getDataModel().setEndTime(startTime + duration);
}
}

Back to the top