1 package jalview.schemes;
3 import jalview.api.ColorI;
7 public class Colour implements ColorI
9 public static final ColorI lightGray = new Colour(Color.lightGray);
11 public static final ColorI gray = new Colour(Color.gray);
13 public static final ColorI blue = new Colour(Color.blue);
15 public static final ColorI yellow = new Colour(Color.yellow);
17 public static final ColorI red = new Colour(Color.red);
19 public static final ColorI black = new Colour(Color.black);
21 public static final ColorI white = new Colour(Color.white);
23 public static final ColorI pink = new Colour(Color.pink);
25 public static final ColorI green = new Colour(Color.green);
27 public static final ColorI magenta = new Colour(Color.magenta);
29 public static final ColorI orange = new Colour(Color.orange);
31 private int greenValue;
33 private int blueValue;
37 public Colour(Color c)
39 this(c.getRed(), c.getGreen(), c.getBlue());
43 * Constructor given RGB values in the range 0-255
49 public Colour(int r, int g, int b)
57 * Constructor given an rgb value
61 public Colour(int rgb)
63 this((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, (rgb >> 0) & 0xFF);
67 * Constructor given RGB values in the range 0-1
73 public Colour(float r, float g, float b)
75 this((int) (r * 255 + 0.5), (int) (g * 255 + 0.5),
76 (int) (b * 255 + 0.5));
99 * @see java.awt.Color#Color(int, int, int, int)
104 int value = ((255 & 0xFF) << 24) |
105 ((redValue & 0xFF) << 16) |
106 ((greenValue & 0xFF) << 8) |
107 ((blueValue & 0xFF) << 0);
112 public int hashCode()
118 public boolean equals(Object obj)
120 if (obj instanceof Colour)
122 return getRGB() == ((Colour) obj).getRGB();