JAL-2598 Sequence.getSequence return a copy of the char array
[jalview.git] / src / jalview / schemes / ColourSchemes.java
index 33ec966..269811b 100644 (file)
@@ -15,7 +15,7 @@ public class ColourSchemes
   private static ColourSchemes instance = new ColourSchemes();
 
   /*
-   * a map from scheme name to an instance of it
+   * a map from scheme name (lower-cased) to an instance of it
    */
   private Map<String, ColourSchemeI> schemes;
 
@@ -94,7 +94,10 @@ public class ColourSchemes
    */
   public void removeColourScheme(String name)
   {
-    schemes.remove(name);
+    if (name != null)
+    {
+      schemes.remove(name.toLowerCase());
+    }
   }
   
   /**
@@ -148,4 +151,20 @@ public class ColourSchemes
   {
     return schemes.values();
   }
+
+  /**
+   * Answers true if there is a scheme with the given name, else false. The test
+   * is not case-sensitive.
+   * 
+   * @param name
+   * @return
+   */
+  public boolean nameExists(String name)
+  {
+    if (name == null)
+    {
+      return false;
+    }
+    return schemes.containsKey(name.toLowerCase());
+  }
 }