X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fappletgui%2FPCAPanel.java;h=fc1d359c44b813389cbf0697289fc75d2c564796;hb=0b93ce8953aaec40a5e06f076cd0b7378f44291d;hp=44711d77c42d5ee2d9019c1f1999d8acc974258e;hpb=586a4ea7a3b1b31f038d2fb56d55a2fbcae79460;p=jalview.git
diff --git a/src/jalview/appletgui/PCAPanel.java b/src/jalview/appletgui/PCAPanel.java
old mode 100755
new mode 100644
index 44711d7..fc1d359
--- a/src/jalview/appletgui/PCAPanel.java
+++ b/src/jalview/appletgui/PCAPanel.java
@@ -1,33 +1,55 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
- * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ 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.appletgui;
-import java.util.*;
-
-import java.awt.*;
-import java.awt.event.*;
-
-import jalview.analysis.*;
-import jalview.datamodel.*;
+import jalview.analysis.scoremodels.ScoreModels;
+import jalview.analysis.scoremodels.SimilarityParams;
+import jalview.api.analysis.ScoreModelI;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentView;
+import jalview.datamodel.HiddenColumns;
+import jalview.datamodel.SeqCigar;
+import jalview.datamodel.SequenceI;
+import jalview.util.MessageManager;
import jalview.viewmodel.PCAModel;
-public class PCAPanel extends EmbmenuFrame implements Runnable,
- ActionListener, ItemListener
+import java.awt.BorderLayout;
+import java.awt.Button;
+import java.awt.CheckboxMenuItem;
+import java.awt.Choice;
+import java.awt.Color;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.Label;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.Panel;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+public class PCAPanel extends EmbmenuFrame
+ implements Runnable, ActionListener, ItemListener
{
RotatableCanvas rc;
@@ -37,7 +59,7 @@ public class PCAPanel extends EmbmenuFrame implements Runnable,
int top = 0;
- public PCAPanel(AlignViewport av)
+ public PCAPanel(AlignViewport viewport)
{
try
{
@@ -54,18 +76,20 @@ public class PCAPanel extends EmbmenuFrame implements Runnable,
zCombobox.addItem("dim " + i);
}
- this.av = av;
- AlignmentView seqstrings = av
- .getAlignmentView(av.getSelectionGroup() != null);
- boolean nucleotide = av.getAlignment().isNucleotide();
+ this.av = viewport;
+ boolean selected = viewport.getSelectionGroup() != null
+ && viewport.getSelectionGroup().getSize() > 0;
+ AlignmentView seqstrings = viewport.getAlignmentView(selected);
+ boolean nucleotide = viewport.getAlignment().isNucleotide();
SequenceI[] seqs;
- if (av.getSelectionGroup() == null)
+ if (!selected)
{
- seqs = av.getAlignment().getSequencesArray();
+ seqs = viewport.getAlignment().getSequencesArray();
}
else
{
- seqs = av.getSelectionGroup().getSequencesInOrder(av.getAlignment());
+ seqs = viewport.getSelectionGroup()
+ .getSequencesInOrder(viewport.getAlignment());
}
SeqCigar sq[] = seqstrings.getSequences();
int length = sq[0].getWidth();
@@ -79,13 +103,18 @@ public class PCAPanel extends EmbmenuFrame implements Runnable,
return;
}
}
- pcaModel = new PCAModel(seqstrings, seqs, nucleotide);
- rc = new RotatableCanvas(av);
+ ScoreModelI scoreModel = ScoreModels.getInstance()
+ .getDefaultModel(!nucleotide);
+ pcaModel = new PCAModel(seqstrings, seqs, nucleotide, scoreModel,
+ SimilarityParams.SeqSpace);
+
+ rc = new RotatableCanvas(viewport);
embedMenuIfNeeded(rc);
add(rc, BorderLayout.CENTER);
- jalview.bin.JalviewLite.addFrame(this, "Principal component analysis",
+ jalview.bin.JalviewLite.addFrame(this,
+ MessageManager.getString("label.principal_component_analysis"),
475, 400);
Thread worker = new Thread(this);
@@ -95,6 +124,7 @@ public class PCAPanel extends EmbmenuFrame implements Runnable,
/**
* DOCUMENT ME!
*/
+ @Override
public void run()
{
// TODO progress indicator
@@ -132,7 +162,7 @@ public class PCAPanel extends EmbmenuFrame implements Runnable,
{
return;
}
-
+
int dim1 = top - xCombobox.getSelectedIndex();
int dim2 = top - yCombobox.getSelectedIndex();
int dim3 = top - zCombobox.getSelectedIndex();
@@ -143,6 +173,7 @@ public class PCAPanel extends EmbmenuFrame implements Runnable,
rc.paint(rc.getGraphics());
}
+ @Override
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == inputData)
@@ -162,6 +193,7 @@ public class PCAPanel extends EmbmenuFrame implements Runnable,
}
}
+ @Override
public void itemStateChanged(ItemEvent evt)
{
if (evt.getSource() == xCombobox)
@@ -185,6 +217,9 @@ public class PCAPanel extends EmbmenuFrame implements Runnable,
if (!pcaModel.isNucleotide())
{
pcaModel.setNucleotide(true);
+ ScoreModelI scoreModel = ScoreModels.getInstance()
+ .getDefaultModel(false);
+ pcaModel.setScoreModel(scoreModel);
new Thread(this).start();
}
}
@@ -193,6 +228,9 @@ public class PCAPanel extends EmbmenuFrame implements Runnable,
if (pcaModel.isNucleotide())
{
pcaModel.setNucleotide(false);
+ ScoreModelI scoreModel = ScoreModels.getInstance()
+ .getDefaultModel(true);
+ pcaModel.setScoreModel(scoreModel);
new Thread(this).start();
}
}
@@ -219,7 +257,8 @@ public class PCAPanel extends EmbmenuFrame implements Runnable,
CutAndPasteTransfer cap = new CutAndPasteTransfer(false, null);
Frame frame = new Frame();
frame.add(cap);
- jalview.bin.JalviewLite.addFrame(frame, "PCA details", 500, 500);
+ jalview.bin.JalviewLite.addFrame(frame,
+ MessageManager.getString("label.pca_details"), 500, 500);
cap.setText(pcaModel.getDetails());
}
@@ -243,15 +282,16 @@ public class PCAPanel extends EmbmenuFrame implements Runnable,
}
;
Object[] alAndColsel = pcaModel.getSeqtrings()
- .getAlignmentAndColumnSelection(gc);
+ .getAlignmentAndHiddenColumns(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
Alignment al = new Alignment((SequenceI[]) alAndColsel[0]);
- AlignFrame af = new AlignFrame(al, av.applet,
- "Original Data for PCA", false);
+ AlignFrame af = new AlignFrame(al, av.applet, "Original Data for PCA",
+ false);
- af.viewport.setHiddenColumns((ColumnSelection) alAndColsel[1]);
+ af.viewport.getAlignment()
+ .setHiddenColumns((HiddenColumns) alAndColsel[1]);
}
}
@@ -316,20 +356,21 @@ public class PCAPanel extends EmbmenuFrame implements Runnable,
xCombobox.setFont(new java.awt.Font("Verdana", 0, 12));
xCombobox.addItemListener(this);
resetButton.setFont(new java.awt.Font("Verdana", 0, 12));
- resetButton.setLabel("Reset");
+ resetButton.setLabel(MessageManager.getString("action.reset"));
resetButton.addActionListener(this);
this.setMenuBar(menuBar1);
- menu1.setLabel("File");
- menu2.setLabel("View");
- calcSettings.setLabel("Change Parameters");
- labels.setLabel("Labels");
+ menu1.setLabel(MessageManager.getString("action.file"));
+ menu2.setLabel(MessageManager.getString("action.view"));
+ calcSettings.setLabel(MessageManager.getString("action.change_params"));
+ labels.setLabel(MessageManager.getString("label.labels"));
labels.addItemListener(this);
- values.setLabel("Output Values...");
+ values.setLabel(MessageManager.getString("label.output_values"));
values.addActionListener(this);
- inputData.setLabel("Input Data...");
- nuclSetting.setLabel("Nucleotide matrix");
+ inputData.setLabel(MessageManager.getString("label.input_data"));
+ nuclSetting
+ .setLabel(MessageManager.getString("label.nucleotide_matrix"));
nuclSetting.addItemListener(this);
- protSetting.setLabel("Protein matrix");
+ protSetting.setLabel(MessageManager.getString("label.protein_matrix"));
protSetting.addItemListener(this);
this.add(jPanel2, BorderLayout.SOUTH);
jPanel2.add(jLabel1, null);