/*
- * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
- * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
*
- * This program 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 2
- * of the License, or (at your option) any later version.
+ * This file is part of Jalview.
*
- * This program 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.
+ * 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.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ * 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/>.
*/
package jalview.gui;
*/
public class PCAPanel extends GPCAPanel implements Runnable
{
+
PCA pca;
int top;
* Creates a new PCAPanel object.
*
* @param av
- * DOCUMENT ME!
+ * DOCUMENT ME!
* @param s
- * DOCUMENT ME!
+ * DOCUMENT ME!
*/
public PCAPanel(AlignmentPanel ap)
{
* DOCUMENT ME!
*
* @param e
- * DOCUMENT ME!
+ * DOCUMENT ME!
*/
protected void xCombobox_actionPerformed(ActionEvent e)
{
* DOCUMENT ME!
*
* @param e
- * DOCUMENT ME!
+ * DOCUMENT ME!
*/
protected void yCombobox_actionPerformed(ActionEvent e)
{
* DOCUMENT ME!
*
* @param e
- * DOCUMENT ME!
+ * DOCUMENT ME!
*/
protected void zCombobox_actionPerformed(ActionEvent e)
{
public void outputValues_actionPerformed(ActionEvent e)
{
CutAndPasteTransfer cap = new CutAndPasteTransfer();
- Desktop.addInternalFrame(cap, "PCA details", 500, 500);
-
- cap.setText(pca.getDetails());
+ try {
+ cap.setText(pca.getDetails());
+ Desktop.addInternalFrame(cap, "PCA details", 500, 500);
+ } catch (OutOfMemoryError oom)
+ {
+ new OOMWarning("opening PCA details",oom);
+ cap.dispose();
+ }
}
public void showLabels_actionPerformed(ActionEvent e)
* CutAndPasteTransfer cap = new CutAndPasteTransfer(); for (int i = 0; i <
* seqs.length; i++) { cap.appendText(new jalview.util.Format("%-" + 15 +
* "s").form( seqs[i].getName())); cap.appendText(" " + seqstrings[i] +
- * "\n");
- * }
+ * "\n"); }
*
* Desktop.addInternalFrame(cap, "Original Data", 400, 400);
*/
* DOCUMENT ME!
*
* @param e
- * DOCUMENT ME!
+ * DOCUMENT ME!
*/
public void eps_actionPerformed(ActionEvent e)
{
* DOCUMENT ME!
*
* @param e
- * DOCUMENT ME!
+ * DOCUMENT ME!
*/
public void png_actionPerformed(ActionEvent e)
{
associateViewsMenu.add(itemf);
}
+ /* (non-Javadoc)
+ * @see jalview.jbgui.GPCAPanel#outputPoints_actionPerformed(java.awt.event.ActionEvent)
+ */
+ protected void outputPoints_actionPerformed(ActionEvent e)
+ {
+ CutAndPasteTransfer cap = new CutAndPasteTransfer();
+ try {
+ cap.setText(getPointsasCsv(false));
+ Desktop.addInternalFrame(cap, "Points for "+getTitle(), 500, 500);
+ } catch (OutOfMemoryError oom)
+ {
+ new OOMWarning("exporting PCA points",oom);
+ cap.dispose();
+ }
+ }
+
+ private String getPointsasCsv(boolean transformed)
+ {
+ StringBuffer csv = new StringBuffer();
+ csv.append("\"Sequence\"");
+ if (transformed) {
+ csv.append(",");
+ csv.append(xCombobox.getSelectedIndex());
+ csv.append(",");
+ csv.append(yCombobox.getSelectedIndex());
+ csv.append(",");
+ csv.append(zCombobox.getSelectedIndex());
+ } else {
+ for (int d=1,dmax=pca.component(1).length;d<=dmax;d++)
+ {
+ csv.append(","+d);
+ }
+ }
+ csv.append("\n");
+ for (int s=0;s<seqs.length;s++)
+ {
+ csv.append("\""+seqs[s].getName()+"\"");
+ double fl[];
+ if (!transformed) {
+ // output pca in correct order
+ fl = pca.component(s);
+ for (int d=fl.length-1; d>=0;d--)
+ {
+ csv.append(",");
+ csv.append(fl[d]);
+ }
+ } else {
+ // output current x,y,z coords for points
+ fl = rc.getPointPosition(s);
+ for (int d=0; d<fl.length;d++)
+ {
+ csv.append(",");
+ csv.append(fl[d]);
+ }
+ }
+ csv.append("\n");
+ }
+ return csv.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see jalview.jbgui.GPCAPanel#outputProjPoints_actionPerformed(java.awt.event.ActionEvent)
+ */
+ protected void outputProjPoints_actionPerformed(ActionEvent e)
+ {
+ CutAndPasteTransfer cap = new CutAndPasteTransfer();
+ try {
+ cap.setText(getPointsasCsv(true));
+ Desktop.addInternalFrame(cap, "Transformed points for "+getTitle(), 500, 500);
+ } catch (OutOfMemoryError oom)
+ {
+ new OOMWarning("exporting transformed PCA points",oom);
+ cap.dispose();
+ }
+ }
}