Remove bookmarks file on drag&drop trace copy.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / widgets / timegraph / widgets / TraceColorScheme.java
1 /*****************************************************************************
2 * Copyright (c) 2008 Intel Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Intel Corporation - Initial API and implementation
10 * Ruslan A. Scherbakov, Intel - Initial API and implementation
11 * Alvaro Sanchex-Leon - Udpated for TMF
12 *
13 * $Id: TraceColorScheme.java,v 1.3 2008/05/09 16:11:24 jkubasta Exp $
14 *****************************************************************************/
15
16 package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
17
18 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeAnalysisProvider.StateColor;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.graphics.Color;
21
22
23 public class TraceColorScheme {
24
25 // elements color indices
26 static public final int BLACK_STATE = 0;
27 static public final int GREEN_STATE = 1;
28 static public final int DARK_BLUE_STATE = 2;
29 static public final int ORANGE_STATE = 3;
30 static public final int GOLD_STATE = 4;
31 static public final int RED_STATE = 5;
32 static public final int GRAY_STATE = 6;
33 static public final int DARK_GREEN_STATE = 7;
34 static public final int DARK_YELLOW_STATE = 8;
35 static public final int MAGENTA3_STATE = 9;
36 static public final int PURPLE1_STATE = 10;
37 static public final int PINK1_STATE = 11;
38 static public final int AQUAMARINE_STATE = 12;
39 static public final int LIGHT_BLUE_STATE = 13;
40 static public final int CADET_BLUE_STATE = 14;
41 static public final int OLIVE_STATE = 15;
42
43 static public final int STATES0 = 0;
44 static public final int STATES1 = 15;
45
46 // State element index to name mapping, must keep the same order as above
47 public static final StateColor stateColors[] = { StateColor.BLACK,
48 StateColor.GREEN, StateColor.DARK_BLUE, StateColor.ORANGE,
49 StateColor.GOLD, StateColor.RED, StateColor.GRAY, StateColor.DARK_GREEN, StateColor.DARK_YELLOW, StateColor.MAGENTA3, StateColor.PURPLE1,
50 StateColor.PINK1, StateColor.AQUAMARINE, StateColor.LIGHT_BLUE, StateColor.CADET_BLUE, StateColor.OLIVE
51 };
52
53 // selected state elements color indices
54 static public final int BLACK_STATE_SEL = 16;
55 static public final int GREEN_STATE_SEL = 17;
56 static public final int DARK_BLUE_STATE_SEL = 18;
57 static public final int ORANGE_STATE_SEL = 19;
58 static public final int GOLD_STATE_SEL = 20;
59 static public final int RED_STATE_SEL = 21;
60 static public final int GRAY_STATE_SEL = 22;
61 static public final int DARK_GREEN_STATE_SEL = 23;
62 static public final int DARK_YELLOW_STATE_SEL = 24;
63 static public final int MAGENTA3_STATE_SEL = 25;
64 static public final int PURPLE1_STATE_SEL = 26;
65 static public final int PINK1_STATE_SEL = 27;
66 static public final int AQUAMARINE_STATE_SEL = 28;
67 static public final int LIGHT_BLUE_STATE_SEL = 29;
68 static public final int CADET_BLUE_STATE_SEL = 30;
69 static public final int OLIVE_STATE_SEL = 31;
70
71 static public final int STATES_SEL0 = 16;
72 static public final int STATES_SEL1 = 31;
73
74 // colors indices for viewer controls
75 static public final int BACKGROUND = 32;
76 static public final int FOREGROUND = 33;
77 static public final int BACKGROUND_SEL = 34;
78 static public final int FOREGROUND_SEL = 35;
79 static public final int BACKGROUND_SEL_NOFOCUS = 36;
80 static public final int FOREGROUND_SEL_NOFOCUS = 37;
81 static public final int TOOL_BACKGROUND = 38;
82 static public final int TOOL_FOREGROUND = 39;
83
84 // misc colors
85 static public final int FIX_COLOR = 40;
86 static public final int WHITE = 41;
87 static public final int GRAY = 42;
88 static public final int BLACK = 43;
89 static public final int DARK_GRAY = 44;
90
91 // selected border color indices
92 static public final int BLACK_BORDER = 45;
93 static public final int GREEN_BORDER = 46;
94 static public final int DARK_BLUE_BORDER = 47;
95 static public final int ORANGE_BORDER = 48;
96 static public final int GOLD_BORDER = 49;
97 static public final int RED_BORDER = 50;
98 static public final int GRAY_BORDER = 51;
99 static public final int DARK_GREEN_BORDER1 = 52;
100 static public final int DARK_YELLOW_BORDER1 = 53;
101 static public final int MAGENTA3_BORDER1 = 54;
102 static public final int PURPLE1_BORDER1 = 55;
103 static public final int PINK1_BORDER1 = 56;
104 static public final int AQUAMARINE_BORDER1 = 57;
105 static public final int LIGHT_BLUE_BORDER1 = 58;
106 static public final int CADET_BLUE_STATE_BORDER = 59;
107 static public final int OLIVE_BORDER2 = 60;
108
109 static public final int STATES_BORDER0 = 45;
110 static public final int STATES_BORDER1 = 60;
111
112 static public final int MID_LINE = 61;
113 static public final int RED = 62;
114 static public final int GREEN = 63;
115 static public final int BLUE = 64;
116 static public final int YELLOW = 65;
117 static public final int CYAN = 66;
118 static public final int MAGENTA = 67;
119
120 static public final int SELECTED_TIME = 68;
121 static public final int LEGEND_BACKGROUND = 69;
122 static public final int LEGEND_FOREGROUND = 70;
123
124 // group items' colors
125 static public final int GR_BACKGROUND = 71;
126 static public final int GR_FOREGROUND = 72;
127 static public final int GR_BACKGROUND_SEL = 73;
128 static public final int GR_FOREGROUND_SEL = 74;
129 static public final int GR_BACKGROUND_SEL_NOFOCUS = 75;
130 static public final int GR_FOREGROUND_SEL_NOFOCUS = 76;
131
132 static public final int LIGHT_LINE = 77;
133 static public final int BACKGROUND_NAME = 78;
134 static public final int BACKGROUND_NAME_SEL = 79;
135 static public final int BACKGROUND_NAME_SEL_NOFOCUS = 80;
136
137 // Interraction's colors
138 static public final int TI_START_THREAD = BLACK;
139 static public final int TI_HANDOFF_LOCK = BLUE;
140 static public final int TI_NOTIFY_ALL = GREEN;
141 static public final int TI_NOTIFY = GREEN;
142 static public final int TI_NOTIFY_JOINED = DARK_GRAY;
143 static public final int TI_INTERRUPT = RED;
144 static public final int TI_WAIT_EXCEEDED = BLUE;
145
146 static interface IColorProvider {
147 public Color get();
148 }
149
150 static class SysCol implements IColorProvider {
151 int syscol;
152
153 SysCol(int syscol) {
154 this.syscol = syscol;
155 }
156
157 @Override
158 public Color get() {
159 return Utils.getSysColor(syscol);
160 }
161 }
162
163 static class RGB implements IColorProvider {
164 int r;
165 int g;
166 int b;
167
168 RGB(int r, int g, int b) {
169 this.r = r;
170 this.g = g;
171 this.b = b;
172 }
173
174 @Override
175 public Color get() {
176 return new Color(null, r, g, b);
177 }
178 }
179
180 static class Mix implements IColorProvider {
181 IColorProvider cp1;
182 IColorProvider cp2;
183 int w1;
184 int w2;
185
186 Mix(IColorProvider cp1, IColorProvider cp2, int w1, int w2) {
187 this.cp1 = cp1;
188 this.cp2 = cp2;
189 this.w1 = w1;
190 this.w2 = w2;
191 }
192
193 Mix(IColorProvider cp1, IColorProvider cp2) {
194 this.cp1 = cp1;
195 this.cp2 = cp2;
196 this.w1 = 1;
197 this.w2 = 1;
198 }
199
200 @Override
201 public Color get() {
202 Color col1 = cp1.get();
203 Color col2 = cp2.get();
204 Color col = Utils.mixColors(col1, col2, w1, w2);
205 return col;
206 }
207 }
208
209 static private final IColorProvider _providersMap[] = {
210 //
211 new RGB(100, 100, 100), // UNKNOWN
212 new RGB(174, 200, 124), // RUNNING
213 new Mix(new SysCol(SWT.COLOR_BLUE), new SysCol(SWT.COLOR_GRAY), 1, 3), // SLEEPING
214 new RGB(210, 150, 60), // WAITING
215 new RGB(242, 225, 168), // BLOCKED
216 new Mix(new SysCol(SWT.COLOR_RED), new SysCol(SWT.COLOR_GRAY), 1, 3), // DEADLOCK
217 new RGB(200, 200, 200), // STOPPED
218 new RGB(35, 107, 42), // STEEL BLUE
219 new RGB(205,205,0), // DARK YELLOW
220 new RGB(205, 0, 205), // MAGENTA
221 new RGB(171, 130, 255), // PURPLE
222 new RGB(255, 181, 197), // PINK
223 new RGB(112, 219, 147), // AQUAMARINE
224 new RGB(198, 226, 255), // SLATEGRAY
225 new RGB(95, 158, 160), // CADET BLUE
226 new RGB(107, 142, 35), // OLIVE
227
228
229 //TODO: Does not seem to be used, check during clean-up
230 new SysCol(SWT.COLOR_WHITE), // UNKNOWN_SEL
231 new SysCol(SWT.COLOR_GREEN), // RUNNING_SEL
232 new SysCol(SWT.COLOR_BLUE), // SLEEPING_SEL
233 new SysCol(SWT.COLOR_CYAN), // WAITING_SEL
234 new SysCol(SWT.COLOR_YELLOW), // BLOCKED_SEL
235 new SysCol(SWT.COLOR_RED), // DEADLOCK_SEL
236 new SysCol(SWT.COLOR_DARK_GRAY), // STOPPED_SEL
237 new SysCol(SWT.COLOR_WHITE),
238 new SysCol(SWT.COLOR_GREEN),
239 new SysCol(SWT.COLOR_BLUE),
240 new SysCol(SWT.COLOR_CYAN),
241 new SysCol(SWT.COLOR_YELLOW),
242 new SysCol(SWT.COLOR_RED),
243 new SysCol(SWT.COLOR_DARK_GRAY),
244 new SysCol(SWT.COLOR_WHITE),
245 new SysCol(SWT.COLOR_GREEN),
246
247
248 new SysCol(SWT.COLOR_LIST_BACKGROUND), // BACKGROUND
249 new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND
250 new RGB(232, 242, 254), // BACKGROUND_SEL
251 new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND_SEL
252 new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // BACKGROUND_SEL_NOFOCUS
253 new SysCol(SWT.COLOR_WIDGET_FOREGROUND), // FOREGROUND_SEL_NOFOCUS
254 new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // TOOL_BACKGROUND
255 new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // TOOL_FOREGROUND
256
257 new SysCol(SWT.COLOR_GRAY), // FIX_COLOR
258 new SysCol(SWT.COLOR_WHITE), // WHITE
259 new SysCol(SWT.COLOR_GRAY), // GRAY
260 new SysCol(SWT.COLOR_BLACK), // BLACK
261 new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GRAY
262
263 new SysCol(SWT.COLOR_DARK_GRAY), // BLACK_BORDER
264 new RGB(75, 115, 120), // GREEN_BORDER
265 new SysCol(SWT.COLOR_DARK_BLUE), // DARK_BLUE_BORDER
266 new RGB(242, 225, 168), // ORANGE_BORDER
267 new RGB(210, 150, 60), // GOLD_BORDER
268 new SysCol(SWT.COLOR_DARK_RED), // RED_BORDER
269 new SysCol(SWT.COLOR_BLACK), // GRAY_BORDER
270 new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GREEN_BORDER
271 new RGB(75, 115, 120), // DARK_YELLOW_BORDER
272 new SysCol(SWT.COLOR_DARK_BLUE), // MAGENTA3_BORDER
273 new RGB(242, 225, 168), // PURPLE1_BORDER
274 new RGB(210, 150, 60), // PINK1_BORDER
275 new SysCol(SWT.COLOR_DARK_RED), // AQUAMARINE_BORDER
276 new SysCol(SWT.COLOR_BLACK), // LIGHT_BLUE_BORDER
277 new SysCol(SWT.COLOR_DARK_GRAY), // BLUE_BORDER
278 new RGB(75, 115, 120), // OLIVE_BORDER
279
280
281 new SysCol(SWT.COLOR_GRAY), // MID_LINE
282 new SysCol(SWT.COLOR_RED), // RED
283 new SysCol(SWT.COLOR_GREEN), // GREEN
284 new SysCol(SWT.COLOR_BLUE), // BLUE
285 new SysCol(SWT.COLOR_YELLOW), // YELLOW
286 new SysCol(SWT.COLOR_CYAN), // CYAN
287 new SysCol(SWT.COLOR_MAGENTA), // MAGENTA
288
289 new SysCol(SWT.COLOR_BLUE), // SELECTED_TIME
290 new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // LEGEND_BACKGROUND
291 new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // LEGEND_FOREGROUND
292
293 new Mix(new RGB(150, 200, 240), new SysCol(
294 SWT.COLOR_LIST_BACKGROUND)),// GR_BACKGROUND
295 new RGB(0, 0, 50), // GR_FOREGROUND
296 new Mix(new RGB(200, 200, 100),
297 new SysCol(SWT.COLOR_LIST_SELECTION)), // GR_BACKGROUND_SEL
298 new Mix(new RGB(150, 200, 240), new SysCol(
299 SWT.COLOR_LIST_SELECTION_TEXT)), // GR_FOREGROUND_SEL
300 new Mix(new RGB(222, 222, 155), new SysCol(
301 SWT.COLOR_WIDGET_BACKGROUND)), // GR_BACKGROUND_SEL_NOFOCUS
302 new RGB(0, 0, 50), // GR_FOREGROUND_SEL_NOFOCUS
303
304 new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(
305 SWT.COLOR_LIST_BACKGROUND), 1, 3), // LIGHT_LINE
306
307 new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 6), // BACKGROUND_NAME
308 new Mix(new SysCol(SWT.COLOR_GRAY), new RGB(232, 242, 254), 1, 6), // BACKGROUND_NAME_SEL
309 new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_WIDGET_BACKGROUND), 1, 6), // BACKGROUND_NAME_SEL_NOFOCUS
310 };
311
312 private Color _colors[];
313
314 public TraceColorScheme() {
315 _colors = new Color[_providersMap.length];
316 }
317
318 public void dispose() {
319 for (int i = 0; i < _colors.length; i++) {
320 Utils.dispose(_colors[i]);
321 _colors[i] = null;
322 }
323 }
324
325 public Color getColor(int idx) {
326 if (null == _colors[idx]) {
327 if (idx >= STATES_SEL0 && idx <= STATES_SEL1) {
328 Color col1 = getColor(idx - STATES_SEL0);
329 Color col2 = getColor(BACKGROUND_SEL);
330 _colors[idx] = Utils.mixColors(col1, col2, 3, 1);
331 } else {
332 _colors[idx] = _providersMap[idx].get();
333 }
334 }
335 return _colors[idx];
336 }
337
338 public Color getBkColor(boolean selected, boolean focused, boolean name) {
339 if (name) {
340 if (selected && focused)
341 return getColor(BACKGROUND_NAME_SEL);
342 if (selected)
343 return getColor(BACKGROUND_NAME_SEL_NOFOCUS);
344 return getColor(BACKGROUND_NAME);
345 } else {
346 if (selected && focused)
347 return getColor(BACKGROUND_SEL);
348 if (selected)
349 return getColor(BACKGROUND_SEL_NOFOCUS);
350 return getColor(BACKGROUND);
351 }
352 }
353
354 public Color getFgColor(boolean selected, boolean focused) {
355 if (selected && focused)
356 return getColor(FOREGROUND_SEL);
357 if (selected)
358 return getColor(FOREGROUND_SEL_NOFOCUS);
359 return getColor(FOREGROUND);
360 }
361
362 public Color getBkColorGroup(boolean selected, boolean focused) {
363 if (selected && focused)
364 return getColor(GR_BACKGROUND_SEL);
365 if (selected)
366 return getColor(GR_BACKGROUND_SEL_NOFOCUS);
367 return getColor(GR_BACKGROUND);
368 }
369
370 public Color getFgColorGroup(boolean selected, boolean focused) {
371 if (selected && focused)
372 return getColor(GR_FOREGROUND_SEL);
373 if (selected)
374 return getColor(GR_FOREGROUND_SEL_NOFOCUS);
375 return getColor(GR_FOREGROUND);
376 }
377
378 public static StateColor[] getStateColors() {
379 return stateColors;
380 }
381 }
This page took 0.050748 seconds and 5 git commands to generate.