default parameter for colours in annotation shading (JAL-234), ensure
[jalview.git] / src / jalview / bin / JalviewLite.java
index f044411..9a4d9e2 100644 (file)
@@ -2244,6 +2244,34 @@ public class JalviewLite extends Applet implements StructureSelectionManagerProv
   }\r
 \r
   /**\r
+   * return the given colour value parameter or the given default if parameter not given\r
+   * @param colparam\r
+   * @param defcolour\r
+   * @return\r
+   */\r
+  public Color getDefaultColourParameter(String colparam, Color defcolour)\r
+  {\r
+    String colprop = getParameter(colparam);\r
+    if (colprop==null || colprop.trim().length()==0)\r
+    {\r
+      return defcolour;\r
+    }\r
+    Color col = jalview.schemes.ColourSchemeProperty.getAWTColorFromName(colprop);\r
+    if (col==null)\r
+    {\r
+      try {\r
+        col = new jalview.schemes.UserColourScheme(colprop).findColour('A');\r
+      } catch (Exception ex)\r
+      {\r
+        System.err.println("Couldn't parse '"+colprop+"' as a colour for "+colparam);\r
+        col=null;\r
+      }\r
+    }\r
+    return (col==null) ? defcolour: col;\r
+\r
+  }\r
+\r
+  /**\r
    * bind structures in a viewer to any matching sequences in an alignFrame (use\r
    * sequenceIds to limit scope of search to specific sequences)\r
    * \r