JAL-2418 source formatting
[jalview.git] / src / jalview / analysis / scoremodels / ScoreModels.java
index 494d09f..ea7b30e 100644 (file)
@@ -1,5 +1,6 @@
 package jalview.analysis.scoremodels;
 
+import jalview.api.AlignmentViewPanel;
 import jalview.api.analysis.ScoreModelI;
 import jalview.io.DataSourceType;
 import jalview.io.FileParse;
@@ -67,14 +68,15 @@ public class ScoreModels
       /*
        * delegate parsing to ScoreMatrixFile
        */
-      FileParse fp = new FileParse(resourcePath, DataSourceType.CLASSLOADER);
+      FileParse fp = new FileParse(resourcePath,
+              DataSourceType.CLASSLOADER);
       ScoreMatrix sm = new ScoreMatrixFile(fp).parseMatrix();
       registerScoreModel(sm);
       return sm;
     } catch (IOException e)
     {
-      System.err.println("Error reading " + resourcePath + ": "
-              + e.getMessage());
+      System.err.println(
+              "Error reading " + resourcePath + ": " + e.getMessage());
     }
     return null;
   }
@@ -90,9 +92,20 @@ public class ScoreModels
     return models.values();
   }
 
-  public ScoreModelI forName(String s)
+  /**
+   * Returns an instance of a score model for the given name. If the model is of
+   * 'view dependent' type (e.g. feature similarity), instantiates a new
+   * instance configured for the given view. Otherwise returns a cached instance
+   * of the score model.
+   * 
+   * @param name
+   * @param avp
+   * @return
+   */
+  public ScoreModelI getScoreModel(String name, AlignmentViewPanel avp)
   {
-    return models.get(s);
+    ScoreModelI model = models.get(name);
+    return model == null ? null : model.getInstance(avp);
   }
 
   public void registerScoreModel(ScoreModelI sm)