Merge branch 'master' into lttng-kepler
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / timechart / TimeChartAnalysisProvider.java
index 2af8116ebeaa2060f2a84713ae712e36127bb1c5..6c69dabfc70954d92b80d2c17e629f4009dcca44 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- *\r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *   Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.timechart;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSetting;\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.swt.SWT;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.widgets.Display;\r
-\r
-/**\r
- * Provider for a time chart analysis view\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\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 StateItem[] getStateTable() {\r
-\r
-        ColorSetting[] settings = ColorSettingsManager.getColorSettings();\r
-        StateItem[] stateItems = new StateItem[settings.length];\r
-        for (int i = 0; i < settings.length; i++) {\r
-            stateItems[i] = new StateItem(settings[i].getTickColorRGB());\r
-        }\r
-        return stateItems;\r
-    }\r
-\r
-    @Override\r
-    public int getStateTableIndex(ITimeEvent event) {\r
-        int priority = ((TimeChartEvent) event).getColorSettingPriority();\r
-        if (currX == lastX) {\r
-            priority = Math.min(priority, lastPriority);\r
-        }\r
-        lastPriority = priority;\r
-        return priority;\r
-    }\r
-\r
-    @Override\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 static 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
-    }\r
-\r
-    private static 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
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010 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:
+ *   Patrick Tasse - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.timechart;
+
+import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSetting;
+import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.StateItem;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Provider for a time chart analysis view
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class TimeChartAnalysisProvider extends TimeGraphPresentationProvider {
+
+    private static final Color BOOKMARK_INNER_COLOR = new Color(Display.getDefault(), 115, 165, 224);
+    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
+    public StateItem[] getStateTable() {
+
+        ColorSetting[] settings = ColorSettingsManager.getColorSettings();
+        StateItem[] stateItems = new StateItem[settings.length];
+        for (int i = 0; i < settings.length; i++) {
+            stateItems[i] = new StateItem(settings[i].getTickColorRGB());
+        }
+        return stateItems;
+    }
+
+    @Override
+    public int getStateTableIndex(ITimeEvent event) {
+        int priority = ((TimeChartEvent) event).getColorSettingPriority();
+        if (currX == lastX) {
+            priority = Math.min(priority, lastPriority);
+        }
+        lastPriority = priority;
+        return priority;
+    }
+
+    @Override
+    public void postDrawEvent(ITimeEvent event, Rectangle rect, GC gc) {
+        if (! ((TimeChartEvent) event).isVisible()) {
+            return;
+        }
+        lastX = currX;
+        currX = rect.x;
+        if (lastBookmarkX == rect.x || ((TimeChartEvent) event).isBookmarked()) {
+            drawBookmark(rect, gc);
+            lastBookmarkX = rect.x;
+        } else if (lastBookmarkX == rect.x - 1) {
+            Rectangle r = new Rectangle(lastBookmarkX, rect.y, rect.width, rect.height);
+            drawBookmark(r, gc);
+        } else {
+            lastBookmarkX = Integer.MIN_VALUE;
+        }
+        if (((TimeChartEvent) event).isSearchMatch()) {
+            drawSearchMatch(rect, gc);
+        }
+    }
+
+    private static void drawBookmark(Rectangle r, GC gc) {
+        gc.setForeground(BOOKMARK_OUTER_COLOR);
+        gc.drawLine(r.x - 1, r.y - 2, r.x - 1, r.y + 2);
+        gc.drawLine(r.x + 1, r.y - 2, r.x + 1, r.y + 2);
+        gc.drawPoint(r.x, r.y - 2);
+        gc.setForeground(BOOKMARK_INNER_COLOR);
+        gc.drawLine(r.x, r.y - 1, r.x, r.y + 1);
+        gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
+        gc.drawPoint(r.x - 1, r.y + 3);
+        gc.drawPoint(r.x, r.y + 2);
+        gc.drawPoint(r.x + 1, r.y + 3);
+    }
+
+    private static void drawSearchMatch(Rectangle r, GC gc) {
+        gc.setForeground(SEARCH_MATCH_COLOR);
+        gc.drawPoint(r.x, r.y + r.height);
+        gc.drawLine(r.x - 1, r.y + r.height + 1, r.x + 1, r.y + r.height + 1);
+        gc.drawLine(r.x - 2, r.y + r.height + 2, r.x + 2, r.y + r.height + 2);
+    }
+}
This page took 0.030191 seconds and 5 git commands to generate.