Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 11217 Details for
Bug 55750
Workbench colors need OS specific tweaks, e.g. unselected tabs cannot be read on Solaris
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to add RGBContrastFactory
contrast-factory.diff (text/plain), 5.87 KB, created by
Billy Biggs
on 2004-05-27 12:48:24 EDT
(
hide
)
Description:
Patch to add RGBContrastFactory
Filename:
MIME Type:
Creator:
Billy Biggs
Created:
2004-05-27 12:48:24 EDT
Size:
5.87 KB
patch
obsolete
>Index: Eclipse UI/org/eclipse/ui/internal/themes/RGBContrastFactory.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/themes/RGBContrastFactory.java >diff -N Eclipse UI/org/eclipse/ui/internal/themes/RGBContrastFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/themes/RGBContrastFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,150 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Common Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/cpl-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.IColorFactory; >+ >+ >+/** >+ * A <code>IColorFactory</code> that may be used to select a colour with >+ * a higher contrast. The colors to blend are specified as per method >+ * number two in {@link org.eclipse.core.runtime.IExecutableExtension}. >+ * <p> >+ * Example usage: >+ * <br/> >+ * <code> >+ * <colorDefinition >+ * label="Red/Blue Contrast" >+ * id="example.redblueblend"> >+ * <colorFactory >+ * plugin="org.eclipse.ui" >+ * class="org.eclipse.ui.internal.themes.RGBContrastFactory"> >+ * <parameter name="foreground" value="0,0,0" /> >+ * <parameter name="background1" value="COLOR_RED" /> >+ * <parameter name="background2" value="COLOR_BLUE" /> >+ * </colorFactory> >+ * </colorDefinition> >+ * </code> >+ * </p> >+ * >+ * <p> >+ * This will select whichever of Red or Blue has a higher contrst with black. >+ * The color values may be specified as RGB triples or as SWT constants. >+ * </p> >+ * >+ * @see org.eclipse.swt.SWT >+ * @since 3.0 >+ */ >+public class RGBContrastFactory implements IColorFactory, IExecutableExtension { >+ private String fg, bg1, bg2; >+ >+ /** >+ * Returns the intensity of an RGB component using the >+ * sRGB gamma function. >+ * >+ * @param val Value to convert. >+ * @return Light intensity of the component. >+ */ >+ double voltage_to_intensity_srgb( double val ) { >+ /* Handle invalid values before doing a gamma transform. */ >+ if( val < 0.0 ) return 0.0; >+ if( val > 1.0 ) return 1.0; >+ >+ if( val <= 0.04045 ) { >+ return val / 12.92; >+ } >+ return Math.pow( ( val + 0.055 ) / 1.055, 2.4 ); >+ } >+ >+ /** >+ * Returns a measure of the lightness in the perceptual colourspace >+ * IPT. >+ * >+ * @param color The colour in sRGB >+ * @return Lightness in IPT space. >+ */ >+ double lightness( RGB color ) { >+ double r = voltage_to_intensity_srgb( color.red / 255.0 ); >+ double g = voltage_to_intensity_srgb( color.green / 255.0 ); >+ double b = voltage_to_intensity_srgb( color.blue / 255.0 ); >+ double l = (0.3139 * r) + (0.6395 * g) + (0.0466 * b); >+ double m = (0.1516 * r) + (0.7482 * g) + (0.1000 * b); >+ double s = (0.0177 * r) + (0.1095 * g) + (0.8729 * b); >+ double lp, mp, sp; >+ >+ if( l < 0.0 ) lp = -Math.pow( -l, 0.43 ); else lp = Math.pow( l, 0.43 ); >+ if( m < 0.0 ) mp = -Math.pow( -m, 0.43 ); else mp = Math.pow( m, 0.43 ); >+ if( s < 0.0 ) sp = -Math.pow( -s, 0.43 ); else sp = Math.pow( s, 0.43 ); >+ >+ return (0.4000 * lp) + (0.4000 *mp) + (0.2000 * sp); >+ } >+ >+ public RGB createColor() { >+ /** >+ * Determine which pair has a higher contrast by selecting >+ * the colour with the furthest distance in lightness. >+ */ >+ RGB cfg, cbg1, cbg2; >+ >+ if( fg != null ) { >+ cfg = ColorUtils.getColorValue( fg ); >+ } else { >+ cfg = new RGB(255,255,255); >+ } >+ if( bg1 != null ) { >+ cbg1 = ColorUtils.getColorValue( bg1 ); >+ } else { >+ cbg1 = new RGB(0, 0, 0); >+ } >+ if( bg2 != null ) { >+ cbg2 = ColorUtils.getColorValue( bg2 ); >+ } else { >+ cbg2 = new RGB(0, 0, 0); >+ } >+ >+ double lfg = lightness( cfg ); >+ double lbg1 = lightness( cbg1 ); >+ double lbg2 = lightness( cbg2 ); >+ >+ if( Math.abs(lbg1 - lfg) > Math.abs(lbg2 - lfg) ) { >+ return cbg1; >+ } else { >+ return cbg2; >+ } >+ } >+ >+ /** >+ * This executable extension requires parameters to be explicitly declared >+ * via the second method described in the <code>IExecutableExtension</code> >+ * documentation. This class expects that there will be three parameters, >+ * <code>foreground</code>, <code>background1</code> and >+ * <code>background2</code>, that describe the two colors to be blended. >+ * These values may either be RGB triples or SWT constants. >+ * >+ * @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; >+ fg = (String) table.get("foreground"); //$NON-NLS-1$ >+ bg1 = (String) table.get("background1"); //$NON-NLS-1$ >+ bg2 = (String) table.get("background2"); //$NON-NLS-1$ >+ } >+ >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 55750
: 11217 |
11218