git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'develop' into bug/JAL-4235_gradle_task_jalviewjsTranspile_does_not_fail...
[jalview.git]
/
src
/
jalview
/
util
/
ColorUtils.java
diff --git
a/src/jalview/util/ColorUtils.java
b/src/jalview/util/ColorUtils.java
index
b728c9d
..
24128ea
100644
(file)
--- a/
src/jalview/util/ColorUtils.java
+++ b/
src/jalview/util/ColorUtils.java
@@
-24,10
+24,9
@@
package jalview.util;
package jalview.util;
-import java.util.Locale;
-
import java.awt.Color;
import java.util.HashMap;
import java.awt.Color;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.Map;
import java.util.Random;
@@
-68,7
+67,7
@@
public class ColorUtils
return color;
}
return color;
}
-
+
/**
*
* @return random color
/**
*
* @return random color
@@
-80,6
+79,7
@@
public class ColorUtils
(int) (Math.random() * 255), (int) (Math.random() * 255));
return col;
}
(int) (Math.random() * 255), (int) (Math.random() * 255));
return col;
}
+
/**
* Convert to Tk colour code format
*
/**
* Convert to Tk colour code format
*
@@
-233,6
+233,12
@@
public class ColorUtils
colour = colour.trim();
Color col = null;
colour = colour.trim();
Color col = null;
+
+ if ("random".equals(colour))
+ {
+ return generateRandomColor(null);
+ }
+
try
{
int value = Integer.parseInt(colour, 16);
try
{
int value = Integer.parseInt(colour, 16);
@@
-258,7
+264,8
@@
public class ColorUtils
int b = Integer.parseInt(tokens[2].trim());
col = new Color(r, g, b);
}
int b = Integer.parseInt(tokens[2].trim());
col = new Color(r, g, b);
}
- } catch (Exception ex)
+ } catch (IllegalArgumentException ex) // IllegalArgumentException includes
+ // NumberFormatException
{
// non-numeric token or out of 0-255 range
}
{
// non-numeric token or out of 0-255 range
}