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