2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, 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/>.
19 * author: Lauren Michelle Lui
24 import java.awt.Color;
25 import java.util.Random;
27 public class ColorUtils
31 * Generates a random color, will mix with input color. Code taken from
32 * http://stackoverflow
33 * .com/questions/43044/algorithm-to-randomly-generate-an-aesthetically
34 * -pleasing-color-palette
37 * @return Random color in RGB
39 public static final Color generateRandomColor(Color mix)
41 Random random = new Random();
42 int red = random.nextInt(256);
43 int green = random.nextInt(256);
44 int blue = random.nextInt(256);
49 red = (red + mix.getRed()) / 2;
50 green = (green + mix.getGreen()) / 2;
51 blue = (blue + mix.getBlue()) / 2;
54 Color color = new Color(red, green, blue);