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 63137 Details for
Bug 180415
Implement "Kelvin Colours"
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 with some slight cleanup
patch180415.txt (text/plain), 14.20 KB, created by
Kevin McGuire
on 2007-04-05 22:33:18 EDT
(
hide
)
Description:
Patch with some slight cleanup
Filename:
MIME Type:
Creator:
Kevin McGuire
Created:
2007-04-05 22:33:18 EDT
Size:
14.20 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/themes/ColorSelectionFactory.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/themes/ColorSelectionFactory.java >diff -N Eclipse UI/org/eclipse/ui/internal/themes/ColorSelectionFactory.java >--- Eclipse UI/org/eclipse/ui/internal/themes/ColorSelectionFactory.java 21 Mar 2007 16:16:27 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,98 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 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.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; >- >-/** >- * ColorSelectionFactory is the abstract superclass of factories that compare >- * two colors. >- * >- * @since 3.3 >- * >- */ >-public abstract class ColorSelectionFactory implements IColorFactory, >- IExecutableExtension { >- >- String color1; >- String color2; >- >- /** >- * 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 two parameters, >- * <code>color1</code> and <code>color2</code>, that describe the two >- * colors to be compared. 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) { >- >- if (data instanceof Hashtable) { >- Hashtable table = (Hashtable) data; >- color1 = (String) table.get("color1"); //$NON-NLS-1$ >- color2 = (String) table.get("color2"); //$NON-NLS-1$ >- } >- } >- >- /** >- * Return the difference of the two >- * >- * @param rgb1 >- * @param rgb2 >- * @return int if the difference is positive rgb1 is darker, if negative >- * rgb2 is darker. >- */ >- protected int difference(RGB rgb1, RGB rgb2) { >- >- return (rgb1.blue - rgb2.blue) + (rgb1.red - rgb2.red) >- + (rgb1.green - rgb2.green); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.themes.IColorFactory#createColor() >- */ >- public RGB createColor() { >- if (color1 == null && color2 == null) { >- return new RGB(0, 0, 0); >- } else if (color1 != null && color2 == null) { >- return ColorUtil.getColorValue(color1); >- } else if (color1 == null && color2 != null) { >- return ColorUtil.getColorValue(color2); >- } else { >- RGB rgb1 = ColorUtil.getColorValue(color1); >- RGB rgb2 = ColorUtil.getColorValue(color2); >- return compare(rgb1, rgb2); >- } >- } >- >- /** >- * Compare the two {@link RGB} instances and return one of them. >- * >- * @param rgb1 >- * @param rgb2 >- * @return {@link RGB} >- */ >- abstract RGB compare(RGB rgb1, RGB rgb2); >- >-} >Index: Eclipse UI/org/eclipse/ui/internal/themes/LightColorSelectionFactory.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/themes/LightColorSelectionFactory.java >diff -N Eclipse UI/org/eclipse/ui/internal/themes/LightColorSelectionFactory.java >--- Eclipse UI/org/eclipse/ui/internal/themes/LightColorSelectionFactory.java 21 Mar 2007 16:16:27 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,35 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 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 org.eclipse.swt.graphics.RGB; >- >-/** >- * LightColorSelectionFactory is a factory that returns the lighter of two >- * {@link RGB} instances. >- * >- * @since 3.3 >- * >- */ >- >-public class LightColorSelectionFactory extends ColorSelectionFactory { >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.internal.themes.ColorSelectionFactory#compare(org.eclipse.swt.graphics.RGB, org.eclipse.swt.graphics.RGB) >- */ >- RGB compare(RGB rgb1, RGB rgb2) { >- if (difference(rgb1, rgb2) > 0) >- return rgb1; >- return rgb2; >- } >- >-} >Index: Eclipse UI/org/eclipse/ui/internal/themes/DarkColorSelectionFactory.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/themes/DarkColorSelectionFactory.java >diff -N Eclipse UI/org/eclipse/ui/internal/themes/DarkColorSelectionFactory.java >--- Eclipse UI/org/eclipse/ui/internal/themes/DarkColorSelectionFactory.java 21 Mar 2007 16:16:27 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,38 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2007 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 org.eclipse.swt.graphics.RGB; >- >-/** >- * DarkColorSelectionFactory is a factory that returns the darker of two >- * {@link RGB} instances. >- * >- * @since 3.3 >- * >- */ >- >-public class DarkColorSelectionFactory extends ColorSelectionFactory { >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.ui.internal.themes.ColorSelectionFactory#compare(org.eclipse.swt.graphics.RGB, >- * org.eclipse.swt.graphics.RGB) >- */ >- RGB compare(RGB rgb1, RGB rgb2) { >- if (difference(rgb1, rgb2) > 0) >- return rgb2; >- return rgb1; >- } >- >-} >Index: Eclipse UI/org/eclipse/ui/internal/themes/LightColorFactory.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/themes/LightColorFactory.java >diff -N Eclipse UI/org/eclipse/ui/internal/themes/LightColorFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/themes/LightColorFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,126 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 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.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; >+ >+/** >+ * LightColorFactory returns tab begin and end colours based on taking >+ * a system color as input, analyzing it, and lightening it appropriately. >+ * >+ * @since 3.3 >+ * >+ */ >+public class LightColorFactory implements IColorFactory, >+ IExecutableExtension { >+ >+ protected static final RGB white = new RGB(255, 255, 255); >+ >+ String baseColorName; >+ String definitionId; >+ >+ /** >+ * This executable extension requires parameters to be explicitly declared >+ * via the second method described in the <code>IExecutableExtension</code> >+ * documentation. The following parameters are parsed: >+ * <code>base</code>, describes the base color to produce all other colours from. >+ * This value may either be an RGB triple or an SWT constant. >+ * <code>definitionId</code>, describes the id of color we are looking for, one of >+ * "org.eclipse.ui.workbench.ACTIVE_TAB_BG_START" >+ * "org.eclipse.ui.workbench.ACTIVE_TAB_BG_END" >+ * @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) { >+ >+ if (data instanceof Hashtable) { >+ Hashtable table = (Hashtable) data; >+ baseColorName = (String) table.get("base"); //$NON-NLS-1$ >+ definitionId = (String) table.get("definitionId"); //$NON-NLS-1$ >+ } >+ } >+ >+ /* >+ * Return the number of RGB values in test that are >+ * equal to or between lower and upper. >+ */ >+ protected int valuesInRange(RGB test, int lower, int upper) { >+ int hits = 0; >+ if(test.red >= lower && test.red <= upper) hits++; >+ if(test.blue >= lower && test.blue <= upper) hits++; >+ if(test.green >= lower && test.green <= upper) hits++; >+ >+ return hits; >+ } >+ >+ /* >+ * Return the RGB value for the bottom tab color >+ * based on a blend of white and sample color >+ */ >+ private RGB getLightenedColor(RGB sample) { >+ //Group 1 >+ if(valuesInRange(sample, 180, 255) >= 2) >+ return sample; >+ >+ //Group 2 >+ if(valuesInRange(sample, 100, 179) >= 2) >+ return ColorUtil.blend(white, sample, 30); >+ >+ //Group 3 >+ if(valuesInRange(sample, 0, 99) >= 2) >+ return ColorUtil.blend(white, sample, 60); >+ >+ //Group 4 >+ return ColorUtil.blend(white, sample, 30); >+ } >+ >+ /* >+ * Return the Start (top of tab) color as an RGB >+ */ >+ private RGB createStartColor() { >+ return ColorUtil.blend(white, createEndColor(), 75); >+ } >+ >+ /* >+ * Return the End (top of tab) color as an RGB >+ */ >+ private RGB createEndColor() { >+ return getLightenedColor( >+ ColorUtil.getColorValue(baseColorName)); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.themes.IColorFactory#createColor() >+ */ >+ public RGB createColor() { >+ //should have base, otherwise error in the xml >+ if (baseColorName == null || definitionId == null) >+ return white; >+ >+ if (definitionId.equals("org.eclipse.ui.workbench.ACTIVE_TAB_BG_START")) //$NON-NLS-1$ >+ return createStartColor(); >+ if (definitionId.equals("org.eclipse.ui.workbench.ACTIVE_TAB_BG_END")) //$NON-NLS-1$ >+ return createEndColor(); >+ >+ //should be one of start or end, otherwise error in the xml >+ return white; >+ } >+} >#P org.eclipse.ui >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui/plugin.xml,v >retrieving revision 1.387 >diff -u -r1.387 plugin.xml >--- plugin.xml 21 Mar 2007 17:13:11 -0000 1.387 >+++ plugin.xml 6 Apr 2007 02:25:14 -0000 >@@ -1189,7 +1189,7 @@ > <colorDefinition > label="%Color.activeTabText" > categoryId="org.eclipse.ui.presentation.default" >- value="COLOR_TITLE_FOREGROUND" >+ value="COLOR_WIDGET_FOREGROUND" > id="org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR"> > <description> > %Color.activeTabTextDesc >@@ -1202,8 +1202,7 @@ > <colorDefinition > categoryId="org.eclipse.ui.presentation.default" > id="org.eclipse.ui.workbench.ACTIVE_TAB_BG_END" >- label="%Color.activeTabBGEnd" >- > >+ label="%Color.activeTabBGEnd"> > <description> > %Color.activeTabBGEndDesc > </description> >@@ -1212,15 +1211,13 @@ > value="COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT"> > </colorValue> > <colorFactory >- class="org.eclipse.ui.internal.themes.DarkColorSelectionFactory" >+ class="org.eclipse.ui.internal.themes.LightColorFactory" > plugin="org.eclipse.ui"> > <parameter >- name="color1" >- value="COLOR_TITLE_BACKGROUND_GRADIENT"> >+ name="base" value="COLOR_TITLE_BACKGROUND"> > </parameter> > <parameter >- name="color2" >- value="COLOR_TITLE_BACKGROUND"> >+ name="definitionId" value="org.eclipse.ui.workbench.ACTIVE_TAB_BG_END"> > </parameter> > </colorFactory> > </colorDefinition> >@@ -1236,16 +1233,14 @@ > value="COLOR_TITLE_INACTIVE_BACKGROUND"> > </colorValue> > <colorFactory >- class="org.eclipse.ui.internal.themes.LightColorSelectionFactory" >+ class="org.eclipse.ui.internal.themes.LightColorFactory" > plugin="org.eclipse.ui"> >- <parameter >- name="color1" >- value="COLOR_TITLE_BACKGROUND_GRADIENT"> >- </parameter> >- <parameter >- name="color2" >- value="COLOR_TITLE_BACKGROUND"> >- </parameter> >+ <parameter >+ name="base" value="COLOR_TITLE_BACKGROUND"> >+ </parameter> >+ <parameter >+ name="definitionId" value="org.eclipse.ui.workbench.ACTIVE_TAB_BG_START"> >+ </parameter> > </colorFactory> > </colorDefinition> > <!-- Active (Nofocus) Tab Colors -->
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 180415
:
62621
|
62622
|
62623
|
63093
| 63137 |
65989