-/*******************************************************************************\r
- * Copyright (c) 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- * Patrick Tasse - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.views.colors;\r
-\r
-import org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.RGB;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.ui.themes.ColorUtil;\r
-\r
-/**\r
- * Application code must explicitly invoke the ColorSetting.dispose() method to release the operating system\r
- * resources managed by each instance when those instances are no longer required. \r
- */\r
-\r
-public class ColorSetting {\r
-\r
- private RGB fForegroundRGB;\r
- private RGB fBackgroundRGB;\r
- private Color fForegroundColor;\r
- private Color fBackgroundColor;\r
- private Color fDimmedForegroundColor;\r
- private Color fDimmedBackgroundColor;\r
- private int fTickColorIndex;\r
- private ITmfFilterTreeNode fFilter;\r
- \r
- /**\r
- * You must dispose the color setting when it is no longer required.\r
- */\r
- public ColorSetting(RGB foreground, RGB background, int tickColorIndex, ITmfFilterTreeNode filter) {\r
- fForegroundRGB = foreground;\r
- fBackgroundRGB = background;\r
- fTickColorIndex = tickColorIndex;\r
- fFilter = filter;\r
- Display display = Display.getDefault();\r
- fForegroundColor = new Color(display, fForegroundRGB);\r
- fBackgroundColor = new Color(display, fBackgroundRGB);\r
- fDimmedForegroundColor = new Color(display, ColorUtil.blend(\r
- fForegroundRGB, fBackgroundRGB));\r
- fDimmedBackgroundColor = new Color(display, ColorUtil.blend(\r
- fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));\r
- }\r
- \r
- /**\r
- * Dispose the color setting resources\r
- */\r
- public void dispose() {\r
- fForegroundColor.dispose();\r
- fBackgroundColor.dispose();\r
- fDimmedForegroundColor.dispose();\r
- fDimmedBackgroundColor.dispose();\r
- }\r
- \r
- /**\r
- * @return the foreground\r
- */\r
- public RGB getForegroundRGB() {\r
- return fForegroundRGB;\r
- }\r
- \r
- /**\r
- * @param foreground the foreground to set\r
- */\r
- public void setForegroundRGB(RGB foreground) {\r
- fForegroundRGB = foreground;\r
- fForegroundColor.dispose();\r
- fDimmedForegroundColor.dispose();\r
- Display display = Display.getDefault();\r
- fForegroundColor = new Color(display, fForegroundRGB);\r
- fDimmedForegroundColor = new Color(display, ColorUtil.blend(\r
- fForegroundRGB, fBackgroundRGB));\r
- }\r
- \r
- /**\r
- * @return the background\r
- */\r
- public RGB getBackgroundRGB() {\r
- return fBackgroundRGB;\r
- }\r
- \r
- /**\r
- * @param background the background to set\r
- */\r
- public void setBackgroundRGB(RGB background) {\r
- fBackgroundRGB = background;\r
- fBackgroundColor.dispose();\r
- fDimmedBackgroundColor.dispose();\r
- Display display = Display.getDefault();\r
- fBackgroundColor = new Color(display, fBackgroundRGB);\r
- fDimmedBackgroundColor = new Color(display, ColorUtil.blend(\r
- fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));\r
- }\r
- \r
- /**\r
- * @return the tick color index (0-15)\r
- * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme\r
- */\r
- public int getTickColorIndex() {\r
- return fTickColorIndex;\r
- }\r
- \r
- /**\r
- * @param tickColorIndex the tick color index to set (0-15)\r
- * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme\r
- */\r
- public void setTickColorIndex(int tickColorIndex) {\r
- fTickColorIndex = tickColorIndex;\r
- }\r
- \r
- /**\r
- * @return the filter\r
- */\r
- public ITmfFilterTreeNode getFilter() {\r
- return fFilter;\r
- }\r
- \r
- /**\r
- * @param filter the filter to set\r
- */\r
- public void setFilter(ITmfFilterTreeNode filter) {\r
- fFilter = filter;\r
- }\r
-\r
- /**\r
- * @return the foreground color\r
- */\r
- public Color getForegroundColor() {\r
- return fForegroundColor;\r
- }\r
-\r
- /**\r
- * @return the background color\r
- */\r
- public Color getBackgroundColor() {\r
- return fBackgroundColor;\r
- }\r
-\r
- /**\r
- * @return the dimmed foreground color\r
- */\r
- public Color getDimmedForegroundColor() {\r
- return fDimmedForegroundColor;\r
- }\r
-\r
- /**\r
- * @return the dimmed background color\r
- */\r
- public Color getDimmedBackgroundColor() {\r
- return fDimmedBackgroundColor;\r
- }\r
- \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2010, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tasse - Initial API and implementation
+ * Bernd Hufmann - Updated to use RGB for the tick color
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.views.colors;
+
+import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.themes.ColorUtil;
+
+/**
+ * Class for storing color settings of a TMF filter.
+ *
+ * Application code must explicitly invoke the ColorSetting.dispose() method to release the operating system
+ * resources managed by each instance when those instances are no longer required.
+ *
+ * @version 1.0
+ * @author Patrick Tasse
+ */
+public class ColorSetting {
+
+ private RGB fForegroundRGB;
+ private RGB fBackgroundRGB;
+ private RGB fTickColorRGB;
+ private Color fForegroundColor;
+ private Color fBackgroundColor;
+ private Color fDimmedForegroundColor;
+ private Color fDimmedBackgroundColor;
+ private Color fTickColor;
+ private ITmfFilterTreeNode fFilter;
+
+ /**
+ * Constructor
+ *
+ * You must dispose the color setting when it is no longer required.
+ *
+ * @param foreground
+ * The foreground color
+ * @param background
+ * The background color
+ * @param tickColorRGB
+ * The color for the checkbox ticks
+ * @param filter
+ * The filter tree node
+ */
+ public ColorSetting(RGB foreground, RGB background, RGB tickColorRGB, ITmfFilterTreeNode filter) {
+ fForegroundRGB = foreground;
+ fBackgroundRGB = background;
+ fTickColorRGB = tickColorRGB;
+ fFilter = filter;
+ Display display = Display.getDefault();
+ fForegroundColor = new Color(display, fForegroundRGB);
+ fBackgroundColor = new Color(display, fBackgroundRGB);
+ fDimmedForegroundColor = new Color(display, ColorUtil.blend(
+ fForegroundRGB, fBackgroundRGB));
+ fDimmedBackgroundColor = new Color(display, ColorUtil.blend(
+ fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));
+ fTickColor = new Color(display, fTickColorRGB);
+ }
+
+ /**
+ * Dispose the color setting resources
+ */
+ public void dispose() {
+ fForegroundColor.dispose();
+ fBackgroundColor.dispose();
+ fDimmedForegroundColor.dispose();
+ fDimmedBackgroundColor.dispose();
+ fTickColor.dispose();
+ }
+
+ /**
+ * Returns foreground RGB value.
+ *
+ * @return the foreground RGB
+ */
+ public RGB getForegroundRGB() {
+ return fForegroundRGB;
+ }
+
+ /**
+ * Sets the foreground RGB value
+ *
+ * @param foreground the foreground to set
+ */
+ public void setForegroundRGB(RGB foreground) {
+ fForegroundRGB = foreground;
+ fForegroundColor.dispose();
+ fDimmedForegroundColor.dispose();
+ Display display = Display.getDefault();
+ fForegroundColor = new Color(display, fForegroundRGB);
+ fDimmedForegroundColor = new Color(display, ColorUtil.blend(
+ fForegroundRGB, fBackgroundRGB));
+ }
+
+ /**
+ * Returns the background RGB value.
+ *
+ * @return the background RGB
+ */
+ public RGB getBackgroundRGB() {
+ return fBackgroundRGB;
+ }
+
+ /**
+ * Sets the background RGB value.
+ *
+ * @param background the background to set
+ */
+ public void setBackgroundRGB(RGB background) {
+ fBackgroundRGB = background;
+ fBackgroundColor.dispose();
+ fDimmedBackgroundColor.dispose();
+ Display display = Display.getDefault();
+ fBackgroundColor = new Color(display, fBackgroundRGB);
+ fDimmedBackgroundColor = new Color(display, ColorUtil.blend(
+ fBackgroundRGB, display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB()));
+ }
+
+ /**
+ * Returns the RGB of the tick color
+ *
+ * @return the RGB of the tick color
+ */
+ public RGB getTickColorRGB() {
+ return fTickColorRGB;
+ }
+
+ /**
+ * Sets the RGB of the tick color
+ *
+ * @param tickColorRGB the tick color TGB
+ */
+ public void setTickColorRGB(RGB tickColorRGB) {
+ fTickColorRGB = tickColorRGB;
+ fTickColor.dispose();
+ Display display = Display.getDefault();
+ fTickColor = new Color(display, fTickColorRGB);
+ }
+
+ /**
+ * Returns the filter implementation.
+ * @return the filter
+ */
+ public ITmfFilterTreeNode getFilter() {
+ return fFilter;
+ }
+
+ /**
+ * Sets the filter implementation.
+ *
+ * @param filter the filter to set
+ */
+ public void setFilter(ITmfFilterTreeNode filter) {
+ fFilter = filter;
+ }
+
+ /**
+ * Returns the foreground color.
+ *
+ * @return the foreground color
+ */
+ public Color getForegroundColor() {
+ return fForegroundColor;
+ }
+
+ /**
+ * Returns the background color.
+ *
+ * @return the background color
+ */
+ public Color getBackgroundColor() {
+ return fBackgroundColor;
+ }
+
+ /**
+ * Returns the dimmed foreground color.
+ *
+ * @return the dimmed foreground color
+ */
+ public Color getDimmedForegroundColor() {
+ return fDimmedForegroundColor;
+ }
+
+ /**
+ * Returns the dimmed background color.
+ *
+ * @return the dimmed background color
+ */
+ public Color getDimmedBackgroundColor() {
+ return fDimmedBackgroundColor;
+ }
+
+ /**
+ * Returns the tick color.
+ *
+ * @return the tick color
+ */
+ public Color getTickColor() {
+ return fTickColor;
+ }
+}