package jalview.util;
import java.awt.Color;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Random;
public class ColorUtils
{
+ private static final int MAX_CACHE_SIZE = 1729;
+ /*
+ * a cache for colours generated from text strings
+ */
+ static Map<String, Color> myColours = new HashMap<>();
/**
* Generates a random color, will mix with input color. Code taken from
{
return Color.white;
}
+ if (myColours.containsKey(name))
+ {
+ return myColours.get(name);
+ }
int lsize = name.length();
int start = 0;
int end = lsize / 3;
Color color = new Color(r, g, b);
+ if (myColours.size() < MAX_CACHE_SIZE)
+ {
+ myColours.put(name, color);
+ }
+
return color;
}