18 |
18 |
19 import org.eclipse.swt.graphics.Color; |
19 import org.eclipse.swt.graphics.Color; |
20 import org.eclipse.swt.widgets.Display; |
20 import org.eclipse.swt.widgets.Display; |
21 |
21 |
22 /** |
22 /** |
23 * Utilities for generating the same (unique) colour for a given String every |
23 * Utilities for generating the same (unique) color for a given String every |
24 * time. |
24 * time. |
25 */ |
25 */ |
26 public final class ColorUtil |
26 public final class ColorUtil { |
27 { |
|
28 private static final int[] RGB_WHITE = { 255, 255, 255 }; |
27 private static final int[] RGB_WHITE = { 255, 255, 255 }; |
29 private static final int[] RGB_GREY = { 180, 180, 180 };//light grey |
28 private static final int[] RGB_GREY = { 180, 180, 180 };// light grey |
30 private static final int[] RGB_BLACK = { 0, 0, 0 }; |
29 private static final int[] RGB_BLACK = { 0, 0, 0 }; |
31 private static final int[] RGB_100 = {100, 100, 100};//middle grey |
30 private static final int[] RGB_100 = { 100, 100, 100 };// middle grey |
32 private static final int[] RGB_170 = {170, 170, 170};//light grey |
31 private static final int[] RGB_170 = { 170, 170, 170 };// light grey |
33 private static final int[] RGB_200 = {200, 200, 200};//very light grey |
32 private static final int[] RGB_200 = { 200, 200, 200 };// very light grey |
34 |
33 |
35 /** Color representing the colour white */ |
34 /** Color representing the color white */ |
36 public static final Color WHITE = |
35 public static final Color WHITE = new Color(Display.getDefault(), |
37 new Color(Display.getDefault(), RGB_WHITE[0], RGB_WHITE[1], RGB_WHITE[2]); |
36 RGB_WHITE[0], RGB_WHITE[1], RGB_WHITE[2]); |
38 |
37 |
39 /** Color representing the colour grey */ |
38 /** Color representing the color grey */ |
40 public static final Color GREY = |
39 public static final Color GREY = new Color(Display.getDefault(), |
41 new Color(Display.getDefault(), RGB_GREY[0], RGB_GREY[1], RGB_GREY[2]); |
40 RGB_GREY[0], RGB_GREY[1], RGB_GREY[2]); |
42 |
41 |
43 /** Color representing the colour black */ |
42 /** Color representing the color black */ |
44 public static final Color BLACK = |
43 public static final Color BLACK = new Color(Display.getDefault(), |
45 new Color(Display.getDefault(), RGB_BLACK[0], RGB_BLACK[1], RGB_BLACK[2]); |
44 RGB_BLACK[0], RGB_BLACK[1], RGB_BLACK[2]); |
46 |
45 |
47 /** Color representing middle grey */ |
46 /** Color representing middle grey */ |
48 public static final Color COLOR_100 = new Color(Display.getDefault(), RGB_100[0], RGB_100[1], RGB_100[2]); |
47 public static final Color COLOR_100 = new Color(Display.getDefault(), |
|
48 RGB_100[0], RGB_100[1], RGB_100[2]); |
49 /** Color representing very light grey */ |
49 /** Color representing very light grey */ |
50 public static final Color COLOR_200 = new Color(Display.getDefault(), RGB_200[0], RGB_200[1], RGB_200[2]); |
50 public static final Color COLOR_200 = new Color(Display.getDefault(), |
|
51 RGB_200[0], RGB_200[1], RGB_200[2]); |
51 /** Color representing light grey */ |
52 /** Color representing light grey */ |
52 public static final Color COLOR_170 = new Color(Display.getDefault(), RGB_170[0], RGB_170[1], RGB_170[2]); |
53 public static final Color COLOR_170 = new Color(Display.getDefault(), |
53 |
54 RGB_170[0], RGB_170[1], RGB_170[2]); |
|
55 |
54 // Guard against instantiation |
56 // Guard against instantiation |
55 private ColorUtil() { |
57 private ColorUtil() { |
56 //do nothing by design |
58 // do nothing by design |
57 } |
59 } |
58 } |
60 } |