View | Details | Raw Unified | Return to bug 163335 | Differences between
and this patch

Collapse All | Expand All

(-)a/bundles/org.eclipse.ui.workbench/Eclipse (+74 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2013 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
12
package org.eclipse.ui.internal.themes;
13
14
import java.util.Hashtable;
15
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.IConfigurationElement;
17
import org.eclipse.core.runtime.IExecutableExtension;
18
import org.eclipse.swt.graphics.RGB;
19
import org.eclipse.ui.themes.ColorUtil;
20
import org.eclipse.ui.themes.IColorFactory;
21
22
/**
23
 * @since 4.2
24
 * 
25
 */
26
public class RGBBrightnessColorFactory implements IColorFactory, IExecutableExtension {
27
28
	String color, scaleFactor;
29
30
	/* (non-Javadoc)
31
	 * @see org.eclipse.ui.themes.IColorFactory#createColor()
32
	 */
33
	public RGB createColor() {
34
		RGB finalRGB = new RGB(0, 0, 0);
35
		try {
36
		if (color != null && scaleFactor != null) {
37
				RGB rgb = ColorUtil.getColorValue(color);
38
			float scale = Float.parseFloat(scaleFactor);
39
			float[] hsb = rgb.getHSB();
40
				hsb[2] *= scale;
41
			if (hsb[2] < 0)
42
				hsb[2] = 0;
43
			if (hsb[2] > 255)
44
				hsb[2] = 255;
45
				finalRGB = new RGB(hsb[0], hsb[1], hsb[2]);
46
		}
47
		} catch (NumberFormatException ex) {
48
		}
49
50
		return finalRGB;
51
	}
52
53
	/**
54
	 * This executable extension requires parameters to be explicitly declared
55
	 * via the second method described in the <code>IExecutableExtension</code>
56
	 * documentation. This class expects that there will be two parameters,
57
	 * <code>color</code> that describe the color to be blended (this values may
58
	 * either be RGB triples or SWT constants) and <code>scaleFactor</code>
59
	 * which is the brightness scale factor with 1.0 having the same brightness
60
	 * as the original color.
61
	 * 
62
	 * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement,
63
	 *      java.lang.String, java.lang.Object)
64
	 */
65
	public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
66
			throws CoreException {
67
		if (data instanceof Hashtable) {
68
			Hashtable table = (Hashtable) data;
69
			color = (String) table.get("color"); //$NON-NLS-1$
70
			scaleFactor = (String) table.get("scaleFactor"); //$NON-NLS-1$            
71
		}
72
	}
73
74
}
(-)a/bundles/org.eclipse.ui/plugin.xml (-4 / +15 lines)
Lines 1501-1518 Link Here
1501
         </description>
1501
         </description>
1502
      </colorDefinition>
1502
      </colorDefinition>
1503
      <colorDefinition
1503
      <colorDefinition
1504
            label="%Color.hyperlinkText"
1505
            categoryId="org.eclipse.ui.workbenchMisc"
1504
            categoryId="org.eclipse.ui.workbenchMisc"
1506
            value="COLOR_DARK_BLUE"
1505
            id="HYPERLINK_COLOR"
1507
            id="HYPERLINK_COLOR">
1506
            label="%Color.hyperlinkText">
1508
         <description>
1507
         <description>
1509
            %Color.hyperlinkTextDesc
1508
            %Color.hyperlinkTextDesc
1510
         </description>
1509
         </description>
1510
         <colorFactory
1511
               class="org.eclipse.ui.internal.themes.RGBBrightnessColorFactory"
1512
               plugin="org.eclipse.ui">
1513
            <parameter
1514
                  name="color"
1515
                  value="COLOR_LINK_FOREGROUND">
1516
            </parameter>
1517
            <parameter
1518
                  name="scaleFactor"
1519
                  value="0.7">
1520
            </parameter>
1521
         </colorFactory>
1511
      </colorDefinition>
1522
      </colorDefinition>
1512
      <colorDefinition
1523
      <colorDefinition
1513
            label="%Color.activeHyperlinkText"
1524
            label="%Color.activeHyperlinkText"
1514
            categoryId="org.eclipse.ui.workbenchMisc"
1525
            categoryId="org.eclipse.ui.workbenchMisc"
1515
            value="COLOR_BLUE"
1526
            value="COLOR_LINK_FOREGROUND"
1516
            id="ACTIVE_HYPERLINK_COLOR">
1527
            id="ACTIVE_HYPERLINK_COLOR">
1517
         <description>
1528
         <description>
1518
            %Color.activeHyperlinkTextDesc
1529
            %Color.activeHyperlinkTextDesc

Return to bug 163335