1 package net.mograsim.logic.core.types;
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 public class ColorDefinition
12 * The built-in color constant defining this color.
14 public final ColorDefinition.BuiltInColor builtInColor;
16 * The red color component defining this color.
20 * The green color component defining this color.
24 * The blue color component defining this color.
28 public ColorDefinition(ColorDefinition.BuiltInColor col)
31 throw new IllegalArgumentException("Illegal built-in color: " + col);
32 this.builtInColor = col;
38 public ColorDefinition(int r, int g, int b)
40 if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255)
41 throw new IllegalArgumentException("Illegal color components: r=" + r + "; g=" + g + "; b=" + b);
42 this.builtInColor = null;
48 public static enum BuiltInColor
50 COLOR_WHITE, COLOR_BLACK, COLOR_RED, COLOR_DARK_RED, COLOR_GREEN, COLOR_DARK_GREEN, COLOR_YELLOW, COLOR_DARK_YELLOW, COLOR_BLUE,
51 COLOR_DARK_BLUE, COLOR_MAGENTA, COLOR_DARK_MAGENTA, COLOR_CYAN, COLOR_DARK_CYAN, COLOR_GRAY, COLOR_DARK_GRAY;