/* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, 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 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. * * 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 */ package jalview.gui; import jalview.datamodel.*; import jalview.analysis.PCA; import jalview.jbgui.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class PCAPanel extends GPCAPanel implements Runnable { PCA pca; int top; RotatableCanvas rc; AlignViewport av; public void run() { // do stuff } public PCAPanel(AlignViewport av, SequenceI[] s) { this.av = av; if(av.getSelectionGroup()!=null && av.getSelectionGroup().getSize()>3) { s = new Sequence[av.getSelectionGroup().getSize()]; for(int i=0; i 1e-4) { comps[i] = pca.component(i); } } ////////////////// xCombobox.setSelectedIndex(0); yCombobox.setSelectedIndex(1); zCombobox.setSelectedIndex(2); top = pca.getM().rows-1; Vector points = new Vector(); float[][] scores = pca.getComponents(top-1,top-2,top-3,100); for (int i =0; i < pca.getM().rows; i++ ) { SequencePoint sp = new SequencePoint(s[i],scores[i]); points.addElement(sp); } rc = new RotatableCanvas(av,points,pca.getM().rows); //rc.printPoints(); add(rc, BorderLayout.CENTER); } void doDimensionChange() { if(top==0) return; int dim1 = top - xCombobox.getSelectedIndex(); int dim2 = top - yCombobox.getSelectedIndex(); int dim3 = top - zCombobox.getSelectedIndex(); float[][] scores = pca.getComponents(dim1,dim2,dim3,100); for (int i=0; i < pca.getM().rows; i++) { ((SequencePoint)rc.points.elementAt(i)).coord = scores[i]; } rc.img = null; rc.rotmat.setIdentity(); rc.initAxes(); rc.paint(rc.getGraphics()); } protected void xCombobox_actionPerformed(ActionEvent e) { doDimensionChange(); } protected void yCombobox_actionPerformed(ActionEvent e) { doDimensionChange(); } protected void zCombobox_actionPerformed(ActionEvent e) { doDimensionChange(); } }