JAL-1136 sometimes there are no parameters associated with a CalcId key
[jalview.git] / src / jalview / viewmodel / PCAModel.java
index 30f8783..64f2497 100644 (file)
@@ -19,7 +19,7 @@ public class PCAModel
     nucleotide=nucleotide2;
   }
 
-  PCA pca;
+  private volatile PCA pca;
   
   int top;
   
@@ -34,10 +34,18 @@ public class PCAModel
 
   private Vector<SequencePoint> points;
 
+  private boolean jvCalcMode=true;
+
+  public boolean isJvCalcMode()
+  {
+    return jvCalcMode;
+  }
+
   public void run()
   {
     
     pca = new PCA(seqstrings.getSequenceStrings(' '), nucleotide);
+    pca.setJvCalcMode(jvCalcMode);
     pca.run();
 
     // Now find the component coordinates
@@ -97,14 +105,15 @@ public class PCAModel
 
   /**
    * update the 2d coordinates for the list of points to the given dimensions
-   * Principal dimension is getTop(). Next greated eigenvector is getTop()-1.
-   * Note - pca.getComponents starts counting the spectrum from zero rather than one, so getComponents(dimN ...)  == updateRcView(dimN+1 ..)  
+   * 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 ..)  
    * @param dim1 
    * @param dim2
    * @param dim3
    */
   public void updateRcView(int dim1, int dim2, int dim3)
   {
+    // note: actual indices for components are dim1-1, etc (patch for JAL-1123)
     float[][] scores = pca.getComponents(dim1-1, dim2-1, dim3-1, 100);
 
     for (int i = 0; i < pca.getM().rows; i++)
@@ -187,4 +196,9 @@ public class PCAModel
     return pts;
   }
 
+  public void setJvCalcMode(boolean state)
+  {
+    jvCalcMode=state;
+  }
+
 }