JAL-629 Change all stdout and stderr output to use Console.outPrintln and Console...
[jalview.git] / src / jalview / schemes / UserColourScheme.java
index 256862d..ec0f008 100755 (executable)
  */
 package jalview.schemes;
 
+import java.util.Locale;
+
+import jalview.api.AlignViewportI;
 import jalview.datamodel.AnnotatedCollectionI;
-import jalview.datamodel.SequenceCollectionI;
-import jalview.datamodel.SequenceI;
 import jalview.util.ColorUtils;
 import jalview.util.StringUtils;
 
@@ -56,8 +57,8 @@ public class UserColourScheme extends ResidueColourScheme
   }
 
   @Override
-  public ColourSchemeI getInstance(AnnotatedCollectionI sg,
-          Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
+  public ColourSchemeI getInstance(AlignViewportI view,
+          AnnotatedCollectionI sg)
   {
     return new UserColourScheme(this);
   }
@@ -107,7 +108,7 @@ public class UserColourScheme extends ResidueColourScheme
 
     if (col == null)
     {
-      System.out.println("Making colour from name: " + colour);
+      jalview.bin.Console.outPrintln("Making colour from name: " + colour);
       col = ColorUtils.createColourFromName(colour);
     }
 
@@ -216,13 +217,14 @@ public class UserColourScheme extends ResidueColourScheme
             continue;
           }
 
-          if (residue.equals(residue.toLowerCase()))
+          if (residue.equals(residue.toLowerCase(Locale.ROOT)))
           {
             if (lowerCaseColours == null)
             {
               lowerCaseColours = new Color[colors.length];
             }
-            lowerCaseColours[colIndex] = ColorUtils.parseColourString(colour);
+            lowerCaseColours[colIndex] = ColorUtils
+                    .parseColourString(colour);
           }
           else
           {
@@ -232,8 +234,8 @@ public class UserColourScheme extends ResidueColourScheme
       }
     } catch (Exception ex)
     {
-      System.out.println("Error parsing userDefinedColours:\n" + token
-              + "\n" + ex);
+      jalview.bin.Console.outPrintln(
+              "Error parsing userDefinedColours:\n" + token + "\n" + ex);
     }
 
   }
@@ -263,8 +265,8 @@ public class UserColourScheme extends ResidueColourScheme
   }
 
   /**
-   * Answers the customised name of the colour scheme, if it has one, else
-   * "User Defined"
+   * Answers the customised name of the colour scheme, if it has one, else "User
+   * Defined"
    */
   @Override
   public String getSchemeName()
@@ -286,7 +288,7 @@ public class UserColourScheme extends ResidueColourScheme
     /*
      * step 1: build a map from colours to the symbol(s) that have the colour
      */
-    Map<Color, List<String>> colours = new HashMap<Color, List<String>>();
+    Map<Color, List<String>> colours = new HashMap<>();
 
     for (char symbol = 'A'; symbol <= 'Z'; symbol++)
     {
@@ -306,7 +308,7 @@ public class UserColourScheme extends ResidueColourScheme
         c = lowerCaseColours[index];
         if (c != null && !c.equals(Color.white))
         {
-          residue = residue.toLowerCase();
+          residue = residue.toLowerCase(Locale.ROOT);
           if (colours.get(c) == null)
           {
             colours.put(c, new ArrayList<String>());
@@ -319,7 +321,7 @@ public class UserColourScheme extends ResidueColourScheme
     /*
      * step 2: make a list of { A,G,R=12f9d6 } residues/colour specs
      */
-    List<String> residueColours = new ArrayList<String>();
+    List<String> residueColours = new ArrayList<>();
     for (Entry<Color, List<String>> cols : colours.entrySet())
     {
       boolean first = true;
@@ -349,4 +351,10 @@ public class UserColourScheme extends ResidueColourScheme
     Collections.sort(residueColours);
     return StringUtils.listToDelimitedString(residueColours, ";");
   }
+
+  @Override
+  public boolean hasGapColour()
+  {
+    return (findColour(' ') != null);
+  }
 }