1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
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
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.colors
;
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
;
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.
27 public class ColorSetting
{
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
;
39 * You must dispose the color setting when it is no longer required.
41 public ColorSetting(RGB foreground
, RGB background
, int tickColorIndex
, ITmfFilterTreeNode filter
) {
42 fForegroundRGB
= foreground
;
43 fBackgroundRGB
= background
;
44 fTickColorIndex
= tickColorIndex
;
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()));
56 * Dispose the color setting resources
58 public void dispose() {
59 fForegroundColor
.dispose();
60 fBackgroundColor
.dispose();
61 fDimmedForegroundColor
.dispose();
62 fDimmedBackgroundColor
.dispose();
66 * @return the foreground
68 public RGB
getForegroundRGB() {
69 return fForegroundRGB
;
73 * @param foreground the foreground to set
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
));
86 * @return the background
88 public RGB
getBackgroundRGB() {
89 return fBackgroundRGB
;
93 * @param background the background to set
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()));
106 * @return the tick color index (0-15)
107 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme
109 public int getTickColorIndex() {
110 return fTickColorIndex
;
114 * @param tickColorIndex the tick color index to set (0-15)
115 * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme
117 public void setTickColorIndex(int tickColorIndex
) {
118 fTickColorIndex
= tickColorIndex
;
124 public ITmfFilterTreeNode
getFilter() {
129 * @param filter the filter to set
131 public void setFilter(ITmfFilterTreeNode filter
) {
136 * @return the foreground color
138 public Color
getForegroundColor() {
139 return fForegroundColor
;
143 * @return the background color
145 public Color
getBackgroundColor() {
146 return fBackgroundColor
;
150 * @return the dimmed foreground color
152 public Color
getDimmedForegroundColor() {
153 return fDimmedForegroundColor
;
157 * @return the dimmed background color
159 public Color
getDimmedBackgroundColor() {
160 return fDimmedBackgroundColor
;