/*
- * 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 2.8.0b1)
+ * 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.
- *
+ *
* 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/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.gui;
import java.awt.print.*;
import javax.swing.*;
-import jalview.analysis.*;
import jalview.datamodel.*;
import jalview.jbgui.*;
import jalview.viewmodel.PCAModel;
* @author $author$
* @version $Revision$
*/
-public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator
+public class PCAPanel extends GPCAPanel implements Runnable,
+ IProgressIndicator
{
-
RotatableCanvas rc;
AlignmentPanel ap;
AlignViewport av;
+
PCAModel pcaModel;
- int top=0;
+
+ int top = 0;
/**
* Creates a new PCAPanel object.
this.ap = ap;
boolean sameLength = true;
-
- AlignmentView seqstrings = av.getAlignmentView(av.getSelectionGroup() != null);
- boolean nucleotide=av.getAlignment().isNucleotide();
+ boolean selected = av.getSelectionGroup() != null
+ && av.getSelectionGroup().getSize() > 0;
+ AlignmentView seqstrings = av.getAlignmentView(selected);
+ boolean nucleotide = av.getAlignment().isNucleotide();
SequenceI[] seqs;
- if (av.getSelectionGroup() == null)
+ if (!selected)
{
seqs = av.getAlignment().getSequencesArray();
}
}
pcaModel = new PCAModel(seqstrings, seqs, nucleotide);
PaintRefresher.Register(this, av.getSequenceSetId());
-
+
rc = new RotatableCanvas(ap);
this.getContentPane().add(rc, BorderLayout.CENTER);
Thread worker = new Thread(this);
*/
public void run()
{
- long progId=System.currentTimeMillis();
- IProgressIndicator progress=this;
- String message="Recalculating PCA";
- if (getParent()==null) {
- progress=ap.alignFrame;
+ long progId = System.currentTimeMillis();
+ IProgressIndicator progress = this;
+ String message = "Recalculating PCA";
+ if (getParent() == null)
+ {
+ progress = ap.alignFrame;
message = "Calculating PCA";
}
progress.setProgressBar(message, progId);
xCombobox.setSelectedIndex(0);
yCombobox.setSelectedIndex(1);
zCombobox.setSelectedIndex(2);
-
+
pcaModel.updateRc(rc);
// rc.invalidate();
nuclSetting.setSelected(pcaModel.isNucleotide());
protSetting.setSelected(!pcaModel.isNucleotide());
- top=pcaModel.getTop();
jvVersionSetting.setSelected(pcaModel.isJvCalcMode());
+ top = pcaModel.getTop();
} catch (OutOfMemoryError er)
{
new OOMWarning("calculating PCA", er);
return;
- }
- finally {
+ } finally
+ {
progress.setProgressBar("", progId);
}
calcSettings.setEnabled(true);
repaint();
- if (getParent()==null)
+ if (getParent() == null)
{
addKeyListener(rc);
- Desktop.addInternalFrame(this, "Principal component analysis", 475, 450);
+ Desktop.addInternalFrame(this, "Principal component analysis", 475,
+ 450);
}
}
+
@Override
protected void nuclSetting_actionPerfomed(ActionEvent arg0)
{
if (!pcaModel.isNucleotide())
{
pcaModel.setNucleotide(true);
- Thread worker = new Thread(this);
- worker.start();
+ Thread worker = new Thread(this);
+ worker.start();
}
-
+
}
+
@Override
protected void protSetting_actionPerfomed(ActionEvent arg0)
{
-
+
if (pcaModel.isNucleotide())
{
pcaModel.setNucleotide(false);
{
}
;
- Object[] alAndColsel = pcaModel.getSeqtrings().getAlignmentAndColumnSelection(gc);
+ Object[] alAndColsel = pcaModel.getSeqtrings()
+ .getAlignmentAndColumnSelection(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
CutAndPasteTransfer cap = new CutAndPasteTransfer();
try
{
- cap.setText(pcaModel.getPointsasCsv(false, xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(), zCombobox.getSelectedIndex()));
+ cap.setText(pcaModel.getPointsasCsv(false,
+ xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(),
+ zCombobox.getSelectedIndex()));
Desktop.addInternalFrame(cap, "Points for " + getTitle(), 500, 500);
} catch (OutOfMemoryError oom)
{
}
}
-
-
/*
* (non-Javadoc)
*
CutAndPasteTransfer cap = new CutAndPasteTransfer();
try
{
- cap.setText(pcaModel.getPointsasCsv(true, xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(), zCombobox.getSelectedIndex()));
+ cap.setText(pcaModel.getPointsasCsv(true,
+ xCombobox.getSelectedIndex(), yCombobox.getSelectedIndex(),
+ zCombobox.getSelectedIndex()));
Desktop.addInternalFrame(cap, "Transformed points for " + getTitle(),
500, 500);
} catch (OutOfMemoryError oom)
/*
* (non-Javadoc)
- *
+ *
* @see jalview.gui.IProgressIndicator#setProgressBar(java.lang.String, long)
*/
@Override
}
/**
- *
+ *
* @return true if any progress bars are still active
*/
@Override
}
return false;
}
+
@Override
protected void resetButton_actionPerformed(ActionEvent e)
{
- int t=top;
- top=0; // ugly - prevents dimensionChanged events from being processed
+ int t = top;
+ top = 0; // ugly - prevents dimensionChanged events from being processed
xCombobox.setSelectedIndex(0);
yCombobox.setSelectedIndex(1);
- top=t;
+ top = t;
zCombobox.setSelectedIndex(2);
}
}