Commit | Line | Data |
---|---|---|
ca13a91c 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 | |
13 | package org.eclipse.linuxtools.tmf.ui.views.colors;\r | |
14 | \r | |
15 | import org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode;\r | |
16 | import org.eclipse.swt.SWT;\r | |
17 | import org.eclipse.swt.graphics.Color;\r | |
18 | import org.eclipse.swt.graphics.RGB;\r | |
19 | import org.eclipse.swt.widgets.Display;\r | |
20 | import org.eclipse.ui.themes.ColorUtil;\r | |
21 | \r | |
22 | public class ColorSetting {\r | |
23 | \r | |
24 | private RGB fForegroundRGB;\r | |
25 | private RGB fBackgroundRGB;\r | |
26 | private Color fForegroundColor;\r | |
27 | private Color fBackgroundColor;\r | |
28 | private Color fDimmedForegroundColor;\r | |
29 | private Color fDimmedBackgroundColor;\r | |
30 | private int fTickColorIndex;\r | |
31 | private ITmfFilterTreeNode fFilter;\r | |
32 | \r | |
33 | public ColorSetting(RGB foreground, RGB background, int tickColorIndex, ITmfFilterTreeNode filter) {\r | |
34 | fForegroundRGB = foreground;\r | |
35 | fBackgroundRGB = background;\r | |
36 | fTickColorIndex = tickColorIndex;\r | |
37 | fFilter = filter;\r | |
38 | Display display = Display.getDefault();\r | |
39 | fForegroundColor = new Color(display, fForegroundRGB);\r | |
40 | fBackgroundColor = new Color(display, fBackgroundRGB);\r | |
41 | fDimmedForegroundColor = new Color(display, ColorUtil.blend(\r | |
42 | fForegroundRGB, fBackgroundRGB));\r | |
43 | fDimmedBackgroundColor = new Color(display, ColorUtil.blend(\r | |
44 | fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));\r | |
45 | }\r | |
46 | \r | |
47 | /**\r | |
48 | * @return the foreground\r | |
49 | */\r | |
50 | public RGB getForegroundRGB() {\r | |
51 | return fForegroundRGB;\r | |
52 | }\r | |
53 | \r | |
54 | /**\r | |
55 | * @param foreground the foreground to set\r | |
56 | */\r | |
57 | public void setForegroundRGB(RGB foreground) {\r | |
58 | fForegroundRGB = foreground;\r | |
59 | fForegroundColor.dispose();\r | |
60 | fDimmedForegroundColor.dispose();\r | |
61 | Display display = Display.getDefault();\r | |
62 | fForegroundColor = new Color(display, fForegroundRGB);\r | |
63 | fDimmedForegroundColor = new Color(display, ColorUtil.blend(\r | |
64 | fForegroundRGB, fBackgroundRGB));\r | |
65 | }\r | |
66 | \r | |
67 | /**\r | |
68 | * @return the background\r | |
69 | */\r | |
70 | public RGB getBackgroundRGB() {\r | |
71 | return fBackgroundRGB;\r | |
72 | }\r | |
73 | \r | |
74 | /**\r | |
75 | * @param background the background to set\r | |
76 | */\r | |
77 | public void setBackgroundRGB(RGB background) {\r | |
78 | fBackgroundRGB = background;\r | |
79 | fBackgroundColor.dispose();\r | |
80 | fDimmedBackgroundColor.dispose();\r | |
81 | Display display = Display.getDefault();\r | |
82 | fBackgroundColor = new Color(display, fBackgroundRGB);\r | |
83 | fDimmedBackgroundColor = new Color(display, ColorUtil.blend(\r | |
84 | fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));\r | |
85 | }\r | |
86 | \r | |
87 | /**\r | |
88 | * @return the tick color index (0-15)\r | |
89 | * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme\r | |
90 | */\r | |
91 | public int getTickColorIndex() {\r | |
92 | return fTickColorIndex;\r | |
93 | }\r | |
94 | \r | |
95 | /**\r | |
96 | * @param tickColorIndex the tick color index to set (0-15)\r | |
97 | * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme\r | |
98 | */\r | |
99 | public void setTickColorIndex(int tickColorIndex) {\r | |
100 | fTickColorIndex = tickColorIndex;\r | |
101 | }\r | |
102 | \r | |
103 | /**\r | |
104 | * @return the filter\r | |
105 | */\r | |
106 | public ITmfFilterTreeNode getFilter() {\r | |
107 | return fFilter;\r | |
108 | }\r | |
109 | \r | |
110 | /**\r | |
111 | * @param filter the filter to set\r | |
112 | */\r | |
113 | public void setFilter(ITmfFilterTreeNode filter) {\r | |
114 | fFilter = filter;\r | |
115 | }\r | |
116 | \r | |
117 | /**\r | |
118 | * @return the foreground color\r | |
119 | */\r | |
120 | public Color getForegroundColor() {\r | |
121 | return fForegroundColor;\r | |
122 | }\r | |
123 | \r | |
124 | /**\r | |
125 | * @return the background color\r | |
126 | */\r | |
127 | public Color getBackgroundColor() {\r | |
128 | return fBackgroundColor;\r | |
129 | }\r | |
130 | \r | |
131 | /**\r | |
132 | * @return the dimmed foreground color\r | |
133 | */\r | |
134 | public Color getDimmedForegroundColor() {\r | |
135 | return fDimmedForegroundColor;\r | |
136 | }\r | |
137 | \r | |
138 | /**\r | |
139 | * @return the dimmed background color\r | |
140 | */\r | |
141 | public Color getDimmedBackgroundColor() {\r | |
142 | return fDimmedBackgroundColor;\r | |
143 | }\r | |
144 | \r | |
145 | }\r |