JAL-2360 simplified code to create a new colour scheme
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 21 Dec 2016 16:00:29 +0000 (16:00 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 21 Dec 2016 16:00:29 +0000 (16:00 +0000)
test/jalview/schemes/ColourSchemesTest.java

index e44ed71..f7f0a0c 100644 (file)
@@ -33,46 +33,52 @@ public class ColourSchemesTest
    */
   class Stripy extends ResidueColourScheme
   {
+    private ColourSchemeI odd;
+
+    private ColourSchemeI even;
+
+    private Stripy()
+    {
+    }
+
+    /**
+     * constructor given colours for odd and even columns
+     * 
+     * @param odd
+     * @param even
+     */
+    private Stripy(ColourSchemeI cs1, ColourSchemeI cs2)
+    {
+      odd = cs1;
+      even = cs2;
+    }
+
     @Override
     public ColourSchemeI getInstance(AnnotatedCollectionI sg,
             Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
     {
-      final ColourSchemeI odd = ColourSchemes.getInstance()
+      final ColourSchemeI cs1 = ColourSchemes.getInstance()
               .getColourScheme(JalviewColourScheme.Taylor.toString(),
                       (AnnotatedCollectionI) null);
-      final ColourSchemeI even = ColourSchemes.getInstance()
+      final ColourSchemeI cs2 = ColourSchemes.getInstance()
               .getColourScheme(JalviewColourScheme.Zappo.toString(),
                       (AnnotatedCollectionI) null);
-      return new ResidueColourScheme() {
-        @Override
-        public Color findColour(char c, int j, SequenceI seq)
-        {
-          if (j % 2 == 1)
-          {
-            return odd.findColour(c, j, seq);
-          }
-          else
-          {
-            return even.findColour(c, j, seq);
-          }
-        }
-
-        @Override
-        public ColourSchemeI getInstance(AnnotatedCollectionI ac,
-                Map<SequenceI, SequenceCollectionI> hrs)
-        {
-          return null;
-        }
+      return new Stripy(cs1, cs2);
+    }
 
-        @Override
-        public String getSchemeName()
-        {
-          return Stripy.this.getSchemeName();
-        }
-        
-      };
+    @Override
+    public Color findColour(char c, int j, SequenceI seq)
+    {
+      if (j % 2 == 1)
+      {
+        return odd.findColour(c, j, seq);
+      }
+      else
+      {
+        return even.findColour(c, j, seq);
+      }
     }
-    
+
     @Override
     public String getSchemeName()
     {
@@ -87,11 +93,11 @@ public class ColourSchemesTest
   {
     ColourSchemeI delegate;
 
-    public MyClustal()
+    private MyClustal()
     {
     }
 
-    public MyClustal(ColourSchemeI scheme)
+    private MyClustal(ColourSchemeI scheme)
     {
       delegate = scheme;
     }