Remove bookmarks file on drag&drop trace copy.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / timechart / TimeChartAnalysisProvider.java
CommitLineData
ce62370f
FC
1/*******************************************************************************\r
2 * Copyright (c) 2010 Ericsson\r
3 * \r
4 * All rights reserved. This program and the accompanying materials are\r
5 * made available under the terms of the Eclipse Public License v1.0 which\r
6 * accompanies this distribution, and is available at\r
7 * http://www.eclipse.org/legal/epl-v10.html\r
8 * \r
9 * Contributors:\r
10 * Patrick Tasse - Initial API and implementation\r
11 *******************************************************************************/\r
12\r
13package org.eclipse.linuxtools.tmf.ui.views.timechart;\r
14\r
15import java.util.Map;\r
16\r
ce62370f 17import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;\r
2fa130b8
PT
18import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeAnalysisProvider;\r
19import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
20import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
21import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TraceColorScheme;\r
ce62370f
FC
22import org.eclipse.swt.SWT;\r
23import org.eclipse.swt.graphics.Color;\r
24import org.eclipse.swt.graphics.GC;\r
25import org.eclipse.swt.graphics.Rectangle;\r
26import org.eclipse.swt.widgets.Display;\r
27\r
28public class TimeChartAnalysisProvider extends TmfTimeAnalysisProvider {\r
29\r
30 private static final Color BOOKMARK_INNER_COLOR = new Color(Display.getDefault(), 115, 165, 224);\r
31 private static final Color BOOKMARK_OUTER_COLOR = new Color(Display.getDefault(), 2, 70, 140);\r
32 private static final Color SEARCH_MATCH_COLOR = new Color(Display.getDefault(), 177, 118, 14);\r
33 \r
34 private int lastX = Integer.MIN_VALUE;\r
35 private int currX = Integer.MIN_VALUE;\r
36 private int lastPriority;\r
37 private int lastBookmarkX = Integer.MIN_VALUE;\r
38 \r
39 @Override\r
40 public StateColor getEventColor(ITimeEvent event) {\r
41 return StateColor.BLACK;\r
42 }\r
43\r
44 @Override\r
45 public int getEventColorVal(ITimeEvent event) {\r
46 int priority = ((TimeChartEvent) event).getColorSettingPriority();\r
47 if (currX == lastX) {\r
48 priority = Math.min(priority, lastPriority);\r
49 }\r
50 lastPriority = priority;\r
51 return ColorSettingsManager.getColorSetting(priority).getTickColorIndex();\r
52 }\r
53\r
54 @Override\r
55 public String getTraceClassName(ITmfTimeAnalysisEntry entry) {\r
56 return null;\r
57 }\r
58\r
59 @Override\r
60 public String getEventName(ITimeEvent event, boolean upper, boolean extInfo) {\r
61 return null;\r
62 }\r
63\r
64 @Override\r
65 public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {\r
66 return null;\r
67 }\r
68\r
69 @Override\r
70 public String getStateName(StateColor color) {\r
71 return null;\r
72 }\r
73\r
74 @Override\r
75 public void drawState(TraceColorScheme colors, ITimeEvent event, Rectangle rect, GC gc, boolean selected, boolean rectBound, boolean timeSelected) {\r
76 if (! ((TimeChartEvent) event).isVisible()) {\r
77 return;\r
78 }\r
79 lastX = currX;\r
80 currX = rect.x;\r
81 super.drawState(colors, event, rect, gc, selected, rectBound, timeSelected);\r
82 if (lastBookmarkX == rect.x || ((TimeChartEvent) event).isBookmarked()) {\r
83 drawBookmark(rect, gc);\r
84 lastBookmarkX = rect.x;\r
85 } else if (lastBookmarkX == rect.x - 1) {\r
86 Rectangle r = new Rectangle(lastBookmarkX, rect.y, rect.width, rect.height);\r
87 drawBookmark(r, gc);\r
88 } else {\r
89 lastBookmarkX = Integer.MIN_VALUE;\r
90 }\r
91 if (((TimeChartEvent) event).isSearchMatch()) {\r
92 drawSearchMatch(rect, gc);\r
93 }\r
94 }\r
95\r
96 private void drawBookmark(Rectangle r, GC gc) {\r
97 gc.setForeground(BOOKMARK_OUTER_COLOR);\r
98 gc.drawLine(r.x - 1, r.y - 2, r.x - 1, r.y + 2);\r
99 gc.drawLine(r.x + 1, r.y - 2, r.x + 1, r.y + 2);\r
100 gc.drawPoint(r.x, r.y - 2);\r
101 gc.setForeground(BOOKMARK_INNER_COLOR);\r
102 gc.drawLine(r.x, r.y - 1, r.x, r.y + 1);\r
103 gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));\r
104 gc.drawPoint(r.x - 1, r.y + 3);\r
105 gc.drawPoint(r.x, r.y + 2);\r
106 gc.drawPoint(r.x + 1, r.y + 3);\r
107 }\r
108 \r
109 private void drawSearchMatch(Rectangle r, GC gc) {\r
110 gc.setForeground(SEARCH_MATCH_COLOR);\r
111 gc.drawPoint(r.x, r.y + r.height);\r
112 gc.drawLine(r.x - 1, r.y + r.height + 1, r.x + 1, r.y + r.height + 1);\r
113 gc.drawLine(r.x - 2, r.y + r.height + 2, r.x + 2, r.y + r.height + 2);\r
114 }\r
115}\r
This page took 0.030545 seconds and 5 git commands to generate.