JAL-1517 fix copyright for 2.8.2
[jalview.git] / src / jalview / gui / PCAPanel.java
index 5c8d08b..213b748 100644 (file)
@@ -1,32 +1,35 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
  * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
  *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  * PURPOSE.  See the GNU General Public License for more details.
  * 
- * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.gui;
 
 import java.util.*;
-
 import java.awt.*;
 import java.awt.event.*;
 import java.awt.print.*;
+
 import javax.swing.*;
 
 import jalview.datamodel.*;
 import jalview.jbgui.*;
+import jalview.schemes.ResidueProperties;
 import jalview.util.MessageManager;
 import jalview.viewmodel.PCAModel;
 
@@ -109,7 +112,43 @@ public class PCAPanel extends GPCAPanel implements Runnable,
     Thread worker = new Thread(this);
     worker.start();
   }
-
+  @Override
+  protected void scoreMatrix_menuSelected()
+  {
+    scoreMatrixMenu.removeAll();
+    for (final String sm:ResidueProperties.scoreMatrices.keySet())
+    {
+      if (ResidueProperties.getScoreMatrix(sm) != null)
+      {
+        // create an entry for this score matrix for use in PCA
+        JCheckBoxMenuItem jm = new JCheckBoxMenuItem();
+        jm.setText(MessageManager
+                .getStringOrReturn("label.score_model", sm));
+        jm.setSelected(pcaModel.getScore_matrix().equals(sm));
+        if ((ResidueProperties.scoreMatrices.get(sm).isDNA() && ResidueProperties.scoreMatrices
+                .get(sm).isProtein())
+                || pcaModel.isNucleotide() == ResidueProperties.scoreMatrices
+                        .get(sm).isDNA())
+        {
+          final PCAPanel us = this;
+          jm.addActionListener(new ActionListener()
+          {
+            @Override
+            public void actionPerformed(ActionEvent e)
+            {
+              if (!pcaModel.getScore_matrix().equals((String) sm))
+              {
+                pcaModel.setScore_matrix((String) sm);
+                Thread worker = new Thread(us);
+                worker.start();
+              }
+            }
+          });
+          scoreMatrixMenu.add(jm);
+        }
+      }
+    }
+  }
   public void bgcolour_actionPerformed(ActionEvent e)
   {
     Color col = JColorChooser.showDialog(this, "Select Background Colour",
@@ -176,6 +215,7 @@ public class PCAPanel extends GPCAPanel implements Runnable,
     if (!pcaModel.isNucleotide())
     {
       pcaModel.setNucleotide(true);
+      pcaModel.setScore_matrix("DNA");
       Thread worker = new Thread(this);
       worker.start();
     }
@@ -189,6 +229,7 @@ public class PCAPanel extends GPCAPanel implements Runnable,
     if (pcaModel.isNucleotide())
     {
       pcaModel.setNucleotide(false);
+      pcaModel.setScore_matrix("BLOSUM62");
       Thread worker = new Thread(this);
       worker.start();
     }
@@ -446,6 +487,7 @@ public class PCAPanel extends GPCAPanel implements Runnable,
     }
   }
 
+  
   public void viewMenu_menuSelected()
   {
     buildAssociatedViewMenu();