JAL-3675 release notes for JAL-3750 JAL-3751
[jalview.git] / src / jalview / schemes / UserColourScheme.java
index 969e6b3..d77f2f5 100755 (executable)
@@ -20,9 +20,8 @@
  */
 package jalview.schemes;
 
+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 +55,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);
   }
@@ -73,7 +72,7 @@ public class UserColourScheme extends ResidueColourScheme
     schemeName = from.schemeName;
     if (from.lowerCaseColours != null)
     {
-      lowerCaseColours = new Color[lowerCaseColours.length];
+      lowerCaseColours = new Color[from.lowerCaseColours.length];
       System.arraycopy(from.lowerCaseColours, 0, lowerCaseColours, 0,
               from.lowerCaseColours.length);
     }
@@ -222,7 +221,8 @@ public class UserColourScheme extends ResidueColourScheme
             {
               lowerCaseColours = new Color[colors.length];
             }
-            lowerCaseColours[colIndex] = ColorUtils.parseColourString(colour);
+            lowerCaseColours[colIndex] = ColorUtils
+                    .parseColourString(colour);
           }
           else
           {
@@ -232,42 +232,12 @@ public class UserColourScheme extends ResidueColourScheme
       }
     } catch (Exception ex)
     {
-      System.out.println("Error parsing userDefinedColours:\n" + token
-              + "\n" + ex);
+      System.out.println(
+              "Error parsing userDefinedColours:\n" + token + "\n" + ex);
     }
 
   }
 
-  @Override
-  public Color findColour(char c, int j, SequenceI seq)
-  {
-    Color currentColour;
-    int index = ResidueProperties.aaIndex[c];
-
-    if ((threshold == 0) || aboveThreshold(c, j))
-    {
-      if (lowerCaseColours != null && 'a' <= c && c <= 'z')
-      {
-        currentColour = lowerCaseColours[index];
-      }
-      else
-      {
-        currentColour = colors[index];
-      }
-    }
-    else
-    {
-      currentColour = Color.white;
-    }
-
-    if (conservationColouring)
-    {
-      currentColour = applyConservation(currentColour, j);
-    }
-
-    return currentColour;
-  }
-
   public void setLowerCaseColours(Color[] lcolours)
   {
     lowerCaseColours = lcolours;
@@ -293,8 +263,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()
@@ -303,7 +273,7 @@ public class UserColourScheme extends ResidueColourScheme
     {
       return schemeName;
     }
-    return "User Defined";
+    return ResidueColourScheme.USER_DEFINED;
   }
 
   /**
@@ -316,7 +286,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++)
     {
@@ -349,7 +319,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;
@@ -379,4 +349,10 @@ public class UserColourScheme extends ResidueColourScheme
     Collections.sort(residueColours);
     return StringUtils.listToDelimitedString(residueColours, ";");
   }
+
+  @Override
+  public boolean hasGapColour()
+  {
+    return (findColour(' ') != null);
+  }
 }