tmf: Add support for blending sub-pixel events in time graph
authorPatrick Tasse <patrick.tasse@gmail.com>
Fri, 26 Jun 2015 15:03:30 +0000 (11:03 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Fri, 3 Jul 2015 16:07:15 +0000 (12:07 -0400)
This allows for many short time events mapping to the same pixel to be
blended in together instead of drawing only the first one and discarding
the remaining. This functionality is optional and off by default.

The Time Chart view is updated to use this scheme to allow the
highlighted ticks from a color settings filter to be noticeable even if
the time event is not the first event of that pixel.

Change-Id: I316f044157cef50f6744d128c3661964b97f09c1
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/51068
Reviewed-by: Hudson CI
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
(cherry picked from commit 37a507dca88f92e040df4d860191a88224fca382)
Reviewed-on: https://git.eclipse.org/r/51344

tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartAnalysisProvider.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java

index 8487ca7cec40238868b5b57a11b6e96ad5d69cb4..993bdcdc1d54b028731f48310f585057def094b1 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010, 2014 Ericsson
+ * Copyright (c) 2010, 2015 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -36,9 +36,6 @@ public class TimeChartAnalysisProvider extends TimeGraphPresentationProvider {
     private static final Color BOOKMARK_OUTER_COLOR = new Color(Display.getDefault(), 2, 70, 140);
     private static final Color SEARCH_MATCH_COLOR = new Color(Display.getDefault(), 177, 118, 14);
 
-    private int lastX = Integer.MIN_VALUE;
-    private int currX = Integer.MIN_VALUE;
-    private int lastPriority;
     private int lastBookmarkX = Integer.MIN_VALUE;
 
     @Override
@@ -57,12 +54,7 @@ public class TimeChartAnalysisProvider extends TimeGraphPresentationProvider {
         if (! ((TimeChartEvent) event).isVisible()) {
             return ITimeGraphPresentationProvider.INVISIBLE;
         }
-        int priority = ((TimeChartEvent) event).getColorSettingPriority();
-        if (currX == lastX) {
-            priority = Math.min(priority, lastPriority);
-        }
-        lastPriority = priority;
-        return priority;
+        return ((TimeChartEvent) event).getColorSettingPriority();
     }
 
     @Override
@@ -70,8 +62,6 @@ public class TimeChartAnalysisProvider extends TimeGraphPresentationProvider {
         if (! ((TimeChartEvent) event).isVisible()) {
             return;
         }
-        lastX = currX;
-        currX = rect.x;
         if (lastBookmarkX == rect.x || ((TimeChartEvent) event).isBookmarked()) {
             drawBookmark(rect, gc);
             lastBookmarkX = rect.x;
index 0501bdf8d4e7c49ca2eb334246aa00c231ec6c0e..beb9367faaa176b9c4774e789e6f6ac9f6e01a14 100644 (file)
@@ -110,6 +110,7 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I
         fViewer.addRangeListener(this);
         fViewer.addSelectionListener(this);
         fViewer.setMinimumItemWidth(1);
+        fViewer.getTimeGraphControl().setBlendSubPixelEvents(true);
 
         IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
         fViewer.getTimeGraphControl().setStatusLineManager(statusLineManager);
index 7977bb2162d23dd8c3236e0f6045f7e0103a15ee..af63f1da43208bcaaf84fc60009ce3211178ba9c 100644 (file)
@@ -127,6 +127,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
     private boolean fIsInFocus = false;
     private boolean fMouseOverSplitLine = false;
     private int fGlobalItemHeight = CUSTOM_ITEM_HEIGHT;
+    private boolean fBlendSubPixelEvents = false;
     private int fMinimumItemWidth = 0;
     private int fTopIndex = 0;
     private int fDragState = DRAG_NONE;
@@ -1488,7 +1489,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
                 }
                 boolean timeSelected = selectedTime >= event.getTime() && selectedTime < event.getTime() + event.getDuration();
                 if (drawState(getColorScheme(), event, stateRect, gc, selected, timeSelected)) {
-                    lastX = x;
+                    lastX = stateRect.x;
                 }
             }
             gc.setClipping((Rectangle) null);
@@ -1763,37 +1764,45 @@ public class TimeGraphControl extends TimeGraphBaseControl
             return false;
         }
         boolean visible = rect.width == 0 ? false : true;
+        rect.width = Math.max(1, rect.width);
         Color black =  Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
         gc.setForeground(black);
 
-        if (visible) {
-            if (colorIdx == ITimeGraphPresentationProvider.TRANSPARENT) {
+        if (colorIdx == ITimeGraphPresentationProvider.TRANSPARENT) {
+            if (visible) {
                 // Only draw the top and bottom borders
                 gc.drawLine(rect.x, rect.y, rect.x + rect.width - 1, rect.y);
                 gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1, rect.y + rect.height - 1);
                 if (rect.width == 1) {
                     gc.drawPoint(rect.x, rect.y - 2);
                 }
-                fTimeGraphProvider.postDrawEvent(event, rect, gc);
-                return false;
-            }
-            Color stateColor = null;
-            if (colorIdx < fEventColorMap.length) {
-                stateColor = fEventColorMap[colorIdx];
-            } else {
-                stateColor = black;
             }
+            fTimeGraphProvider.postDrawEvent(event, rect, gc);
+            return false;
+        }
+        Color stateColor = null;
+        if (colorIdx < fEventColorMap.length) {
+            stateColor = fEventColorMap[colorIdx];
+        } else {
+            stateColor = black;
+        }
 
-            boolean reallySelected = timeSelected && selected;
-            // fill all rect area
-            gc.setBackground(stateColor);
+        boolean reallySelected = timeSelected && selected;
+        // fill all rect area
+        gc.setBackground(stateColor);
+        if (visible) {
             gc.fillRectangle(rect);
+        } else if (fBlendSubPixelEvents) {
+            gc.setAlpha(128);
+            gc.fillRectangle(rect);
+            gc.setAlpha(255);
+        }
 
-            if (reallySelected) {
-                gc.drawLine(rect.x, rect.y - 1, rect.x + rect.width - 1, rect.y - 1);
-                gc.drawLine(rect.x, rect.y + rect.height, rect.x + rect.width - 1, rect.y + rect.height);
-            }
-        } else {
+        if (reallySelected) {
+            gc.drawLine(rect.x, rect.y - 1, rect.x + rect.width - 1, rect.y - 1);
+            gc.drawLine(rect.x, rect.y + rect.height, rect.x + rect.width - 1, rect.y + rect.height);
+        }
+        if (!visible) {
             gc.drawPoint(rect.x, rect.y - 2);
         }
         fTimeGraphProvider.postDrawEvent(event, rect, gc);
@@ -2429,6 +2438,20 @@ public class TimeGraphControl extends TimeGraphBaseControl
         return fMinimumItemWidth;
     }
 
+    /**
+     * Set whether all time events with a duration shorter than one pixel should
+     * be blended in. If false, only the first such time event will be drawn and
+     * the subsequent time events in the same pixel will be discarded. The
+     * default value is false.
+     *
+     * @param blend
+     *            true if sub-pixel events should be blended, false otherwise.
+     * @since 2.0
+     */
+    public void setBlendSubPixelEvents(boolean blend) {
+        fBlendSubPixelEvents = blend;
+    }
+
     /**
      * @return The entries that are currently filtered out
      */
This page took 0.06253 seconds and 5 git commands to generate.