~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorSetting.java

  • Committer: Package Import Robot
  • Author(s): tony mancill
  • Date: 2013-05-13 21:43:22 UTC
  • mfrom: (1.2.1) (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130513214322-6frgd9du1n0w2uo7
Tags: 1.2.1-1
* Team upload.
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 * Copyright (c) 2010, 2012 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
 
 *   Bernd Hufmann - Updated to use RGB for the tick color
12
 
 *******************************************************************************/
13
 
 
14
 
package org.eclipse.linuxtools.tmf.ui.views.colors;
15
 
 
16
 
import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
17
 
import org.eclipse.swt.SWT;
18
 
import org.eclipse.swt.graphics.Color;
19
 
import org.eclipse.swt.graphics.RGB;
20
 
import org.eclipse.swt.widgets.Display;
21
 
import org.eclipse.ui.themes.ColorUtil;
22
 
 
23
 
/**
24
 
 * Class for storing color settings of a TMF filter.
25
 
 *
26
 
 * Application code must explicitly invoke the ColorSetting.dispose() method to release the operating system
27
 
 * resources managed by each instance when those instances are no longer required.
28
 
 *
29
 
 *  @version 1.0
30
 
 *  @author Patrick Tasse
31
 
 */
32
 
public class ColorSetting {
33
 
 
34
 
        private RGB fForegroundRGB;
35
 
        private RGB fBackgroundRGB;
36
 
        private RGB fTickColorRGB;
37
 
        private Color fForegroundColor;
38
 
        private Color fBackgroundColor;
39
 
        private Color fDimmedForegroundColor;
40
 
        private Color fDimmedBackgroundColor;
41
 
        private Color fTickColor;
42
 
        private ITmfFilterTreeNode fFilter;
43
 
 
44
 
            /**
45
 
     * Constructor
46
 
     *
47
 
     * You must dispose the color setting when it is no longer required.
48
 
     *
49
 
     * @param foreground
50
 
     *            The foreground color
51
 
     * @param background
52
 
     *            The background color
53
 
     * @param tickColorRGB
54
 
     *            The color for the checkbox ticks
55
 
     * @param filter
56
 
     *            The filter tree node
57
 
     */
58
 
        public ColorSetting(RGB foreground, RGB background, RGB tickColorRGB, ITmfFilterTreeNode filter) {
59
 
                fForegroundRGB = foreground;
60
 
                fBackgroundRGB = background;
61
 
                fTickColorRGB = tickColorRGB;
62
 
                fFilter = filter;
63
 
                Display display = Display.getDefault();
64
 
                fForegroundColor = new Color(display, fForegroundRGB);
65
 
                fBackgroundColor = new Color(display, fBackgroundRGB);
66
 
                fDimmedForegroundColor = new Color(display, ColorUtil.blend(
67
 
                                fForegroundRGB, fBackgroundRGB));
68
 
                fDimmedBackgroundColor = new Color(display, ColorUtil.blend(
69
 
                                fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));
70
 
                fTickColor = new Color(display, fTickColorRGB);
71
 
        }
72
 
 
73
 
        /**
74
 
         * Dispose the color setting resources
75
 
         */
76
 
        public void dispose() {
77
 
                fForegroundColor.dispose();
78
 
                fBackgroundColor.dispose();
79
 
                fDimmedForegroundColor.dispose();
80
 
                fDimmedBackgroundColor.dispose();
81
 
                fTickColor.dispose();
82
 
        }
83
 
 
84
 
        /**
85
 
         * Returns foreground RGB value.
86
 
         *
87
 
         * @return the foreground RGB
88
 
         */
89
 
        public RGB getForegroundRGB() {
90
 
                return fForegroundRGB;
91
 
        }
92
 
 
93
 
        /**
94
 
         * Sets the foreground RGB value
95
 
         *
96
 
         * @param foreground the foreground to set
97
 
         */
98
 
        public void setForegroundRGB(RGB foreground) {
99
 
                fForegroundRGB = foreground;
100
 
                fForegroundColor.dispose();
101
 
                fDimmedForegroundColor.dispose();
102
 
                Display display = Display.getDefault();
103
 
                fForegroundColor = new Color(display, fForegroundRGB);
104
 
                fDimmedForegroundColor = new Color(display, ColorUtil.blend(
105
 
                                fForegroundRGB, fBackgroundRGB));
106
 
        }
107
 
 
108
 
        /**
109
 
         * Returns the background RGB value.
110
 
         *
111
 
         * @return the background RGB
112
 
         */
113
 
        public RGB getBackgroundRGB() {
114
 
                return fBackgroundRGB;
115
 
        }
116
 
 
117
 
        /**
118
 
         * Sets the background RGB value.
119
 
         *
120
 
         * @param background the background to set
121
 
         */
122
 
        public void setBackgroundRGB(RGB background) {
123
 
                fBackgroundRGB = background;
124
 
                fBackgroundColor.dispose();
125
 
                fDimmedBackgroundColor.dispose();
126
 
                Display display = Display.getDefault();
127
 
                fBackgroundColor = new Color(display, fBackgroundRGB);
128
 
                fDimmedBackgroundColor = new Color(display, ColorUtil.blend(
129
 
                                fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));
130
 
        }
131
 
 
132
 
        /**
133
 
         * Returns the RGB of the tick color
134
 
         *
135
 
         * @return the RGB of the tick color
136
 
         */
137
 
        public RGB getTickColorRGB() {
138
 
                return fTickColorRGB;
139
 
        }
140
 
 
141
 
        /**
142
 
         * Sets the RGB of the tick color
143
 
         *
144
 
         * @param tickColorRGB the tick color TGB
145
 
         */
146
 
        public void setTickColorRGB(RGB tickColorRGB) {
147
 
               fTickColorRGB = tickColorRGB;
148
 
               fTickColor.dispose();
149
 
           Display display = Display.getDefault();
150
 
           fTickColor = new Color(display, fTickColorRGB);
151
 
        }
152
 
 
153
 
        /**
154
 
         * Returns the filter implementation.
155
 
         * @return the filter
156
 
         */
157
 
        public ITmfFilterTreeNode getFilter() {
158
 
                return fFilter;
159
 
        }
160
 
 
161
 
        /**
162
 
         * Sets the filter implementation.
163
 
         *
164
 
         * @param filter the filter to set
165
 
         */
166
 
        public void setFilter(ITmfFilterTreeNode filter) {
167
 
                fFilter = filter;
168
 
        }
169
 
 
170
 
        /**
171
 
         * Returns the foreground color.
172
 
         *
173
 
         * @return the foreground color
174
 
         */
175
 
        public Color getForegroundColor() {
176
 
                return fForegroundColor;
177
 
        }
178
 
 
179
 
        /**
180
 
         * Returns the background color.
181
 
         *
182
 
         * @return the background color
183
 
         */
184
 
        public Color getBackgroundColor() {
185
 
                return fBackgroundColor;
186
 
        }
187
 
 
188
 
        /**
189
 
         * Returns the dimmed foreground color.
190
 
         *
191
 
         * @return the dimmed foreground color
192
 
         */
193
 
        public Color getDimmedForegroundColor() {
194
 
                return fDimmedForegroundColor;
195
 
        }
196
 
 
197
 
        /**
198
 
         * Returns the dimmed background color.
199
 
         *
200
 
         * @return the dimmed background color
201
 
         */
202
 
        public Color getDimmedBackgroundColor() {
203
 
                return fDimmedBackgroundColor;
204
 
        }
205
 
 
206
 
        /**
207
 
         * Returns the tick color.
208
 
         *
209
 
         * @return the tick color
210
 
         */
211
 
        public Color getTickColor() {
212
 
        return fTickColor;
213
 
    }
214
 
}
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2010, 2012 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
 *   Bernd Hufmann - Updated to use RGB for the tick color
 
12
 *******************************************************************************/
 
13
 
 
14
package org.eclipse.linuxtools.tmf.ui.views.colors;
 
15
 
 
16
import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
 
17
import org.eclipse.swt.SWT;
 
18
import org.eclipse.swt.graphics.Color;
 
19
import org.eclipse.swt.graphics.RGB;
 
20
import org.eclipse.swt.widgets.Display;
 
21
import org.eclipse.ui.themes.ColorUtil;
 
22
 
 
23
/**
 
24
 * Class for storing color settings of a TMF filter.
 
25
 *
 
26
 * Application code must explicitly invoke the ColorSetting.dispose() method to release the operating system
 
27
 * resources managed by each instance when those instances are no longer required.
 
28
 *
 
29
 *  @version 1.0
 
30
 *  @author Patrick Tasse
 
31
 */
 
32
public class ColorSetting {
 
33
 
 
34
        private RGB fForegroundRGB;
 
35
        private RGB fBackgroundRGB;
 
36
        private RGB fTickColorRGB;
 
37
        private Color fForegroundColor;
 
38
        private Color fBackgroundColor;
 
39
        private Color fDimmedForegroundColor;
 
40
        private Color fDimmedBackgroundColor;
 
41
        private Color fTickColor;
 
42
        private ITmfFilterTreeNode fFilter;
 
43
 
 
44
            /**
 
45
     * Constructor
 
46
     *
 
47
     * You must dispose the color setting when it is no longer required.
 
48
     *
 
49
     * @param foreground
 
50
     *            The foreground color
 
51
     * @param background
 
52
     *            The background color
 
53
     * @param tickColorRGB
 
54
     *            The color for the checkbox ticks
 
55
     * @param filter
 
56
     *            The filter tree node
 
57
     */
 
58
        public ColorSetting(RGB foreground, RGB background, RGB tickColorRGB, ITmfFilterTreeNode filter) {
 
59
                fForegroundRGB = foreground;
 
60
                fBackgroundRGB = background;
 
61
                fTickColorRGB = tickColorRGB;
 
62
                fFilter = filter;
 
63
                Display display = Display.getDefault();
 
64
                fForegroundColor = new Color(display, fForegroundRGB);
 
65
                fBackgroundColor = new Color(display, fBackgroundRGB);
 
66
                fDimmedForegroundColor = new Color(display, ColorUtil.blend(
 
67
                                fForegroundRGB, fBackgroundRGB));
 
68
                fDimmedBackgroundColor = new Color(display, ColorUtil.blend(
 
69
                                fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));
 
70
                fTickColor = new Color(display, fTickColorRGB);
 
71
        }
 
72
 
 
73
        /**
 
74
         * Dispose the color setting resources
 
75
         */
 
76
        public void dispose() {
 
77
                fForegroundColor.dispose();
 
78
                fBackgroundColor.dispose();
 
79
                fDimmedForegroundColor.dispose();
 
80
                fDimmedBackgroundColor.dispose();
 
81
                fTickColor.dispose();
 
82
        }
 
83
 
 
84
        /**
 
85
         * Returns foreground RGB value.
 
86
         *
 
87
         * @return the foreground RGB
 
88
         */
 
89
        public RGB getForegroundRGB() {
 
90
                return fForegroundRGB;
 
91
        }
 
92
 
 
93
        /**
 
94
         * Sets the foreground RGB value
 
95
         *
 
96
         * @param foreground the foreground to set
 
97
         */
 
98
        public void setForegroundRGB(RGB foreground) {
 
99
                fForegroundRGB = foreground;
 
100
                fForegroundColor.dispose();
 
101
                fDimmedForegroundColor.dispose();
 
102
                Display display = Display.getDefault();
 
103
                fForegroundColor = new Color(display, fForegroundRGB);
 
104
                fDimmedForegroundColor = new Color(display, ColorUtil.blend(
 
105
                                fForegroundRGB, fBackgroundRGB));
 
106
        }
 
107
 
 
108
        /**
 
109
         * Returns the background RGB value.
 
110
         *
 
111
         * @return the background RGB
 
112
         */
 
113
        public RGB getBackgroundRGB() {
 
114
                return fBackgroundRGB;
 
115
        }
 
116
 
 
117
        /**
 
118
         * Sets the background RGB value.
 
119
         *
 
120
         * @param background the background to set
 
121
         */
 
122
        public void setBackgroundRGB(RGB background) {
 
123
                fBackgroundRGB = background;
 
124
                fBackgroundColor.dispose();
 
125
                fDimmedBackgroundColor.dispose();
 
126
                Display display = Display.getDefault();
 
127
                fBackgroundColor = new Color(display, fBackgroundRGB);
 
128
                fDimmedBackgroundColor = new Color(display, ColorUtil.blend(
 
129
                                fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));
 
130
        }
 
131
 
 
132
        /**
 
133
         * Returns the RGB of the tick color
 
134
         *
 
135
         * @return the RGB of the tick color
 
136
         */
 
137
        public RGB getTickColorRGB() {
 
138
                return fTickColorRGB;
 
139
        }
 
140
 
 
141
        /**
 
142
         * Sets the RGB of the tick color
 
143
         *
 
144
         * @param tickColorRGB the tick color TGB
 
145
         */
 
146
        public void setTickColorRGB(RGB tickColorRGB) {
 
147
               fTickColorRGB = tickColorRGB;
 
148
               fTickColor.dispose();
 
149
           Display display = Display.getDefault();
 
150
           fTickColor = new Color(display, fTickColorRGB);
 
151
        }
 
152
 
 
153
        /**
 
154
         * Returns the filter implementation.
 
155
         * @return the filter
 
156
         */
 
157
        public ITmfFilterTreeNode getFilter() {
 
158
                return fFilter;
 
159
        }
 
160
 
 
161
        /**
 
162
         * Sets the filter implementation.
 
163
         *
 
164
         * @param filter the filter to set
 
165
         */
 
166
        public void setFilter(ITmfFilterTreeNode filter) {
 
167
                fFilter = filter;
 
168
        }
 
169
 
 
170
        /**
 
171
         * Returns the foreground color.
 
172
         *
 
173
         * @return the foreground color
 
174
         */
 
175
        public Color getForegroundColor() {
 
176
                return fForegroundColor;
 
177
        }
 
178
 
 
179
        /**
 
180
         * Returns the background color.
 
181
         *
 
182
         * @return the background color
 
183
         */
 
184
        public Color getBackgroundColor() {
 
185
                return fBackgroundColor;
 
186
        }
 
187
 
 
188
        /**
 
189
         * Returns the dimmed foreground color.
 
190
         *
 
191
         * @return the dimmed foreground color
 
192
         */
 
193
        public Color getDimmedForegroundColor() {
 
194
                return fDimmedForegroundColor;
 
195
        }
 
196
 
 
197
        /**
 
198
         * Returns the dimmed background color.
 
199
         *
 
200
         * @return the dimmed background color
 
201
         */
 
202
        public Color getDimmedBackgroundColor() {
 
203
                return fDimmedBackgroundColor;
 
204
        }
 
205
 
 
206
        /**
 
207
         * Returns the tick color.
 
208
         *
 
209
         * @return the tick color
 
210
         */
 
211
        public Color getTickColor() {
 
212
        return fTickColor;
 
213
    }
 
214
}