From: jprocter Date: Fri, 22 Jul 2011 14:23:26 +0000 (+0100) Subject: method to get a user default colour (JAL-234) X-Git-Tag: Release_2_7~129 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6243301a956bb45508ba97bbb2ab6f627eb86de9;p=jalview.git method to get a user default colour (JAL-234) --- diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index f77c2f1..09ebadd 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -17,6 +17,7 @@ */ package jalview.bin; +import java.awt.Color; import java.io.*; import java.util.*; @@ -129,6 +130,8 @@ import org.biojava.dasobert.dasregistry.Das1Source; * *
  • SHOW_WSDISCOVERY_ERRORS (true) Controls if the web service URL discovery * warning dialog box is displayed.
  • + *
  • ANNOTATIONCOLOUR_MIN (orange) Shade used for minimum value of annotation when shading by annotation
  • + *
  • ANNOTATIONCOLOUR_MAX (red) Shade used for maximum value of annotation when shading by annotation
  • * *
  • * @@ -726,4 +729,29 @@ public class Cache } } + /** + * get the user's default colour if available + * @param property + * @param defcolour + * @return + */ + public static Color getDefaultColour(String property, Color defcolour) + { + String colprop = getProperty(property); + if (colprop==null) { + return defcolour; + } + Color col = jalview.schemes.ColourSchemeProperty.getAWTColorFromName(colprop); + if (col==null) + { + try { + col = new jalview.schemes.UserColourScheme(colprop).findColour('A'); + } catch (Exception ex) + { + log.warn("Couldn't parse '"+colprop+"' as a colour for "+property); + col=null; + } + } + return (col==null) ? defcolour: col; + } }