1 4 package com.nightlabs.rcp.util; 5 6 import org.eclipse.swt.graphics.Color; 7 import org.eclipse.swt.graphics.Device; 8 import org.eclipse.swt.graphics.RGB; 9 import org.eclipse.swt.widgets.Display; 10 11 14 public class ColorUtil extends com.nightlabs.util.ColorUtil 15 { 16 17 protected ColorUtil() 18 { 19 } 20 21 public static String rgbToString(RGB rgb) 22 { 23 return "RGBA{" 24 + rgb.red + ',' 25 + rgb.green + ',' 26 + rgb.blue + ",255}"; } 28 29 public static RGB stringToRGB(String color) 30 { 31 RGBA rgba = parseRGBA(color); 32 return new RGB(rgba.r, rgba.g, rgba.b); 33 } 34 35 public static String swtColorToString(Color color) 36 { 37 return "RGBA{" 38 + color.getRed() + ',' 39 + color.getGreen() + ',' 40 + color.getBlue() + ",255}"; } 42 43 47 public static Color stringToSWTColor(String color) 48 { 49 RGBA rgba = parseRGBA(color); 50 return new Color(Display.getDefault(), rgba.r, rgba.g, rgba.b); 51 } 52 53 57 public static Color stringToSWTColor(Device device, String color) 58 { 59 RGBA rgba = parseRGBA(color); 60 if (device == null) 61 device = Display.getDefault(); 62 return new Color(device, rgba.r, rgba.g, rgba.b); 63 } 64 } 65 | Popular Tags |