From: Ben Soares Date: Wed, 6 Dec 2023 11:02:32 +0000 (+0000) Subject: JAL-4353 Add a 'random' colour to produce a random colour. X-Git-Tag: Release_2_11_4_0~56^2~6 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7cef06600140ffeb5a989117113d510742b9aa5e;p=jalview.git JAL-4353 Add a 'random' colour to produce a random colour. --- 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);