From 7cef06600140ffeb5a989117113d510742b9aa5e Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 6 Dec 2023 11:02:32 +0000 Subject: [PATCH] JAL-4353 Add a 'random' colour to produce a random colour. --- src/jalview/util/ColorUtils.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/jalview/util/ColorUtils.java b/src/jalview/util/ColorUtils.java index 9ed98bd..e9c66bd 100644 --- a/src/jalview/util/ColorUtils.java +++ b/src/jalview/util/ColorUtils.java @@ -24,10 +24,9 @@ package jalview.util; -import java.util.Locale; - import java.awt.Color; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import java.util.Random; @@ -234,6 +233,15 @@ public class ColorUtils colour = colour.trim(); Color col = null; + + if ("random".equals(colour)) + { + Random rand = new Random(); + col = new Color(rand.nextInt(256), rand.nextInt(256), + rand.nextInt(256)); + return col; + } + try { int value = Integer.parseInt(colour, 16); -- 1.7.10.2