update author list in license for (JAL-826)
[jalview.git] / src / jalview / util / ColorUtils.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3  * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
10  * 
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 /**
20  * author: Lauren Michelle Lui
21  */
22
23 package jalview.util;
24
25 import java.awt.Color;
26 import java.util.Random;
27
28 public class ColorUtils
29 {
30
31   /**
32    * Generates a random color, will mix with input color. Code taken from
33    * http://stackoverflow
34    * .com/questions/43044/algorithm-to-randomly-generate-an-aesthetically
35    * -pleasing-color-palette
36    * 
37    * @param mix
38    * @return Random color in RGB
39    */
40   public static final Color generateRandomColor(Color mix)
41   {
42     Random random = new Random();
43     int red = random.nextInt(256);
44     int green = random.nextInt(256);
45     int blue = random.nextInt(256);
46
47     // mix the color
48     if (mix != null)
49     {
50       red = (red + mix.getRed()) / 2;
51       green = (green + mix.getGreen()) / 2;
52       blue = (blue + mix.getBlue()) / 2;
53     }
54
55     Color color = new Color(red, green, blue);
56     return color;
57
58   }
59
60 }