Merge branch 'features/JAL-2360colourSchemeApplicability' into features/JAL-2371colle...
[jalview.git] / src / jalview / schemes / UserColourScheme.java
index 218c285..85bf54e 100755 (executable)
@@ -56,18 +56,27 @@ public class UserColourScheme extends ResidueColourScheme
   }
 
   @Override
-  public ColourSchemeI applyTo(AnnotatedCollectionI sg,
+  public ColourSchemeI getInstance(AnnotatedCollectionI sg,
           Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
   {
-    UserColourScheme usc = new UserColourScheme(colors);
-    if (lowerCaseColours != null)
+    return new UserColourScheme(this);
+  }
+
+  /**
+   * Copy constructor
+   * 
+   * @return
+   */
+  protected UserColourScheme(UserColourScheme from)
+  {
+    this(from.colors);
+    schemeName = from.schemeName;
+    if (from.lowerCaseColours != null)
     {
-      usc.schemeName = schemeName;
-      usc.lowerCaseColours = new Color[lowerCaseColours.length];
-      System.arraycopy(lowerCaseColours, 0, usc.lowerCaseColours, 0,
-              lowerCaseColours.length);
+      lowerCaseColours = new Color[lowerCaseColours.length];
+      System.arraycopy(from.lowerCaseColours, 0, lowerCaseColours, 0,
+              from.lowerCaseColours.length);
     }
-    return usc;
   }
 
   /**
@@ -229,36 +238,6 @@ public class UserColourScheme extends ResidueColourScheme
 
   }
 
-  @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;
@@ -294,7 +273,7 @@ public class UserColourScheme extends ResidueColourScheme
     {
       return schemeName;
     }
-    return JalviewColourScheme.UserDefined.toString();
+    return "User Defined";
   }
 
   /**