1 package net.mograsim.preferences;
4 * A way to define a color with the possibility to use colors built into the system (called "system colors" in SWT).
6 * A {@link ColorDefinition} is defined either by a {@link BuiltInColor} constant, in which case <code>r==g==b==-1</code>, or by red / green
7 * / blue components, in which case <code>builtInColor==null</code>
9 * @author Daniel Kirschten
11 public class ColorDefinition
14 * The built-in color constant defining this color.
16 public final ColorDefinition.BuiltInColor builtInColor;
18 * The red color component defining this color.
22 * The green color component defining this color.
26 * The blue color component defining this color.
30 public ColorDefinition(ColorDefinition.BuiltInColor col)
33 throw new IllegalArgumentException("Illegal built-in color: " + col);
34 this.builtInColor = col;
40 public ColorDefinition(int r, int g, int b)
42 if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255)
43 throw new IllegalArgumentException("Illegal color components: r=" + r + "; g=" + g + "; b=" + b);
44 this.builtInColor = null;
50 public static enum BuiltInColor
52 COLOR_WHITE, COLOR_BLACK, COLOR_RED, COLOR_DARK_RED, COLOR_GREEN, COLOR_DARK_GREEN, COLOR_YELLOW, COLOR_DARK_YELLOW, COLOR_BLUE,
53 COLOR_DARK_BLUE, COLOR_MAGENTA, COLOR_DARK_MAGENTA, COLOR_CYAN, COLOR_DARK_CYAN, COLOR_GRAY, COLOR_DARK_GRAY;