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 | |
6c13869b | 15 | import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;\r |
ca13a91c FC |
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 | |
5d862cfc FC |
22 | /**\r |
23 | * Application code must explicitly invoke the ColorSetting.dispose() method to release the operating system\r | |
24 | * resources managed by each instance when those instances are no longer required. \r | |
25 | */\r | |
26 | \r | |
ca13a91c FC |
27 | public class ColorSetting {\r |
28 | \r | |
29 | private RGB fForegroundRGB;\r | |
30 | private RGB fBackgroundRGB;\r | |
31 | private Color fForegroundColor;\r | |
32 | private Color fBackgroundColor;\r | |
33 | private Color fDimmedForegroundColor;\r | |
34 | private Color fDimmedBackgroundColor;\r | |
35 | private int fTickColorIndex;\r | |
36 | private ITmfFilterTreeNode fFilter;\r | |
37 | \r | |
5d862cfc FC |
38 | /**\r |
39 | * You must dispose the color setting when it is no longer required.\r | |
40 | */\r | |
ca13a91c FC |
41 | public ColorSetting(RGB foreground, RGB background, int tickColorIndex, ITmfFilterTreeNode filter) {\r |
42 | fForegroundRGB = foreground;\r | |
43 | fBackgroundRGB = background;\r | |
44 | fTickColorIndex = tickColorIndex;\r | |
45 | fFilter = filter;\r | |
46 | Display display = Display.getDefault();\r | |
47 | fForegroundColor = new Color(display, fForegroundRGB);\r | |
48 | fBackgroundColor = new Color(display, fBackgroundRGB);\r | |
49 | fDimmedForegroundColor = new Color(display, ColorUtil.blend(\r | |
50 | fForegroundRGB, fBackgroundRGB));\r | |
51 | fDimmedBackgroundColor = new Color(display, ColorUtil.blend(\r | |
52 | fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));\r | |
53 | }\r | |
54 | \r | |
5d862cfc FC |
55 | /**\r |
56 | * Dispose the color setting resources\r | |
57 | */\r | |
58 | public void dispose() {\r | |
59 | fForegroundColor.dispose();\r | |
60 | fBackgroundColor.dispose();\r | |
61 | fDimmedForegroundColor.dispose();\r | |
62 | fDimmedBackgroundColor.dispose();\r | |
63 | }\r | |
64 | \r | |
ca13a91c FC |
65 | /**\r |
66 | * @return the foreground\r | |
67 | */\r | |
68 | public RGB getForegroundRGB() {\r | |
69 | return fForegroundRGB;\r | |
70 | }\r | |
71 | \r | |
72 | /**\r | |
73 | * @param foreground the foreground to set\r | |
74 | */\r | |
75 | public void setForegroundRGB(RGB foreground) {\r | |
76 | fForegroundRGB = foreground;\r | |
77 | fForegroundColor.dispose();\r | |
78 | fDimmedForegroundColor.dispose();\r | |
79 | Display display = Display.getDefault();\r | |
80 | fForegroundColor = new Color(display, fForegroundRGB);\r | |
81 | fDimmedForegroundColor = new Color(display, ColorUtil.blend(\r | |
82 | fForegroundRGB, fBackgroundRGB));\r | |
83 | }\r | |
84 | \r | |
85 | /**\r | |
86 | * @return the background\r | |
87 | */\r | |
88 | public RGB getBackgroundRGB() {\r | |
89 | return fBackgroundRGB;\r | |
90 | }\r | |
91 | \r | |
92 | /**\r | |
93 | * @param background the background to set\r | |
94 | */\r | |
95 | public void setBackgroundRGB(RGB background) {\r | |
96 | fBackgroundRGB = background;\r | |
97 | fBackgroundColor.dispose();\r | |
98 | fDimmedBackgroundColor.dispose();\r | |
99 | Display display = Display.getDefault();\r | |
100 | fBackgroundColor = new Color(display, fBackgroundRGB);\r | |
101 | fDimmedBackgroundColor = new Color(display, ColorUtil.blend(\r | |
102 | fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));\r | |
103 | }\r | |
104 | \r | |
105 | /**\r | |
106 | * @return the tick color index (0-15)\r | |
107 | * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme\r | |
108 | */\r | |
109 | public int getTickColorIndex() {\r | |
110 | return fTickColorIndex;\r | |
111 | }\r | |
112 | \r | |
113 | /**\r | |
114 | * @param tickColorIndex the tick color index to set (0-15)\r | |
115 | * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme\r | |
116 | */\r | |
117 | public void setTickColorIndex(int tickColorIndex) {\r | |
118 | fTickColorIndex = tickColorIndex;\r | |
119 | }\r | |
120 | \r | |
121 | /**\r | |
122 | * @return the filter\r | |
123 | */\r | |
124 | public ITmfFilterTreeNode getFilter() {\r | |
125 | return fFilter;\r | |
126 | }\r | |
127 | \r | |
128 | /**\r | |
129 | * @param filter the filter to set\r | |
130 | */\r | |
131 | public void setFilter(ITmfFilterTreeNode filter) {\r | |
132 | fFilter = filter;\r | |
133 | }\r | |
134 | \r | |
135 | /**\r | |
136 | * @return the foreground color\r | |
137 | */\r | |
138 | public Color getForegroundColor() {\r | |
139 | return fForegroundColor;\r | |
140 | }\r | |
141 | \r | |
142 | /**\r | |
143 | * @return the background color\r | |
144 | */\r | |
145 | public Color getBackgroundColor() {\r | |
146 | return fBackgroundColor;\r | |
147 | }\r | |
148 | \r | |
149 | /**\r | |
150 | * @return the dimmed foreground color\r | |
151 | */\r | |
152 | public Color getDimmedForegroundColor() {\r | |
153 | return fDimmedForegroundColor;\r | |
154 | }\r | |
155 | \r | |
156 | /**\r | |
157 | * @return the dimmed background color\r | |
158 | */\r | |
159 | public Color getDimmedBackgroundColor() {\r | |
160 | return fDimmedBackgroundColor;\r | |
161 | }\r | |
162 | \r | |
163 | }\r |