JAL-1473 show available score matrices for use in PCA calculation
[jalview.git] / src / jalview / gui / PCAPanel.java
index 538b245..fc32e54 100644 (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.schemes.ScoreMatrix;
 import jalview.util.MessageManager;
 import jalview.viewmodel.PCAModel;
 
@@ -109,7 +111,32 @@ public class PCAPanel extends GPCAPanel implements Runnable,
     Thread worker = new Thread(this);
     worker.start();
   }
-
+  @Override
+  protected void scoreMatrix_menuSelected()
+  {
+    scoreMatrixMenu.removeAll();
+    for (final Object sm:ResidueProperties.scoreMatrices.keySet())
+    {
+      JMenuItem jm=new JMenuItem();
+      jm.setText((String)sm);
+      jm.setSelected(pcaModel.getScore_matrix().equals((String)sm));
+      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",
@@ -165,7 +192,7 @@ public class PCAPanel extends GPCAPanel implements Runnable,
     if (getParent() == null)
     {
       addKeyListener(rc);
-      Desktop.addInternalFrame(this, "Principal component analysis", 475,
+      Desktop.addInternalFrame(this, MessageManager.getString("label.principal_component_analysis"), 475,
               450);
     }
   }
@@ -261,7 +288,7 @@ public class PCAPanel extends GPCAPanel implements Runnable,
     try
     {
       cap.setText(pcaModel.getDetails());
-      Desktop.addInternalFrame(cap, "PCA details", 500, 500);
+      Desktop.addInternalFrame(cap, MessageManager.getString("label.pca_details"), 500, 500);
     } catch (OutOfMemoryError oom)
     {
       new OOMWarning("opening PCA details", oom);
@@ -335,7 +362,7 @@ public class PCAPanel extends GPCAPanel implements Runnable,
         // af.addSortByOrderMenuItem(ServiceName + " Ordering",
         // msaorder);
 
-        Desktop.addInternalFrame(af, "Original Data for " + this.title,
+        Desktop.addInternalFrame(af, MessageManager.formatMessage("label.original_data_for_params", new String[]{this.title}),
                 AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT);
       }
     }
@@ -446,6 +473,7 @@ public class PCAPanel extends GPCAPanel implements Runnable,
     }
   }
 
+  
   public void viewMenu_menuSelected()
   {
     buildAssociatedViewMenu();
@@ -524,7 +552,7 @@ public class PCAPanel extends GPCAPanel implements Runnable,
       cap.setText(pcaModel.getPointsasCsv(false,
               xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(),
               zCombobox.getSelectedIndex()));
-      Desktop.addInternalFrame(cap, "Points for " + getTitle(), 500, 500);
+      Desktop.addInternalFrame(cap, MessageManager.formatMessage("label.points_for_params", new String[]{this.getTitle()}), 500, 500);
     } catch (OutOfMemoryError oom)
     {
       new OOMWarning("exporting PCA points", oom);
@@ -547,7 +575,7 @@ public class PCAPanel extends GPCAPanel implements Runnable,
       cap.setText(pcaModel.getPointsasCsv(true,
               xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(),
               zCombobox.getSelectedIndex()));
-      Desktop.addInternalFrame(cap, "Transformed points for " + getTitle(),
+      Desktop.addInternalFrame(cap, MessageManager.formatMessage("label.transformed_points_for_params", new String[]{this.getTitle()}),
               500, 500);
     } catch (OutOfMemoryError oom)
     {