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