1 11 package org.eclipse.ui.themes; 12 13 import java.util.Hashtable ; 14 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 20 48 public class RGBBlendColorFactory implements IColorFactory, 49 IExecutableExtension { 50 51 private String color1, color2; 52 53 56 public RGB createColor() { 57 if (color1 == null && color2 == null) { 58 return new RGB(0, 0, 0); 59 } else if (color1 != null && color2 == null) { 60 return ColorUtil.getColorValue(color1); 61 } else if (color1 == null && color2 != null) { 62 return ColorUtil.getColorValue(color2); 63 } else { 64 RGB rgb1 = ColorUtil.getColorValue(color1); 65 RGB rgb2 = ColorUtil.getColorValue(color2); 66 return ColorUtil.blend(rgb1, rgb2); 67 } 68 } 69 70 79 public void setInitializationData(IConfigurationElement config, 80 String propertyName, Object data) throws CoreException { 81 82 if (data instanceof Hashtable ) { 83 Hashtable table = (Hashtable ) data; 84 color1 = (String ) table.get("color1"); color2 = (String ) table.get("color2"); } 87 } 88 } 89 | Popular Tags |