X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FPCAPanel.java;h=3483cc4500c0b359ae3d73f492146d21677d6c08;hb=76139ef711627a3176736af47272ff55be62e720;hp=5c8d08b7ae048452be9afd3110d1757e95b434f8;hpb=cb5d856b1304448cae13a333cbd9017f81520d90;p=jalview.git diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index 5c8d08b..3483cc4 100644 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -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 . + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . * 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; @@ -94,10 +97,8 @@ public class PCAPanel extends GPCAPanel implements Runnable, JOptionPane .showMessageDialog( Desktop.desktop, - "The sequences must be aligned before calculating PCA.\n" - + "Try using the Pad function in the edit menu,\n" - + "or one of the multiple sequence alignment web services.", - "Sequences not aligned", JOptionPane.WARNING_MESSAGE); + MessageManager.getString("label.pca_sequences_not_aligned"), + MessageManager.getString("label.sequences_not_aligned"), JOptionPane.WARNING_MESSAGE); return; } @@ -110,9 +111,47 @@ public class PCAPanel extends GPCAPanel implements Runnable, 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", + Color col = JColorChooser.showDialog(this, MessageManager.getString("label.select_backgroud_colour"), rc.bgColour); if (col != null) @@ -129,11 +168,11 @@ public class PCAPanel extends GPCAPanel implements Runnable, { long progId = System.currentTimeMillis(); IProgressIndicator progress = this; - String message = "Recalculating PCA"; + String message = MessageManager.getString("label.pca_recalculating"); if (getParent() == null) { progress = ap.alignFrame; - message = "Calculating PCA"; + message = MessageManager.getString("label.pca_calculating"); } progress.setProgressBar(message, progId); try @@ -165,8 +204,8 @@ public class PCAPanel extends GPCAPanel implements Runnable, if (getParent() == null) { addKeyListener(rc); - Desktop.addInternalFrame(this, MessageManager.getString("label.principal_component_analysis"), 475, - 450); + Desktop.addInternalFrame(this, MessageManager + .getString("label.principal_component_analysis"), 475, 450); } } @@ -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(); } @@ -261,7 +302,8 @@ public class PCAPanel extends GPCAPanel implements Runnable, try { cap.setText(pcaModel.getDetails()); - Desktop.addInternalFrame(cap, MessageManager.getString("label.pca_details"), 500, 500); + Desktop.addInternalFrame(cap, + MessageManager.getString("label.pca_details"), 500, 500); } catch (OutOfMemoryError oom) { new OOMWarning("opening PCA details", oom); @@ -335,8 +377,10 @@ public class PCAPanel extends GPCAPanel implements Runnable, // af.addSortByOrderMenuItem(ServiceName + " Ordering", // msaorder); - Desktop.addInternalFrame(af, MessageManager.formatMessage("label.original_data_for_params", new String[]{this.title}), - AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); + Desktop.addInternalFrame(af, MessageManager.formatMessage( + "label.original_data_for_params", new String[] + { this.title }), AlignFrame.DEFAULT_WIDTH, + AlignFrame.DEFAULT_HEIGHT); } } /* @@ -524,7 +568,9 @@ public class PCAPanel extends GPCAPanel implements Runnable, cap.setText(pcaModel.getPointsasCsv(false, xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(), zCombobox.getSelectedIndex())); - Desktop.addInternalFrame(cap, MessageManager.formatMessage("label.points_for_params", new String[]{this.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,8 +593,9 @@ public class PCAPanel extends GPCAPanel implements Runnable, cap.setText(pcaModel.getPointsasCsv(true, xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(), zCombobox.getSelectedIndex())); - Desktop.addInternalFrame(cap, MessageManager.formatMessage("label.transformed_points_for_params", new String[]{this.getTitle()}), - 500, 500); + Desktop.addInternalFrame(cap, MessageManager.formatMessage( + "label.transformed_points_for_params", new String[] + { this.getTitle() }), 500, 500); } catch (OutOfMemoryError oom) { new OOMWarning("exporting transformed PCA points", oom); @@ -619,14 +666,14 @@ public class PCAPanel extends GPCAPanel implements Runnable, { if (progressBarHandlers == null || !progressBars.contains(new Long(id))) { - throw new Error( - "call setProgressBar before registering the progress bar's handler."); + throw new Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler")); } progressBarHandlers.put(new Long(id), handler); final JPanel progressPanel = (JPanel) progressBars.get(new Long(id)); if (handler.canCancel()) { - JButton cancel = new JButton(MessageManager.getString("action.cancel")); + JButton cancel = new JButton( + MessageManager.getString("action.cancel")); final IProgressIndicator us = this; cancel.addActionListener(new ActionListener() { @@ -635,10 +682,7 @@ public class PCAPanel extends GPCAPanel implements Runnable, public void actionPerformed(ActionEvent e) { handler.cancelActivity(id); - us.setProgressBar( - "Cancelled " - + ((JLabel) progressPanel.getComponent(0)) - .getText(), id); + us.setProgressBar(MessageManager.formatMessage("label.cancelled_params", new String[]{((JLabel) progressPanel.getComponent(0)).getText()}), id); } }); progressPanel.add(cancel, BorderLayout.EAST);