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
5 * This file is part of Jalview.
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.
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.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
20 * author: Lauren Michelle Lui
25 import java.awt.Color;
26 import java.util.Random;
28 public class ColorUtils
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
38 * @return Random color in RGB
40 public static final Color generateRandomColor(Color mix)
42 Random random = new Random();
43 int red = random.nextInt(256);
44 int green = random.nextInt(256);
45 int blue = random.nextInt(256);
50 red = (red + mix.getRed()) / 2;
51 green = (green + mix.getGreen()) / 2;
52 blue = (blue + mix.getBlue()) / 2;
55 Color color = new Color(red, green, blue);