diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/RGBBrightnessColorFactory.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/RGBBrightnessColorFactory.java new file mode 100644 index 0000000..7debcf2 --- /dev/null +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/themes/RGBBrightnessColorFactory.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * Copyright (c) 2013 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + ******************************************************************************/ + +package org.eclipse.ui.internal.themes; + +import java.util.Hashtable; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExecutableExtension; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.ui.themes.ColorUtil; +import org.eclipse.ui.themes.IColorFactory; + +/** + * @since 4.2 + * + */ +public class RGBBrightnessColorFactory implements IColorFactory, IExecutableExtension { + + String color, scaleFactor; + + /* (non-Javadoc) + * @see org.eclipse.ui.themes.IColorFactory#createColor() + */ + public RGB createColor() { + RGB finalRGB = new RGB(0, 0, 0); + try { + if (color != null && scaleFactor != null) { + RGB rgb = ColorUtil.getColorValue(color); + float scale = Float.parseFloat(scaleFactor); + float[] hsb = rgb.getHSB(); + hsb[2] *= scale; + if (hsb[2] < 0) + hsb[2] = 0; + if (hsb[2] > 255) + hsb[2] = 255; + finalRGB = new RGB(hsb[0], hsb[1], hsb[2]); + } + } catch (NumberFormatException ex) { + } + + return finalRGB; + } + + /** + * This executable extension requires parameters to be explicitly declared + * via the second method described in the IExecutableExtension + * documentation. This class expects that there will be two parameters, + * color that describe the color to be blended (this values may + * either be RGB triples or SWT constants) and scaleFactor + * which is the brightness scale factor with 1.0 having the same brightness + * as the original color. + * + * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, + * java.lang.String, java.lang.Object) + */ + public void setInitializationData(IConfigurationElement config, String propertyName, Object data) + throws CoreException { + if (data instanceof Hashtable) { + Hashtable table = (Hashtable) data; + color = (String) table.get("color"); //$NON-NLS-1$ + scaleFactor = (String) table.get("scaleFactor"); //$NON-NLS-1$ + } + } + +} diff --git a/bundles/org.eclipse.ui/plugin.xml b/bundles/org.eclipse.ui/plugin.xml index 07d785a..a08027e 100644 --- a/bundles/org.eclipse.ui/plugin.xml +++ b/bundles/org.eclipse.ui/plugin.xml @@ -1501,18 +1501,29 @@ + id="HYPERLINK_COLOR" + label="%Color.hyperlinkText"> %Color.hyperlinkTextDesc + + + + + + %Color.activeHyperlinkTextDesc