JAL-2016 push getFeatureColourScheme(source) into SequenceFetcher
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 28 Mar 2016 09:02:46 +0000 (10:02 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 28 Mar 2016 09:02:46 +0000 (10:02 +0100)
src/jalview/gui/AlignFrame.java
src/jalview/ws/seqfetcher/ASequenceFetcher.java

index 9e52fa3..b48a750 100644 (file)
@@ -100,7 +100,6 @@ import jalview.ws.SequenceFetcher;
 import jalview.ws.jws1.Discoverer;
 import jalview.ws.jws2.Jws2Discoverer;
 import jalview.ws.jws2.jabaws2.Jws2Instance;
-import jalview.ws.seqfetcher.ASequenceFetcher;
 import jalview.ws.seqfetcher.DbSourceProxy;
 
 import java.awt.BorderLayout;
@@ -4733,21 +4732,11 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           if (xrefs != null)
           {
             /*
-             * figure out colour scheme if any to apply to features
+             * get display scheme (if any) to apply to features
              */
-            ASequenceFetcher sftch = new SequenceFetcher();
-            List<DbSourceProxy> proxies = sftch.getSourceProxy(source);
-            FeatureSettingsModelI featureColourScheme = null;
-            for (DbSourceProxy proxy : proxies)
-            {
-              FeatureSettingsModelI preferredColours = proxy
-                      .getFeatureColourScheme();
-              if (preferredColours != null)
-              {
-                featureColourScheme = preferredColours;
-                break;
-              }
-            }
+            FeatureSettingsModelI featureColourScheme = new SequenceFetcher()
+                    .getFeatureColourScheme(source);
+
             AlignmentI al = makeCrossReferencesAlignment(
                     alignment.getDataset(), xrefs);
 
index 2ed3263..2392476 100644 (file)
@@ -20,6 +20,7 @@
  */
 package jalview.ws.seqfetcher;
 
+import jalview.api.FeatureSettingsModelI;
 import jalview.bin.Cache;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.DBRefEntry;
@@ -435,4 +436,28 @@ public class ASequenceFetcher
     return prlist.toArray(new DbSourceProxy[0]);
   }
 
+  /**
+   * Returns a preferred feature colouring scheme for the given source, or null
+   * if none is defined.
+   * 
+   * @param source
+   * @return
+   */
+  public FeatureSettingsModelI getFeatureColourScheme(String source)
+  {
+    /*
+     * return the first non-null colour scheme for any proxy for
+     * this database source
+     */
+    for (DbSourceProxy proxy : getSourceProxy(source))
+    {
+      FeatureSettingsModelI preferredColours = proxy
+              .getFeatureColourScheme();
+      if (preferredColours != null)
+      {
+        return preferredColours;
+      }
+    }
+    return null;
+  }
 }