ColorControllerpublic class ColorController extends Object
Fields Summary |
---|
private static final int[] | systemColors | private static org.eclipse.swt.graphics.RGB[] | rgbColors | private static HashMap | colorCache | private static HashMap | imageCache |
Constructors Summary |
---|
public ColorController()
|
Methods Summary |
---|
public static void | assignMethodColors(org.eclipse.swt.widgets.Display display, MethodData[] methods)
int nextColorIndex = 0;
for (MethodData md : methods) {
RGB rgb = rgbColors[nextColorIndex];
if (++nextColorIndex == rgbColors.length)
nextColorIndex = 0;
Color color = requestColor(display, rgb);
Image image = requestColorSquare(display, rgb);
md.setColor(color);
md.setImage(image);
// Compute and set a faded color
int fadedRed = 150 + rgb.red / 4;
int fadedGreen = 150 + rgb.green / 4;
int fadedBlue = 150 + rgb.blue / 4;
RGB faded = new RGB(fadedRed, fadedGreen, fadedBlue);
color = requestColor(display, faded);
image = requestColorSquare(display, faded);
md.setFadedColor(color);
md.setFadedImage(image);
}
| public static org.eclipse.swt.graphics.Color | requestColor(org.eclipse.swt.widgets.Display display, org.eclipse.swt.graphics.RGB rgb)
return requestColor(display, rgb.red, rgb.green, rgb.blue);
| public static org.eclipse.swt.graphics.Color | requestColor(org.eclipse.swt.widgets.Display display, int red, int green, int blue)
int key = (red << 16) | (green << 8) | blue;
Color color = colorCache.get(key);
if (color == null) {
color = new Color(display, red, green, blue);
colorCache.put(key, color);
}
return color;
| public static org.eclipse.swt.graphics.Image | requestColorSquare(org.eclipse.swt.widgets.Display display, org.eclipse.swt.graphics.RGB rgb)
return requestColorSquare(display, rgb.red, rgb.green, rgb.blue);
| public static org.eclipse.swt.graphics.Image | requestColorSquare(org.eclipse.swt.widgets.Display display, int red, int green, int blue)
int key = (red << 16) | (green << 8) | blue;
Image image = imageCache.get(key);
if (image == null) {
image = new Image(display, 8, 14);
GC gc = new GC(image);
Color color = requestColor(display, red, green, blue);
gc.setBackground(color);
gc.fillRectangle(image.getBounds());
gc.dispose();
imageCache.put(key, image);
}
return image;
|
|