JAL-1767 refactorings to enable faithful restore of PCA from project
[jalview.git] / src / jalview / viewmodel / PCAModel.java
index 3403887..a4f57be 100644 (file)
@@ -29,6 +29,7 @@ import jalview.datamodel.Point;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.SequencePoint;
 
+import java.util.List;
 import java.util.Vector;
 
 public class PCAModel
@@ -56,7 +57,7 @@ public class PCAModel
 
   int top;
 
-  private Vector<SequencePoint> points;
+  private List<SequencePoint> points;
 
   /**
    * Constructor given sequence data, score model and score calculation
@@ -105,7 +106,7 @@ public class PCAModel
     for (int i = 0; i < height; i++)
     {
       SequencePoint sp = new SequencePoint(seqs[i], scores[i]);
-      points.addElement(sp);
+      points.add(sp);
     }
   }
 
@@ -125,17 +126,22 @@ public class PCAModel
   }
 
   /**
+   * Answers the index of the principal dimension of the PCA
    * 
-   * 
-   * @return index of principle dimension of PCA
+   * @return
    */
   public int getTop()
   {
     return top;
   }
 
+  public void setTop(int t)
+  {
+    top = t;
+  }
+
   /**
-   * update the 2d coordinates for the list of points to the given dimensions
+   * Updates the 3D coordinates for the list of points to the given dimensions.
    * Principal dimension is getTop(). Next greatest eigenvector is getTop()-1.
    * Note - pca.getComponents starts counting the spectrum from rank-2 to zero,
    * rather than rank-1, so getComponents(dimN ...) == updateRcView(dimN+1 ..)
@@ -151,7 +157,7 @@ public class PCAModel
 
     for (int i = 0; i < pca.getHeight(); i++)
     {
-      points.elementAt(i).coord = scores[i];
+      points.get(i).coord = scores[i];
     }
   }
 
@@ -203,7 +209,7 @@ public class PCAModel
       }
       else
       {
-        Point p = points.elementAt(s).coord;
+        Point p = points.get(s).coord;
         csv.append(",").append(p.x);
         csv.append(",").append(p.y);
         csv.append(",").append(p.z);
@@ -213,29 +219,48 @@ public class PCAModel
     return csv.toString();
   }
 
+  public String getScoreModelName()
+  {
+    return scoreModel == null ? "" : scoreModel.getName();
+  }
+
+  public void setScoreModel(ScoreModelI sm)
+  {
+    this.scoreModel = sm;
+  }
+
   /**
+   * Answers the parameters configured for pairwise similarity calculations
    * 
-   * @return x,y,z positions of point s (index into points) under current
-   *         transform.
+   * @return
    */
-  public double[] getPointPosition(int s)
+  public SimilarityParamsI getSimilarityParameters()
   {
-    double pts[] = new double[3];
-    Point p = points.elementAt(s).coord;
-    pts[0] = p.x;
-    pts[1] = p.y;
-    pts[2] = p.z;
-    return pts;
+    return similarityParams;
   }
 
-  public String getScoreModelName()
+  public List<SequencePoint> getSequencePoints()
   {
-    return scoreModel == null ? "" : scoreModel.getName();
+    return points;
   }
 
-  public void setScoreModel(ScoreModelI sm)
+  public void setSequencePoints(List<SequencePoint> sp)
   {
-    this.scoreModel = sm;
+    points = sp;
   }
 
+  /**
+   * Answers the object holding the values of the computed PCA
+   * 
+   * @return
+   */
+  public PCA getPcaData()
+  {
+    return pca;
+  }
+
+  public void setPCA(PCA data)
+  {
+    pca = data;
+  }
 }