--- /dev/null
+package jalview.schemes;
+
+import jalview.api.ColorI;
+
+import java.awt.Color;
+
+public class Colour implements ColorI
+{
+ public static final ColorI lightGray = new Colour(Color.lightGray);
+
+ public static final ColorI gray = new Colour(Color.gray);
+
+ public static final ColorI blue = new Colour(Color.blue);
+
+ public static final ColorI yellow = new Colour(Color.yellow);
+
+ public static final ColorI red = new Colour(Color.red);
+
+ public static final ColorI black = new Colour(Color.black);
+
+ public static final ColorI white = new Colour(Color.white);
+
+ public static final ColorI pink = new Colour(Color.pink);
+
+ public static final ColorI green = new Colour(Color.green);
+
+ public static final ColorI magenta = new Colour(Color.magenta);
+
+ public static final ColorI orange = new Colour(Color.orange);
+
+ private int greenValue;
+
+ private int blueValue;
+
+ private int redValue;
+
+ public Colour(Color c)
+ {
+ this(c.getRed(), c.getGreen(), c.getBlue());
+ }
+
+ /**
+ * Constructor given RGB values in the range 0-255
+ *
+ * @param r
+ * @param g
+ * @param b
+ */
+ public Colour(int r, int g, int b)
+ {
+ redValue = r;
+ greenValue = g;
+ blueValue = b;
+ }
+
+ /**
+ * Constructor given an rgb value
+ *
+ * @param rgb
+ */
+ public Colour(int rgb)
+ {
+ this((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, (rgb >> 0) & 0xFF);
+ }
+
+ /**
+ * Constructor given RGB values in the range 0-1
+ *
+ * @param r
+ * @param g
+ * @param b
+ */
+ public Colour(float r, float g, float b)
+ {
+ this((int) (r * 255 + 0.5), (int) (g * 255 + 0.5),
+ (int) (b * 255 + 0.5));
+ }
+
+ @Override
+ public int getGreen()
+ {
+ return greenValue;
+ }
+
+ @Override
+ public int getBlue()
+ {
+ return blueValue;
+ }
+
+ @Override
+ public int getRed()
+ {
+ return redValue;
+ }
+
+ /**
+ *
+ * @see java.awt.Color#Color(int, int, int, int)
+ */
+ @Override
+ public int getRGB()
+ {
+ int value = ((255 & 0xFF) << 24) |
+ ((redValue & 0xFF) << 16) |
+ ((greenValue & 0xFF) << 8) |
+ ((blueValue & 0xFF) << 0);
+ return value;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return getRGB();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof Colour)
+ {
+ return getRGB() == ((Colour) obj).getRGB();
+ }
+ return false;
+ }
+
+}