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
.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
;
22 public class ColorSetting
{
24 private RGB fForegroundRGB
;
25 private RGB fBackgroundRGB
;
26 private Color fForegroundColor
;
27 private Color fBackgroundColor
;
28 private Color fDimmedForegroundColor
;
29 private Color fDimmedBackgroundColor
;
30 private int fTickColorIndex
;
31 private ITmfFilterTreeNode fFilter
;
33 public ColorSetting(RGB foreground
, RGB background
, int tickColorIndex
, ITmfFilterTreeNode filter
) {
34 fForegroundRGB
= foreground
;
35 fBackgroundRGB
= background
;
36 fTickColorIndex
= tickColorIndex
;
38 Display display
= Display
.getDefault();
39 fForegroundColor
= new Color(display
, fForegroundRGB
);
40 fBackgroundColor
= new Color(display
, fBackgroundRGB
);
41 fDimmedForegroundColor
= new Color(display
, ColorUtil
.blend(
42 fForegroundRGB
, fBackgroundRGB
));
43 fDimmedBackgroundColor
= new Color(display
, ColorUtil
.blend(
44 fBackgroundRGB
, display
.getSystemColor(SWT
.COLOR_LIST_BACKGROUND
).getRGB()));
48 * @return the foreground
50 public RGB
getForegroundRGB() {
51 return fForegroundRGB
;
55 * @param foreground the foreground to set
57 public void setForegroundRGB(RGB foreground
) {
58 fForegroundRGB
= foreground
;
59 fForegroundColor
.dispose();
60 fDimmedForegroundColor
.dispose();
61 Display display
= Display
.getDefault();
62 fForegroundColor
= new Color(display
, fForegroundRGB
);
63 fDimmedForegroundColor
= new Color(display
, ColorUtil
.blend(
64 fForegroundRGB
, fBackgroundRGB
));
68 * @return the background
70 public RGB
getBackgroundRGB() {
71 return fBackgroundRGB
;
75 * @param background the background to set
77 public void setBackgroundRGB(RGB background
) {
78 fBackgroundRGB
= background
;
79 fBackgroundColor
.dispose();
80 fDimmedBackgroundColor
.dispose();
81 Display display
= Display
.getDefault();
82 fBackgroundColor
= new Color(display
, fBackgroundRGB
);
83 fDimmedBackgroundColor
= new Color(display
, ColorUtil
.blend(
84 fBackgroundRGB
, display
.getSystemColor(SWT
.COLOR_LIST_BACKGROUND
).getRGB()));
88 * @return the tick color index (0-15)
89 * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme
91 public int getTickColorIndex() {
92 return fTickColorIndex
;
96 * @param tickColorIndex the tick color index to set (0-15)
97 * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme
99 public void setTickColorIndex(int tickColorIndex
) {
100 fTickColorIndex
= tickColorIndex
;
106 public ITmfFilterTreeNode
getFilter() {
111 * @param filter the filter to set
113 public void setFilter(ITmfFilterTreeNode filter
) {
118 * @return the foreground color
120 public Color
getForegroundColor() {
121 return fForegroundColor
;
125 * @return the background color
127 public Color
getBackgroundColor() {
128 return fBackgroundColor
;
132 * @return the dimmed foreground color
134 public Color
getDimmedForegroundColor() {
135 return fDimmedForegroundColor
;
139 * @return the dimmed background color
141 public Color
getDimmedBackgroundColor() {
142 return fDimmedBackgroundColor
;