-/*****************************************************************************\r
- * Copyright (c) 2008 Intel Corporation, 2009, 2012 Ericsson.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * Intel Corporation - Initial API and implementation\r
- * Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- * Alvaro Sanchez-Leon - Updated for TMF\r
- * Patrick Tasse - Refactoring\r
- *\r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Color;\r
-\r
-/**\r
- * Color theme used by the timegraph view\r
- *\r
- * @version 1.0\r
- * @author Patrick Tasse\r
- */\r
-@SuppressWarnings("javadoc")\r
-public class TimeGraphColorScheme {\r
-\r
- // elements color indices\r
- static public final int BLACK_STATE = 0;\r
- static public final int GREEN_STATE = 1;\r
- static public final int DARK_BLUE_STATE = 2;\r
- static public final int ORANGE_STATE = 3;\r
- static public final int GOLD_STATE = 4;\r
- static public final int RED_STATE = 5;\r
- static public final int GRAY_STATE = 6;\r
- static public final int DARK_GREEN_STATE = 7;\r
- static public final int DARK_YELLOW_STATE = 8;\r
- static public final int MAGENTA3_STATE = 9;\r
- static public final int PURPLE1_STATE = 10;\r
- static public final int PINK1_STATE = 11;\r
- static public final int AQUAMARINE_STATE = 12;\r
- static public final int LIGHT_BLUE_STATE = 13;\r
- static public final int CADET_BLUE_STATE = 14;\r
- static public final int OLIVE_STATE = 15;\r
-\r
- static public final int STATES0 = 0;\r
- static public final int STATES1 = 15;\r
-\r
- // selected state elements color indices\r
- static public final int BLACK_STATE_SEL = 16;\r
- static public final int GREEN_STATE_SEL = 17;\r
- static public final int DARK_BLUE_STATE_SEL = 18;\r
- static public final int ORANGE_STATE_SEL = 19;\r
- static public final int GOLD_STATE_SEL = 20;\r
- static public final int RED_STATE_SEL = 21;\r
- static public final int GRAY_STATE_SEL = 22;\r
- static public final int DARK_GREEN_STATE_SEL = 23;\r
- static public final int DARK_YELLOW_STATE_SEL = 24;\r
- static public final int MAGENTA3_STATE_SEL = 25;\r
- static public final int PURPLE1_STATE_SEL = 26;\r
- static public final int PINK1_STATE_SEL = 27;\r
- static public final int AQUAMARINE_STATE_SEL = 28;\r
- static public final int LIGHT_BLUE_STATE_SEL = 29;\r
- static public final int CADET_BLUE_STATE_SEL = 30;\r
- static public final int OLIVE_STATE_SEL = 31;\r
-\r
- static public final int STATES_SEL0 = 16;\r
- static public final int STATES_SEL1 = 31;\r
-\r
- // colors indices for viewer controls\r
- static public final int BACKGROUND = 32;\r
- static public final int FOREGROUND = 33;\r
- static public final int BACKGROUND_SEL = 34;\r
- static public final int FOREGROUND_SEL = 35;\r
- static public final int BACKGROUND_SEL_NOFOCUS = 36;\r
- static public final int FOREGROUND_SEL_NOFOCUS = 37;\r
- static public final int TOOL_BACKGROUND = 38;\r
- static public final int TOOL_FOREGROUND = 39;\r
-\r
- // misc colors\r
- static public final int FIX_COLOR = 40;\r
- static public final int WHITE = 41;\r
- static public final int GRAY = 42;\r
- static public final int BLACK = 43;\r
- static public final int DARK_GRAY = 44;\r
-\r
- // selected border color indices\r
- static public final int BLACK_BORDER = 45;\r
- static public final int GREEN_BORDER = 46;\r
- static public final int DARK_BLUE_BORDER = 47;\r
- static public final int ORANGE_BORDER = 48;\r
- static public final int GOLD_BORDER = 49;\r
- static public final int RED_BORDER = 50;\r
- static public final int GRAY_BORDER = 51;\r
- static public final int DARK_GREEN_BORDER1 = 52;\r
- static public final int DARK_YELLOW_BORDER1 = 53;\r
- static public final int MAGENTA3_BORDER1 = 54;\r
- static public final int PURPLE1_BORDER1 = 55;\r
- static public final int PINK1_BORDER1 = 56;\r
- static public final int AQUAMARINE_BORDER1 = 57;\r
- static public final int LIGHT_BLUE_BORDER1 = 58;\r
- static public final int CADET_BLUE_STATE_BORDER = 59;\r
- static public final int OLIVE_BORDER2 = 60;\r
-\r
- static public final int STATES_BORDER0 = 45;\r
- static public final int STATES_BORDER1 = 60;\r
-\r
- static public final int MID_LINE = 61;\r
- static public final int RED = 62;\r
- static public final int GREEN = 63;\r
- static public final int BLUE = 64;\r
- static public final int YELLOW = 65;\r
- static public final int CYAN = 66;\r
- static public final int MAGENTA = 67;\r
-\r
- static public final int SELECTED_TIME = 68;\r
- static public final int LEGEND_BACKGROUND = 69;\r
- static public final int LEGEND_FOREGROUND = 70;\r
-\r
- // group items' colors\r
- static public final int GR_BACKGROUND = 71;\r
- static public final int GR_FOREGROUND = 72;\r
- static public final int GR_BACKGROUND_SEL = 73;\r
- static public final int GR_FOREGROUND_SEL = 74;\r
- static public final int GR_BACKGROUND_SEL_NOFOCUS = 75;\r
- static public final int GR_FOREGROUND_SEL_NOFOCUS = 76;\r
-\r
- static public final int LIGHT_LINE = 77;\r
- static public final int BACKGROUND_NAME = 78;\r
- static public final int BACKGROUND_NAME_SEL = 79;\r
- static public final int BACKGROUND_NAME_SEL_NOFOCUS = 80;\r
-\r
- // Interraction's colors\r
- static public final int TI_START_THREAD = BLACK;\r
- static public final int TI_HANDOFF_LOCK = BLUE;\r
- static public final int TI_NOTIFY_ALL = GREEN;\r
- static public final int TI_NOTIFY = GREEN;\r
- static public final int TI_NOTIFY_JOINED = DARK_GRAY;\r
- static public final int TI_INTERRUPT = RED;\r
- static public final int TI_WAIT_EXCEEDED = BLUE;\r
-\r
- static interface IColorProvider {\r
- public Color get();\r
- }\r
-\r
- static class SysCol implements IColorProvider {\r
- int syscol;\r
-\r
- SysCol(int syscol) {\r
- this.syscol = syscol;\r
- }\r
-\r
- @Override\r
- public Color get() {\r
- return Utils.getSysColor(syscol);\r
- }\r
- }\r
-\r
- static class RGB implements IColorProvider {\r
- int r;\r
- int g;\r
- int b;\r
-\r
- RGB(int r, int g, int b) {\r
- this.r = r;\r
- this.g = g;\r
- this.b = b;\r
- }\r
-\r
- @Override\r
- public Color get() {\r
- return new Color(null, r, g, b);\r
- }\r
- }\r
-\r
- static class Mix implements IColorProvider {\r
- IColorProvider cp1;\r
- IColorProvider cp2;\r
- int w1;\r
- int w2;\r
-\r
- Mix(IColorProvider cp1, IColorProvider cp2, int w1, int w2) {\r
- this.cp1 = cp1;\r
- this.cp2 = cp2;\r
- this.w1 = w1;\r
- this.w2 = w2;\r
- }\r
-\r
- Mix(IColorProvider cp1, IColorProvider cp2) {\r
- this.cp1 = cp1;\r
- this.cp2 = cp2;\r
- this.w1 = 1;\r
- this.w2 = 1;\r
- }\r
-\r
- @Override\r
- public Color get() {\r
- Color col1 = cp1.get();\r
- Color col2 = cp2.get();\r
- Color col = Utils.mixColors(col1, col2, w1, w2);\r
- return col;\r
- }\r
- }\r
-\r
- static private final IColorProvider _providersMap[] = {\r
- //\r
- new RGB(100, 100, 100), // UNKNOWN\r
- new RGB(174, 200, 124), // RUNNING\r
- new Mix(new SysCol(SWT.COLOR_BLUE), new SysCol(SWT.COLOR_GRAY), 1, 3), // SLEEPING\r
- new RGB(210, 150, 60), // WAITING\r
- new RGB(242, 225, 168), // BLOCKED\r
- new Mix(new SysCol(SWT.COLOR_RED), new SysCol(SWT.COLOR_GRAY), 1, 3), // DEADLOCK\r
- new RGB(200, 200, 200), // STOPPED\r
- new RGB(35, 107, 42), // STEEL BLUE\r
- new RGB(205,205,0), // DARK YELLOW\r
- new RGB(205, 0, 205), // MAGENTA\r
- new RGB(171, 130, 255), // PURPLE\r
- new RGB(255, 181, 197), // PINK\r
- new RGB(112, 219, 147), // AQUAMARINE\r
- new RGB(198, 226, 255), // SLATEGRAY\r
- new RGB(95, 158, 160), // CADET BLUE\r
- new RGB(107, 142, 35), // OLIVE\r
-\r
-\r
- //TODO: Does not seem to be used, check during clean-up\r
- new SysCol(SWT.COLOR_WHITE), // UNKNOWN_SEL\r
- new SysCol(SWT.COLOR_GREEN), // RUNNING_SEL\r
- new SysCol(SWT.COLOR_BLUE), // SLEEPING_SEL\r
- new SysCol(SWT.COLOR_CYAN), // WAITING_SEL\r
- new SysCol(SWT.COLOR_YELLOW), // BLOCKED_SEL\r
- new SysCol(SWT.COLOR_RED), // DEADLOCK_SEL\r
- new SysCol(SWT.COLOR_DARK_GRAY), // STOPPED_SEL\r
- new SysCol(SWT.COLOR_WHITE),\r
- new SysCol(SWT.COLOR_GREEN),\r
- new SysCol(SWT.COLOR_BLUE),\r
- new SysCol(SWT.COLOR_CYAN),\r
- new SysCol(SWT.COLOR_YELLOW),\r
- new SysCol(SWT.COLOR_RED),\r
- new SysCol(SWT.COLOR_DARK_GRAY),\r
- new SysCol(SWT.COLOR_WHITE),\r
- new SysCol(SWT.COLOR_GREEN),\r
-\r
-\r
- new SysCol(SWT.COLOR_LIST_BACKGROUND), // BACKGROUND\r
- new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND\r
- new RGB(232, 242, 254), // BACKGROUND_SEL\r
- new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND_SEL\r
- new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // BACKGROUND_SEL_NOFOCUS\r
- new SysCol(SWT.COLOR_WIDGET_FOREGROUND), // FOREGROUND_SEL_NOFOCUS\r
- new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // TOOL_BACKGROUND\r
- new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // TOOL_FOREGROUND\r
-\r
- new SysCol(SWT.COLOR_GRAY), // FIX_COLOR\r
- new SysCol(SWT.COLOR_WHITE), // WHITE\r
- new SysCol(SWT.COLOR_GRAY), // GRAY\r
- new SysCol(SWT.COLOR_BLACK), // BLACK\r
- new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GRAY\r
-\r
- new SysCol(SWT.COLOR_DARK_GRAY), // BLACK_BORDER\r
- new RGB(75, 115, 120), // GREEN_BORDER\r
- new SysCol(SWT.COLOR_DARK_BLUE), // DARK_BLUE_BORDER\r
- new RGB(242, 225, 168), // ORANGE_BORDER\r
- new RGB(210, 150, 60), // GOLD_BORDER\r
- new SysCol(SWT.COLOR_DARK_RED), // RED_BORDER\r
- new SysCol(SWT.COLOR_BLACK), // GRAY_BORDER\r
- new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GREEN_BORDER\r
- new RGB(75, 115, 120), // DARK_YELLOW_BORDER\r
- new SysCol(SWT.COLOR_DARK_BLUE), // MAGENTA3_BORDER\r
- new RGB(242, 225, 168), // PURPLE1_BORDER\r
- new RGB(210, 150, 60), // PINK1_BORDER\r
- new SysCol(SWT.COLOR_DARK_RED), // AQUAMARINE_BORDER\r
- new SysCol(SWT.COLOR_BLACK), // LIGHT_BLUE_BORDER\r
- new SysCol(SWT.COLOR_DARK_GRAY), // BLUE_BORDER\r
- new RGB(75, 115, 120), // OLIVE_BORDER\r
-\r
-\r
- new SysCol(SWT.COLOR_GRAY), // MID_LINE\r
- new SysCol(SWT.COLOR_RED), // RED\r
- new SysCol(SWT.COLOR_GREEN), // GREEN\r
- new SysCol(SWT.COLOR_BLUE), // BLUE\r
- new SysCol(SWT.COLOR_YELLOW), // YELLOW\r
- new SysCol(SWT.COLOR_CYAN), // CYAN\r
- new SysCol(SWT.COLOR_MAGENTA), // MAGENTA\r
-\r
- new SysCol(SWT.COLOR_BLUE), // SELECTED_TIME\r
- new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // LEGEND_BACKGROUND\r
- new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // LEGEND_FOREGROUND\r
-\r
- new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_LIST_BACKGROUND)), // GR_BACKGROUND\r
- new RGB(0, 0, 50), // GR_FOREGROUND\r
- new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_WHITE), 6, 1), // GR_BACKGROUND_SEL\r
- new RGB(0, 0, 50), // GR_FOREGROUND_SEL\r
- new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_WHITE), 6, 1), // GR_BACKGROUND_SEL_NOFOCUS\r
- new RGB(0, 0, 50), // GR_FOREGROUND_SEL_NOFOCUS\r
-\r
- new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 3), // LIGHT_LINE\r
-\r
- new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 6), // BACKGROUND_NAME\r
- new Mix(new SysCol(SWT.COLOR_GRAY), new RGB(232, 242, 254), 1, 6), // BACKGROUND_NAME_SEL\r
- new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_WIDGET_BACKGROUND), 1, 6), // BACKGROUND_NAME_SEL_NOFOCUS\r
- };\r
-\r
- private final Color _colors[];\r
-\r
- /**\r
- * Default constructor\r
- */\r
- public TimeGraphColorScheme() {\r
- _colors = new Color[_providersMap.length];\r
- }\r
-\r
- /**\r
- * Dispose this color scheme\r
- */\r
- public void dispose() {\r
- for (int i = 0; i < _colors.length; i++) {\r
- Utils.dispose(_colors[i]);\r
- _colors[i] = null;\r
- }\r
- }\r
-\r
- /**\r
- * Get the color matching the given index\r
- *\r
- * @param idx\r
- * The index\r
- * @return The matching color\r
- */\r
- public Color getColor(int idx) {\r
- if (null == _colors[idx]) {\r
- if (idx >= STATES_SEL0 && idx <= STATES_SEL1) {\r
- Color col1 = getColor(idx - STATES_SEL0);\r
- Color col2 = getColor(BACKGROUND_SEL);\r
- _colors[idx] = Utils.mixColors(col1, col2, 3, 1);\r
- } else {\r
- _colors[idx] = _providersMap[idx].get();\r
- }\r
- }\r
- return _colors[idx];\r
- }\r
-\r
- /**\r
- * Get an entry's background color based on its status.\r
- *\r
- * @param selected\r
- * If the entry is selected\r
- * @param focused\r
- * If the entry is focused\r
- * @param name\r
- * Get the color of the name column (false for other columns)\r
- * @return The matching color\r
- */\r
- public Color getBkColor(boolean selected, boolean focused, boolean name) {\r
- if (name) {\r
- if (selected && focused) {\r
- return getColor(BACKGROUND_NAME_SEL);\r
- }\r
- if (selected) {\r
- return getColor(BACKGROUND_NAME_SEL_NOFOCUS);\r
- }\r
- return getColor(BACKGROUND_NAME);\r
- }\r
- if (selected && focused) {\r
- return getColor(BACKGROUND_SEL);\r
- }\r
- if (selected) {\r
- return getColor(BACKGROUND_SEL_NOFOCUS);\r
- }\r
- return getColor(BACKGROUND);\r
- }\r
-\r
- /**\r
- * Get the correct foreground color\r
- *\r
- * @param selected\r
- * Is the entry selected\r
- * @param focused\r
- * Is the entry focused\r
- * @return The matching color\r
- */\r
- public Color getFgColor(boolean selected, boolean focused) {\r
- if (selected && focused) {\r
- return getColor(FOREGROUND_SEL);\r
- }\r
- if (selected) {\r
- return getColor(FOREGROUND_SEL_NOFOCUS);\r
- }\r
- return getColor(FOREGROUND);\r
- }\r
-\r
- /**\r
- * Get the correct background color group\r
- *\r
- * @param selected\r
- * Is the entry selected\r
- * @param focused\r
- * Is the entry focused\r
- * @return The matching color\r
- */\r
- public Color getBkColorGroup(boolean selected, boolean focused) {\r
- if (selected && focused) {\r
- return getColor(GR_BACKGROUND_SEL);\r
- }\r
- if (selected) {\r
- return getColor(GR_BACKGROUND_SEL_NOFOCUS);\r
- }\r
- return getColor(GR_BACKGROUND);\r
- }\r
-\r
- /**\r
- * Get the correct foreground color group\r
- *\r
- * @param selected\r
- * Is the entry selected\r
- * @param focused\r
- * Is the entry focused\r
- * @return The matching color\r
- */\r
- public Color getFgColorGroup(boolean selected, boolean focused) {\r
- if (selected && focused) {\r
- return getColor(GR_FOREGROUND_SEL);\r
- }\r
- if (selected) {\r
- return getColor(GR_FOREGROUND_SEL_NOFOCUS);\r
- }\r
- return getColor(GR_FOREGROUND);\r
- }\r
-}\r
+/*****************************************************************************
+ * Copyright (c) 2008 Intel Corporation, 2009, 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:
+ * Intel Corporation - Initial API and implementation
+ * Ruslan A. Scherbakov, Intel - Initial API and implementation
+ * Alvaro Sanchez-Leon - Updated for TMF
+ * Patrick Tasse - Refactoring
+ *
+ *****************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Color theme used by the timegraph view
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+@SuppressWarnings("javadoc")
+public class TimeGraphColorScheme {
+
+ // elements color indices
+ static public final int BLACK_STATE = 0;
+ static public final int GREEN_STATE = 1;
+ static public final int DARK_BLUE_STATE = 2;
+ static public final int ORANGE_STATE = 3;
+ static public final int GOLD_STATE = 4;
+ static public final int RED_STATE = 5;
+ static public final int GRAY_STATE = 6;
+ static public final int DARK_GREEN_STATE = 7;
+ static public final int DARK_YELLOW_STATE = 8;
+ static public final int MAGENTA3_STATE = 9;
+ static public final int PURPLE1_STATE = 10;
+ static public final int PINK1_STATE = 11;
+ static public final int AQUAMARINE_STATE = 12;
+ static public final int LIGHT_BLUE_STATE = 13;
+ static public final int CADET_BLUE_STATE = 14;
+ static public final int OLIVE_STATE = 15;
+
+ static public final int STATES0 = 0;
+ static public final int STATES1 = 15;
+
+ // selected state elements color indices
+ static public final int BLACK_STATE_SEL = 16;
+ static public final int GREEN_STATE_SEL = 17;
+ static public final int DARK_BLUE_STATE_SEL = 18;
+ static public final int ORANGE_STATE_SEL = 19;
+ static public final int GOLD_STATE_SEL = 20;
+ static public final int RED_STATE_SEL = 21;
+ static public final int GRAY_STATE_SEL = 22;
+ static public final int DARK_GREEN_STATE_SEL = 23;
+ static public final int DARK_YELLOW_STATE_SEL = 24;
+ static public final int MAGENTA3_STATE_SEL = 25;
+ static public final int PURPLE1_STATE_SEL = 26;
+ static public final int PINK1_STATE_SEL = 27;
+ static public final int AQUAMARINE_STATE_SEL = 28;
+ static public final int LIGHT_BLUE_STATE_SEL = 29;
+ static public final int CADET_BLUE_STATE_SEL = 30;
+ static public final int OLIVE_STATE_SEL = 31;
+
+ static public final int STATES_SEL0 = 16;
+ static public final int STATES_SEL1 = 31;
+
+ // colors indices for viewer controls
+ static public final int BACKGROUND = 32;
+ static public final int FOREGROUND = 33;
+ static public final int BACKGROUND_SEL = 34;
+ static public final int FOREGROUND_SEL = 35;
+ static public final int BACKGROUND_SEL_NOFOCUS = 36;
+ static public final int FOREGROUND_SEL_NOFOCUS = 37;
+ static public final int TOOL_BACKGROUND = 38;
+ static public final int TOOL_FOREGROUND = 39;
+
+ // misc colors
+ static public final int FIX_COLOR = 40;
+ static public final int WHITE = 41;
+ static public final int GRAY = 42;
+ static public final int BLACK = 43;
+ static public final int DARK_GRAY = 44;
+
+ // selected border color indices
+ static public final int BLACK_BORDER = 45;
+ static public final int GREEN_BORDER = 46;
+ static public final int DARK_BLUE_BORDER = 47;
+ static public final int ORANGE_BORDER = 48;
+ static public final int GOLD_BORDER = 49;
+ static public final int RED_BORDER = 50;
+ static public final int GRAY_BORDER = 51;
+ static public final int DARK_GREEN_BORDER1 = 52;
+ static public final int DARK_YELLOW_BORDER1 = 53;
+ static public final int MAGENTA3_BORDER1 = 54;
+ static public final int PURPLE1_BORDER1 = 55;
+ static public final int PINK1_BORDER1 = 56;
+ static public final int AQUAMARINE_BORDER1 = 57;
+ static public final int LIGHT_BLUE_BORDER1 = 58;
+ static public final int CADET_BLUE_STATE_BORDER = 59;
+ static public final int OLIVE_BORDER2 = 60;
+
+ static public final int STATES_BORDER0 = 45;
+ static public final int STATES_BORDER1 = 60;
+
+ static public final int MID_LINE = 61;
+ static public final int RED = 62;
+ static public final int GREEN = 63;
+ static public final int BLUE = 64;
+ static public final int YELLOW = 65;
+ static public final int CYAN = 66;
+ static public final int MAGENTA = 67;
+
+ static public final int SELECTED_TIME = 68;
+ static public final int LEGEND_BACKGROUND = 69;
+ static public final int LEGEND_FOREGROUND = 70;
+
+ // group items' colors
+ static public final int GR_BACKGROUND = 71;
+ static public final int GR_FOREGROUND = 72;
+ static public final int GR_BACKGROUND_SEL = 73;
+ static public final int GR_FOREGROUND_SEL = 74;
+ static public final int GR_BACKGROUND_SEL_NOFOCUS = 75;
+ static public final int GR_FOREGROUND_SEL_NOFOCUS = 76;
+
+ static public final int LIGHT_LINE = 77;
+ static public final int BACKGROUND_NAME = 78;
+ static public final int BACKGROUND_NAME_SEL = 79;
+ static public final int BACKGROUND_NAME_SEL_NOFOCUS = 80;
+
+ // Interraction's colors
+ static public final int TI_START_THREAD = BLACK;
+ static public final int TI_HANDOFF_LOCK = BLUE;
+ static public final int TI_NOTIFY_ALL = GREEN;
+ static public final int TI_NOTIFY = GREEN;
+ static public final int TI_NOTIFY_JOINED = DARK_GRAY;
+ static public final int TI_INTERRUPT = RED;
+ static public final int TI_WAIT_EXCEEDED = BLUE;
+
+ static interface IColorProvider {
+ public Color get();
+ }
+
+ static class SysCol implements IColorProvider {
+ int syscol;
+
+ SysCol(int syscol) {
+ this.syscol = syscol;
+ }
+
+ @Override
+ public Color get() {
+ return Utils.getSysColor(syscol);
+ }
+ }
+
+ static class RGB implements IColorProvider {
+ int r;
+ int g;
+ int b;
+
+ RGB(int r, int g, int b) {
+ this.r = r;
+ this.g = g;
+ this.b = b;
+ }
+
+ @Override
+ public Color get() {
+ return new Color(null, r, g, b);
+ }
+ }
+
+ static class Mix implements IColorProvider {
+ IColorProvider cp1;
+ IColorProvider cp2;
+ int w1;
+ int w2;
+
+ Mix(IColorProvider cp1, IColorProvider cp2, int w1, int w2) {
+ this.cp1 = cp1;
+ this.cp2 = cp2;
+ this.w1 = w1;
+ this.w2 = w2;
+ }
+
+ Mix(IColorProvider cp1, IColorProvider cp2) {
+ this.cp1 = cp1;
+ this.cp2 = cp2;
+ this.w1 = 1;
+ this.w2 = 1;
+ }
+
+ @Override
+ public Color get() {
+ Color col1 = cp1.get();
+ Color col2 = cp2.get();
+ Color col = Utils.mixColors(col1, col2, w1, w2);
+ return col;
+ }
+ }
+
+ static private final IColorProvider _providersMap[] = {
+ //
+ new RGB(100, 100, 100), // UNKNOWN
+ new RGB(174, 200, 124), // RUNNING
+ new Mix(new SysCol(SWT.COLOR_BLUE), new SysCol(SWT.COLOR_GRAY), 1, 3), // SLEEPING
+ new RGB(210, 150, 60), // WAITING
+ new RGB(242, 225, 168), // BLOCKED
+ new Mix(new SysCol(SWT.COLOR_RED), new SysCol(SWT.COLOR_GRAY), 1, 3), // DEADLOCK
+ new RGB(200, 200, 200), // STOPPED
+ new RGB(35, 107, 42), // STEEL BLUE
+ new RGB(205,205,0), // DARK YELLOW
+ new RGB(205, 0, 205), // MAGENTA
+ new RGB(171, 130, 255), // PURPLE
+ new RGB(255, 181, 197), // PINK
+ new RGB(112, 219, 147), // AQUAMARINE
+ new RGB(198, 226, 255), // SLATEGRAY
+ new RGB(95, 158, 160), // CADET BLUE
+ new RGB(107, 142, 35), // OLIVE
+
+
+ //TODO: Does not seem to be used, check during clean-up
+ new SysCol(SWT.COLOR_WHITE), // UNKNOWN_SEL
+ new SysCol(SWT.COLOR_GREEN), // RUNNING_SEL
+ new SysCol(SWT.COLOR_BLUE), // SLEEPING_SEL
+ new SysCol(SWT.COLOR_CYAN), // WAITING_SEL
+ new SysCol(SWT.COLOR_YELLOW), // BLOCKED_SEL
+ new SysCol(SWT.COLOR_RED), // DEADLOCK_SEL
+ new SysCol(SWT.COLOR_DARK_GRAY), // STOPPED_SEL
+ new SysCol(SWT.COLOR_WHITE),
+ new SysCol(SWT.COLOR_GREEN),
+ new SysCol(SWT.COLOR_BLUE),
+ new SysCol(SWT.COLOR_CYAN),
+ new SysCol(SWT.COLOR_YELLOW),
+ new SysCol(SWT.COLOR_RED),
+ new SysCol(SWT.COLOR_DARK_GRAY),
+ new SysCol(SWT.COLOR_WHITE),
+ new SysCol(SWT.COLOR_GREEN),
+
+
+ new SysCol(SWT.COLOR_LIST_BACKGROUND), // BACKGROUND
+ new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND
+ new RGB(232, 242, 254), // BACKGROUND_SEL
+ new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND_SEL
+ new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // BACKGROUND_SEL_NOFOCUS
+ new SysCol(SWT.COLOR_WIDGET_FOREGROUND), // FOREGROUND_SEL_NOFOCUS
+ new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // TOOL_BACKGROUND
+ new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // TOOL_FOREGROUND
+
+ new SysCol(SWT.COLOR_GRAY), // FIX_COLOR
+ new SysCol(SWT.COLOR_WHITE), // WHITE
+ new SysCol(SWT.COLOR_GRAY), // GRAY
+ new SysCol(SWT.COLOR_BLACK), // BLACK
+ new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GRAY
+
+ new SysCol(SWT.COLOR_DARK_GRAY), // BLACK_BORDER
+ new RGB(75, 115, 120), // GREEN_BORDER
+ new SysCol(SWT.COLOR_DARK_BLUE), // DARK_BLUE_BORDER
+ new RGB(242, 225, 168), // ORANGE_BORDER
+ new RGB(210, 150, 60), // GOLD_BORDER
+ new SysCol(SWT.COLOR_DARK_RED), // RED_BORDER
+ new SysCol(SWT.COLOR_BLACK), // GRAY_BORDER
+ new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GREEN_BORDER
+ new RGB(75, 115, 120), // DARK_YELLOW_BORDER
+ new SysCol(SWT.COLOR_DARK_BLUE), // MAGENTA3_BORDER
+ new RGB(242, 225, 168), // PURPLE1_BORDER
+ new RGB(210, 150, 60), // PINK1_BORDER
+ new SysCol(SWT.COLOR_DARK_RED), // AQUAMARINE_BORDER
+ new SysCol(SWT.COLOR_BLACK), // LIGHT_BLUE_BORDER
+ new SysCol(SWT.COLOR_DARK_GRAY), // BLUE_BORDER
+ new RGB(75, 115, 120), // OLIVE_BORDER
+
+
+ new SysCol(SWT.COLOR_GRAY), // MID_LINE
+ new SysCol(SWT.COLOR_RED), // RED
+ new SysCol(SWT.COLOR_GREEN), // GREEN
+ new SysCol(SWT.COLOR_BLUE), // BLUE
+ new SysCol(SWT.COLOR_YELLOW), // YELLOW
+ new SysCol(SWT.COLOR_CYAN), // CYAN
+ new SysCol(SWT.COLOR_MAGENTA), // MAGENTA
+
+ new SysCol(SWT.COLOR_BLUE), // SELECTED_TIME
+ new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // LEGEND_BACKGROUND
+ new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // LEGEND_FOREGROUND
+
+ new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_LIST_BACKGROUND)), // GR_BACKGROUND
+ new RGB(0, 0, 50), // GR_FOREGROUND
+ new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_WHITE), 6, 1), // GR_BACKGROUND_SEL
+ new RGB(0, 0, 50), // GR_FOREGROUND_SEL
+ new Mix(new RGB(150, 200, 240), new SysCol(SWT.COLOR_WHITE), 6, 1), // GR_BACKGROUND_SEL_NOFOCUS
+ new RGB(0, 0, 50), // GR_FOREGROUND_SEL_NOFOCUS
+
+ new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 3), // LIGHT_LINE
+
+ new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 6), // BACKGROUND_NAME
+ new Mix(new SysCol(SWT.COLOR_GRAY), new RGB(232, 242, 254), 1, 6), // BACKGROUND_NAME_SEL
+ new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_WIDGET_BACKGROUND), 1, 6), // BACKGROUND_NAME_SEL_NOFOCUS
+ };
+
+ private final Color _colors[];
+
+ /**
+ * Default constructor
+ */
+ public TimeGraphColorScheme() {
+ _colors = new Color[_providersMap.length];
+ }
+
+ /**
+ * Dispose this color scheme
+ */
+ public void dispose() {
+ for (int i = 0; i < _colors.length; i++) {
+ Utils.dispose(_colors[i]);
+ _colors[i] = null;
+ }
+ }
+
+ /**
+ * Get the color matching the given index
+ *
+ * @param idx
+ * The index
+ * @return The matching color
+ */
+ public Color getColor(int idx) {
+ if (null == _colors[idx]) {
+ if (idx >= STATES_SEL0 && idx <= STATES_SEL1) {
+ Color col1 = getColor(idx - STATES_SEL0);
+ Color col2 = getColor(BACKGROUND_SEL);
+ _colors[idx] = Utils.mixColors(col1, col2, 3, 1);
+ } else {
+ _colors[idx] = _providersMap[idx].get();
+ }
+ }
+ return _colors[idx];
+ }
+
+ /**
+ * Get an entry's background color based on its status.
+ *
+ * @param selected
+ * If the entry is selected
+ * @param focused
+ * If the entry is focused
+ * @param name
+ * Get the color of the name column (false for other columns)
+ * @return The matching color
+ */
+ public Color getBkColor(boolean selected, boolean focused, boolean name) {
+ if (name) {
+ if (selected && focused) {
+ return getColor(BACKGROUND_NAME_SEL);
+ }
+ if (selected) {
+ return getColor(BACKGROUND_NAME_SEL_NOFOCUS);
+ }
+ return getColor(BACKGROUND_NAME);
+ }
+ if (selected && focused) {
+ return getColor(BACKGROUND_SEL);
+ }
+ if (selected) {
+ return getColor(BACKGROUND_SEL_NOFOCUS);
+ }
+ return getColor(BACKGROUND);
+ }
+
+ /**
+ * Get the correct foreground color
+ *
+ * @param selected
+ * Is the entry selected
+ * @param focused
+ * Is the entry focused
+ * @return The matching color
+ */
+ public Color getFgColor(boolean selected, boolean focused) {
+ if (selected && focused) {
+ return getColor(FOREGROUND_SEL);
+ }
+ if (selected) {
+ return getColor(FOREGROUND_SEL_NOFOCUS);
+ }
+ return getColor(FOREGROUND);
+ }
+
+ /**
+ * Get the correct background color group
+ *
+ * @param selected
+ * Is the entry selected
+ * @param focused
+ * Is the entry focused
+ * @return The matching color
+ */
+ public Color getBkColorGroup(boolean selected, boolean focused) {
+ if (selected && focused) {
+ return getColor(GR_BACKGROUND_SEL);
+ }
+ if (selected) {
+ return getColor(GR_BACKGROUND_SEL_NOFOCUS);
+ }
+ return getColor(GR_BACKGROUND);
+ }
+
+ /**
+ * Get the correct foreground color group
+ *
+ * @param selected
+ * Is the entry selected
+ * @param focused
+ * Is the entry focused
+ * @return The matching color
+ */
+ public Color getFgColorGroup(boolean selected, boolean focused) {
+ if (selected && focused) {
+ return getColor(GR_FOREGROUND_SEL);
+ }
+ if (selected) {
+ return getColor(GR_FOREGROUND_SEL_NOFOCUS);
+ }
+ return getColor(GR_FOREGROUND);
+ }
+}