-/*******************************************************************************\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 java.util.Map;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;\r
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphProvider;\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.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme;\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
-public class TimeChartAnalysisProvider extends TimeGraphProvider {\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
-\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
- }\r
-\r
- @Override\r
- public String getTraceClassName(ITimeGraphEntry entry) {\r
- return null;\r
- }\r
-\r
- @Override\r
- public String getEventName(ITimeEvent event, boolean upper, boolean extInfo) {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {\r
- return null;\r
- }\r
-\r
- @Override\r
- public String getStateName(StateColor color) {\r
- return null;\r
- }\r
-\r
- @Override\r
- public void drawState(TimeGraphColorScheme 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
- }\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
- }\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
- }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010, 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:
+ * 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.ITimeGraphPresentationProvider;
+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) {
+ if (! ((TimeChartEvent) event).isVisible()) {
+ return ITimeGraphPresentationProvider.INVISIBLE;
+ }
+ 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);
+ }
+}