1 11 package org.eclipse.ui.internal.presentations.r21; 12 13 import java.util.HashMap ; 14 import java.util.Iterator ; 15 16 import org.eclipse.core.runtime.Assert; 17 import org.eclipse.swt.SWT; 18 import org.eclipse.swt.graphics.Color; 19 import org.eclipse.swt.graphics.RGB; 20 import org.eclipse.swt.widgets.Display; 21 22 25 public class R21Colors { 26 27 static private boolean init = false; 28 29 static private HashMap colorMap; 30 31 static private HashMap systemColorMap; 32 33 static private Color workbenchColors[]; 34 35 static private Color[] activeViewGradient; 36 37 static private Color[] deactivatedViewGradient; 38 39 static private Color[] activeEditorGradient; 40 41 static private Color[] activeNoFocusEditorGradient; 42 43 static private Color[] deactivatedEditorGradient; 44 45 static private int[] activeViewPercentages; 46 47 static private int[] deactivatedViewPercentages; 48 49 static private int[] activeEditorPercentages; 50 51 static private int[] activeNoFocusEditorPercentages; 52 53 static private int[] deactivatedEditorPercentages; 54 55 static private final String CLR_VIEW_GRAD_START = "clrViewGradStart"; 57 static private final String CLR_VIEW_GRAD_END = "clrViewGradEnd"; 59 static private final String CLR_EDITOR_GRAD_START = "clrEditorGradStart"; 61 static private final String CLR_EDITOR_GRAD_END = "clrEditorGradEnd"; 63 66 private static void disposeWorkbenchColors() { 67 for (int i = 0; i < workbenchColors.length; i++) { 68 workbenchColors[i].dispose(); 69 } 70 } 71 72 75 static public Color[] getActiveEditorGradient() { 76 return activeEditorGradient; 77 } 78 79 82 static public Color getActiveEditorGradientEnd() { 83 Color clr = (Color) systemColorMap.get(CLR_EDITOR_GRAD_END); 84 Assert.isNotNull(clr); 85 return clr; 86 } 87 88 91 static public int[] getActiveEditorGradientPercents() { 92 return activeEditorPercentages; 93 } 94 95 98 static public Color getActiveEditorGradientStart() { 99 Color clr = (Color) systemColorMap.get(CLR_EDITOR_GRAD_START); 100 Assert.isNotNull(clr); 101 return clr; 102 } 103 104 107 static public Color[] getActiveNoFocusEditorGradient() { 108 return activeNoFocusEditorGradient; 109 } 110 111 114 static public int[] getActiveNoFocusEditorGradientPercents() { 115 return activeNoFocusEditorPercentages; 116 } 117 118 121 static public Color[] getActiveViewGradient() { 122 return activeViewGradient; 123 } 124 125 128 static public Color getActiveViewGradientEnd() { 129 Color clr = (Color) systemColorMap.get(CLR_VIEW_GRAD_END); 130 Assert.isNotNull(clr); 131 return clr; 132 } 133 134 137 static public int[] getActiveViewGradientPercents() { 138 return activeViewPercentages; 139 } 140 141 144 static public Color getActiveViewGradientStart() { 145 Color clr = (Color) systemColorMap.get(CLR_VIEW_GRAD_START); 146 Assert.isNotNull(clr); 147 return clr; 148 } 149 150 153 static public Color[] getDeactivatedEditorGradient() { 154 return deactivatedEditorGradient; 155 } 156 157 160 static public int[] getDeactivatedEditorGradientPercents() { 161 return deactivatedEditorPercentages; 162 } 163 164 167 static public Color[] getDeactivatedViewGradient() { 168 return deactivatedViewGradient; 169 } 170 171 174 static public int[] getDeactivatedViewGradientPercents() { 175 return deactivatedViewPercentages; 176 } 177 178 181 static public Color getColor(RGB rgbValue) { 182 Color clr = (Color) colorMap.get(rgbValue); 183 if (clr == null) { 184 Display disp = Display.getDefault(); 185 clr = new Color(disp, rgbValue); 186 colorMap.put(rgbValue, clr); 187 } 188 return clr; 189 } 190 191 194 static public Color getSystemColor(int swtId) { 195 Integer bigInt = new Integer (swtId); 196 Color clr = (Color) systemColorMap.get(bigInt); 197 if (clr == null) { 198 Display disp = Display.getDefault(); 199 clr = disp.getSystemColor(swtId); 200 systemColorMap.put(bigInt, clr); 201 } 202 return clr; 203 } 204 205 211 private static void initWorkbenchColors(Display d) { 212 if (workbenchColors != null) { 213 return; 214 } 215 216 workbenchColors = new Color[] { 217 new Color(d, 255, 255, 255), new Color(d, 255, 251, 240), 219 new Color(d, 223, 223, 191), new Color(d, 223, 191, 191), 220 new Color(d, 192, 220, 192), new Color(d, 192, 192, 192), 221 new Color(d, 191, 191, 191), new Color(d, 191, 191, 159), 222 new Color(d, 191, 159, 191), new Color(d, 160, 160, 164), 223 new Color(d, 159, 159, 191), new Color(d, 159, 159, 159), 224 new Color(d, 159, 159, 127), new Color(d, 159, 127, 159), 225 new Color(d, 159, 127, 127), new Color(d, 128, 128, 128), 226 new Color(d, 127, 159, 159), new Color(d, 127, 159, 127), 227 new Color(d, 127, 127, 159), new Color(d, 127, 127, 127), 228 new Color(d, 127, 127, 95), new Color(d, 127, 95, 127), 229 new Color(d, 127, 95, 95), new Color(d, 95, 127, 127), 230 new Color(d, 95, 127, 95), new Color(d, 95, 95, 127), 231 new Color(d, 95, 95, 95), new Color(d, 95, 95, 63), 232 new Color(d, 95, 63, 95), new Color(d, 95, 63, 63), 233 new Color(d, 63, 95, 95), new Color(d, 63, 95, 63), 234 new Color(d, 63, 63, 95), new Color(d, 0, 0, 0), 235 new Color(d, 195, 204, 224), new Color(d, 214, 221, 235), 237 new Color(d, 149, 168, 199), new Color(d, 128, 148, 178), 238 new Color(d, 106, 128, 158), new Color(d, 255, 255, 255), 239 new Color(d, 0, 0, 0), new Color(d, 0, 0, 0), 240 new Color(d, 132, 130, 132), new Color(d, 143, 141, 138), 242 new Color(d, 171, 168, 165), 243 new Color(d, 230, 226, 221) }; 245 } 246 247 251 static public void shutdown() { 252 if (!init) { 253 return; 254 } 255 256 disposeWorkbenchColors(); 257 258 Iterator iter = colorMap.values().iterator(); 259 while (iter.hasNext()) { 260 Color clr = (Color) iter.next(); 261 if (clr != null) { 262 clr.dispose(); 263 } 264 } 265 266 colorMap.clear(); 267 systemColorMap.clear(); 268 init = false; 269 } 270 271 274 static public void startup() { 275 if (init) { 276 return; 277 } 278 279 init = true; 281 colorMap = new HashMap (10); 282 systemColorMap = new HashMap (10); 283 284 initWorkbenchColors(Display.getDefault()); 285 Color clr1 = getSystemColor(SWT.COLOR_TITLE_BACKGROUND); 287 Color clr2 = getSystemColor(SWT.COLOR_TITLE_BACKGROUND_GRADIENT); 288 Color clr3 = getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); 289 systemColorMap.put(CLR_VIEW_GRAD_START, clr1); 290 systemColorMap.put(CLR_VIEW_GRAD_END, clr3); 291 activeViewGradient = new Color[] { clr1, clr2, clr3 }; 292 activeViewPercentages = new int[] { 50, 100 }; 293 294 systemColorMap.put(CLR_EDITOR_GRAD_START, clr1); 296 systemColorMap.put(CLR_EDITOR_GRAD_END, null); activeEditorGradient = new Color[] { clr1, clr2, null, null }; 299 activeEditorPercentages = new int[] { 50, 90, 100 }; 300 301 activeNoFocusEditorGradient = new Color[] { getSystemColor(SWT.COLOR_LIST_BACKGROUND) }; 303 activeNoFocusEditorPercentages = new int[0]; 304 305 clr1 = getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND); 308 clr2 = getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT); 309 clr3 = getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); 310 deactivatedViewGradient = new Color[] { clr1, clr2, clr3 }; 311 deactivatedViewPercentages = new int[] { 70, 100 }; 312 313 deactivatedEditorGradient = new Color[] { clr1, clr2, null, null }; 316 deactivatedEditorPercentages = new int[] { 70, 95, 100 }; 317 318 getSystemColor(SWT.COLOR_WIDGET_FOREGROUND); 320 getSystemColor(SWT.COLOR_BLACK); 321 } 322 } 323 | Popular Tags |