Bug 378401: Implementation of time graph widget.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / timechart / TimeChartAnalysisProvider.java
index 3a0c31faac3f6f7ba9f8ab4393125467a9ba9c7f..9d9e55db20ba4237911aa95d61766247a7e668bf 100644 (file)
@@ -14,102 +14,115 @@ package org.eclipse.linuxtools.tmf.ui.views.timechart;
 \r
 import java.util.Map;\r
 \r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme;\r
 import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.StateItem;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.graphics.Color;\r
 import org.eclipse.swt.graphics.GC;\r
+import org.eclipse.swt.graphics.RGB;\r
 import org.eclipse.swt.graphics.Rectangle;\r
 import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.ui.themes.ColorUtil;\r
 \r
-public class TimeChartAnalysisProvider extends TmfTimeAnalysisProvider {\r
+public class TimeChartAnalysisProvider extends TimeGraphPresentationProvider {\r
 \r
-       private static final Color BOOKMARK_INNER_COLOR = new Color(Display.getDefault(), 115, 165, 224);\r
-       private static final Color BOOKMARK_OUTER_COLOR = new Color(Display.getDefault(), 2, 70, 140);\r
-       private static final Color SEARCH_MATCH_COLOR = new Color(Display.getDefault(), 177, 118, 14);\r
-       \r
-       private int lastX = Integer.MIN_VALUE;\r
-       private int currX = Integer.MIN_VALUE;\r
-       private int lastPriority;\r
-       private int lastBookmarkX = Integer.MIN_VALUE;\r
-       \r
-    @Override\r
-    public StateColor getEventColor(ITimeEvent event) {\r
-        return StateColor.BLACK;\r
-    }\r
+    private static final Color BOOKMARK_INNER_COLOR = new Color(Display.getDefault(), 115, 165, 224);\r
+    private static final Color BOOKMARK_OUTER_COLOR = new Color(Display.getDefault(), 2, 70, 140);\r
+    private static final Color SEARCH_MATCH_COLOR = new Color(Display.getDefault(), 177, 118, 14);\r
+\r
+    private int lastX = Integer.MIN_VALUE;\r
+    private int currX = Integer.MIN_VALUE;\r
+    private int lastPriority;\r
+    private int lastBookmarkX = Integer.MIN_VALUE;\r
 \r
     @Override\r
-    public int getEventColorVal(ITimeEvent event) {\r
-               int priority = ((TimeChartEvent) event).getColorSettingPriority();\r
-               if (currX == lastX) {\r
-                       priority = Math.min(priority, lastPriority);\r
-               }\r
-               lastPriority = priority;\r
-               return ColorSettingsManager.getColorSetting(priority).getTickColorIndex();\r
+    public StateItem[] getStateTable() {\r
+        return new StateItem[] {\r
+                new StateItem(new RGB(100, 100, 100)), \r
+                new StateItem(new RGB(174, 200, 124)),\r
+                new StateItem(ColorUtil.blend(Display.getDefault().getSystemColor(SWT.COLOR_BLUE).getRGB(), Display.getDefault().getSystemColor(SWT.COLOR_GRAY).getRGB())),\r
+                new StateItem(new RGB(210, 150, 60)),\r
+                new StateItem(new RGB(242, 225, 168)),\r
+                new StateItem(ColorUtil.blend(Display.getDefault().getSystemColor(SWT.COLOR_RED).getRGB(), Display.getDefault().getSystemColor(SWT.COLOR_GRAY).getRGB())),\r
+                new StateItem(new RGB(200, 200, 200)),\r
+                new StateItem(new RGB(35, 107, 42)),\r
+                new StateItem(new RGB(205,205,0)),\r
+                new StateItem(new RGB(205, 0, 205)),\r
+                new StateItem(new RGB(171, 130, 255)),\r
+                new StateItem(new RGB(255, 181, 197)),\r
+                new StateItem(new RGB(112, 219, 147)),\r
+                new StateItem(new RGB(198, 226, 255)),\r
+                new StateItem(new RGB(95, 158, 160)),\r
+                new StateItem(new RGB(107, 142, 35))\r
+        };\r
     }\r
 \r
-       @Override\r
-    public String getTraceClassName(ITmfTimeAnalysisEntry entry) {\r
-        return null;\r
+    @Override\r
+    public int getEventTableIndex(ITimeEvent event) {\r
+        int priority = ((TimeChartEvent) event).getColorSettingPriority();\r
+        if (currX == lastX) {\r
+            priority = Math.min(priority, lastPriority);\r
+        }\r
+        lastPriority = priority;\r
+        return ColorSettingsManager.getColorSetting(priority).getTickColorIndex();\r
     }\r
 \r
     @Override\r
-    public String getEventName(ITimeEvent event, boolean upper, boolean extInfo) {\r
+    public String getTraceClassName(ITimeGraphEntry entry) {\r
         return null;\r
     }\r
 \r
     @Override\r
-    public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {\r
+    public String getEventName(ITimeEvent event) {\r
         return null;\r
     }\r
 \r
     @Override\r
-    public String getStateName(StateColor color) {\r
+    public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {\r
         return null;\r
     }\r
 \r
     @Override\r
-    public void drawState(TraceColorScheme colors, ITimeEvent event, Rectangle rect, GC gc, boolean selected, boolean rectBound, boolean timeSelected) {\r
-           if (! ((TimeChartEvent) event).isVisible()) {\r
-               return;\r
-           }\r
-       lastX = currX;\r
-       currX = rect.x;\r
-           super.drawState(colors, event, rect, gc, selected, rectBound, timeSelected);\r
-           if (lastBookmarkX == rect.x || ((TimeChartEvent) event).isBookmarked()) {\r
-               drawBookmark(rect, gc);\r
-               lastBookmarkX = rect.x;\r
-           } else if (lastBookmarkX == rect.x - 1) {\r
-               Rectangle r = new Rectangle(lastBookmarkX, rect.y, rect.width, rect.height);\r
-               drawBookmark(r, gc);\r
-           } else {\r
-               lastBookmarkX = Integer.MIN_VALUE;\r
-           }\r
-           if (((TimeChartEvent) event).isSearchMatch()) {\r
-               drawSearchMatch(rect, gc);\r
-           }\r
+    public void postDrawEvent(ITimeEvent event, Rectangle rect, GC gc) {\r
+        if (! ((TimeChartEvent) event).isVisible()) {\r
+            return;\r
+        }\r
+        lastX = currX;\r
+        currX = rect.x;\r
+        if (lastBookmarkX == rect.x || ((TimeChartEvent) event).isBookmarked()) {\r
+            drawBookmark(rect, gc);\r
+            lastBookmarkX = rect.x;\r
+        } else if (lastBookmarkX == rect.x - 1) {\r
+            Rectangle r = new Rectangle(lastBookmarkX, rect.y, rect.width, rect.height);\r
+            drawBookmark(r, gc);\r
+        } else {\r
+            lastBookmarkX = Integer.MIN_VALUE;\r
+        }\r
+        if (((TimeChartEvent) event).isSearchMatch()) {\r
+            drawSearchMatch(rect, gc);\r
+        }\r
     }\r
 \r
     private void drawBookmark(Rectangle r, GC gc) {\r
-       gc.setForeground(BOOKMARK_OUTER_COLOR);\r
-       gc.drawLine(r.x - 1, r.y - 2, r.x - 1, r.y + 2);\r
-       gc.drawLine(r.x + 1, r.y - 2, r.x + 1, r.y + 2);\r
-       gc.drawPoint(r.x, r.y - 2);\r
-       gc.setForeground(BOOKMARK_INNER_COLOR);\r
-       gc.drawLine(r.x, r.y - 1, r.x, r.y + 1);\r
-       gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));\r
-       gc.drawPoint(r.x - 1, r.y + 3);\r
-       gc.drawPoint(r.x, r.y + 2);\r
-       gc.drawPoint(r.x + 1, r.y + 3);\r
+        gc.setForeground(BOOKMARK_OUTER_COLOR);\r
+        gc.drawLine(r.x - 1, r.y - 2, r.x - 1, r.y + 2);\r
+        gc.drawLine(r.x + 1, r.y - 2, r.x + 1, r.y + 2);\r
+        gc.drawPoint(r.x, r.y - 2);\r
+        gc.setForeground(BOOKMARK_INNER_COLOR);\r
+        gc.drawLine(r.x, r.y - 1, r.x, r.y + 1);\r
+        gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));\r
+        gc.drawPoint(r.x - 1, r.y + 3);\r
+        gc.drawPoint(r.x, r.y + 2);\r
+        gc.drawPoint(r.x + 1, r.y + 3);\r
     }\r
-    \r
+\r
     private void drawSearchMatch(Rectangle r, GC gc) {\r
-       gc.setForeground(SEARCH_MATCH_COLOR);\r
-       gc.drawPoint(r.x, r.y + r.height);\r
-       gc.drawLine(r.x - 1, r.y + r.height + 1, r.x + 1, r.y + r.height + 1);\r
-       gc.drawLine(r.x - 2, r.y + r.height + 2, r.x + 2, r.y + r.height + 2);\r
+        gc.setForeground(SEARCH_MATCH_COLOR);\r
+        gc.drawPoint(r.x, r.y + r.height);\r
+        gc.drawLine(r.x - 1, r.y + r.height + 1, r.x + 1, r.y + r.height + 1);\r
+        gc.drawLine(r.x - 2, r.y + r.height + 2, r.x + 2, r.y + r.height + 2);\r
     }\r
 }\r
This page took 0.026483 seconds and 5 git commands to generate.