+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ */\r
package jalview.gui;\r
\r
+import jalview.analysis.*;\r
+\r
import jalview.datamodel.*;\r
-import jalview.analysis.PCA;\r
+\r
import jalview.jbgui.*;\r
+\r
import java.awt.*;\r
import java.awt.event.*;\r
+\r
import java.util.*;\r
\r
\r
+/**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @author $author$\r
+ * @version $Revision$\r
+ */\r
public class PCAPanel extends GPCAPanel implements Runnable\r
{\r
- PCA pca;\r
- int top;\r
- RotatableCanvas rc;\r
- AlignViewport av;\r
-\r
- public void run()\r
- {\r
- // do stuff\r
- }\r
-\r
- public PCAPanel(AlignViewport av, SequenceI[] s) {\r
-\r
- this.av = av;\r
- if(av.getSelectionGroup()!=null && av.getSelectionGroup().getSize()>3)\r
+ PCA pca;\r
+ int top;\r
+ RotatableCanvas rc;\r
+ AlignViewport av;\r
+\r
+ /**\r
+ * Creates a new PCAPanel object.\r
+ *\r
+ * @param av DOCUMENT ME!\r
+ * @param s DOCUMENT ME!\r
+ */\r
+ public PCAPanel(AlignViewport av, SequenceI[] s)\r
{\r
- s = new Sequence[av.getSelectionGroup().getSize()];\r
- for(int i=0; i<s.length; i++)\r
- s[i] = av.getSelectionGroup().getSequenceAt(i);\r
+ this.av = av;\r
+\r
+ if ((av.getSelectionGroup() != null) &&\r
+ (av.getSelectionGroup().getSize() > 3))\r
+ {\r
+ s = new Sequence[av.getSelectionGroup().getSize()];\r
+\r
+ for (int i = 0; i < s.length; i++)\r
+ {\r
+ s[i] = av.getSelectionGroup().getSequenceAt(i);\r
+ }\r
+ }\r
+\r
+ if (s == null)\r
+ {\r
+ s = new Sequence[av.getAlignment().getHeight()];\r
+\r
+ for (int i = 0; i < av.getAlignment().getHeight(); i++)\r
+ {\r
+ s[i] = av.getAlignment().getSequenceAt(i);\r
+ }\r
+ }\r
+\r
+ //////////////////////This part was done in PCATHread originally. Is it too slow???\r
+ pca = new PCA(s);\r
+ pca.run();\r
+\r
+ // Now find the component coordinates\r
+ int ii = 0;\r
+\r
+ while ((ii < s.length) && (s[ii] != null))\r
+ {\r
+ ii++;\r
+ }\r
+\r
+ double[][] comps = new double[ii][ii];\r
+\r
+ for (int i = 0; i < ii; i++)\r
+ {\r
+ if (pca.getEigenvalue(i) > 1e-4)\r
+ {\r
+ comps[i] = pca.component(i);\r
+ }\r
+ }\r
+\r
+ //////////////////\r
+ xCombobox.setSelectedIndex(0);\r
+ yCombobox.setSelectedIndex(1);\r
+ zCombobox.setSelectedIndex(2);\r
+\r
+ top = pca.getM().rows - 1;\r
+\r
+ Vector points = new Vector();\r
+ float[][] scores = pca.getComponents(top - 1, top - 2, top - 3, 100);\r
+\r
+ for (int i = 0; i < pca.getM().rows; i++)\r
+ {\r
+ SequencePoint sp = new SequencePoint(s[i], scores[i]);\r
+ points.addElement(sp);\r
+ }\r
+\r
+ rc = new RotatableCanvas(av, points, pca.getM().rows);\r
+\r
+ //rc.printPoints();\r
+ add(rc, BorderLayout.CENTER);\r
}\r
\r
-\r
- if(s==null)\r
- {\r
- s = new Sequence[av.getAlignment().getHeight()];\r
- for (int i = 0; i < av.getAlignment().getHeight(); i++)\r
- s[i] = av.getAlignment().getSequenceAt(i);\r
- }\r
-\r
-//////////////////////This part was done in PCATHread originally. Is it too slow???\r
- pca = new PCA(s);\r
- pca.run();\r
-\r
- // Now find the component coordinates\r
- int ii=0;\r
- while (ii < s.length && s[ii] != null)\r
+ /**\r
+ * DOCUMENT ME!\r
+ */\r
+ public void run()\r
{\r
- ii++;\r
+ // do stuff\r
}\r
\r
- double[][] comps = new double[ii][ii];\r
-\r
- for (int i=0; i < ii; i++ )\r
+ /**\r
+ * DOCUMENT ME!\r
+ */\r
+ void doDimensionChange()\r
{\r
- if (pca.getEigenvalue(i) > 1e-4)\r
- {\r
- comps[i] = pca.component(i);\r
- }\r
+ if (top == 0)\r
+ {\r
+ return;\r
+ }\r
+\r
+ int dim1 = top - xCombobox.getSelectedIndex();\r
+ int dim2 = top - yCombobox.getSelectedIndex();\r
+ int dim3 = top - zCombobox.getSelectedIndex();\r
+\r
+ float[][] scores = pca.getComponents(dim1, dim2, dim3, 100);\r
+\r
+ for (int i = 0; i < pca.getM().rows; i++)\r
+ {\r
+ ((SequencePoint) rc.points.elementAt(i)).coord = scores[i];\r
+ }\r
+\r
+ rc.img = null;\r
+ rc.rotmat.setIdentity();\r
+ rc.initAxes();\r
+ rc.paint(rc.getGraphics());\r
}\r
\r
- //////////////////\r
-\r
- xCombobox.setSelectedIndex(0);\r
- yCombobox.setSelectedIndex(1);\r
- zCombobox.setSelectedIndex(2);\r
-\r
- top = pca.getM().rows-1;\r
-\r
- Vector points = new Vector();\r
- float[][] scores = pca.getComponents(top-1,top-2,top-3,100);\r
-\r
- for (int i =0; i < pca.getM().rows; i++ )\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param e DOCUMENT ME!\r
+ */\r
+ protected void xCombobox_actionPerformed(ActionEvent e)\r
{\r
- SequencePoint sp = new SequencePoint(s[i],scores[i]);\r
- points.addElement(sp);\r
+ doDimensionChange();\r
}\r
\r
- rc = new RotatableCanvas(av,points,pca.getM().rows);\r
-\r
- //rc.printPoints();\r
-\r
- add(rc, BorderLayout.CENTER);\r
- }\r
-\r
-\r
- void doDimensionChange()\r
- {\r
- if(top==0)\r
- return;\r
-\r
- int dim1 = top - xCombobox.getSelectedIndex();\r
- int dim2 = top - yCombobox.getSelectedIndex();\r
- int dim3 = top - zCombobox.getSelectedIndex();\r
-\r
- float[][] scores = pca.getComponents(dim1,dim2,dim3,100);\r
- for (int i=0; i < pca.getM().rows; i++) {\r
- ((SequencePoint)rc.points.elementAt(i)).coord = scores[i];\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param e DOCUMENT ME!\r
+ */\r
+ protected void yCombobox_actionPerformed(ActionEvent e)\r
+ {\r
+ doDimensionChange();\r
}\r
\r
- rc.img = null;\r
- rc.rotmat.setIdentity();\r
- rc.initAxes();\r
- rc.paint(rc.getGraphics());\r
- }\r
-\r
- protected void xCombobox_actionPerformed(ActionEvent e)\r
- {\r
- doDimensionChange();\r
- }\r
-\r
- protected void yCombobox_actionPerformed(ActionEvent e)\r
- {\r
- doDimensionChange();\r
- }\r
-\r
- protected void zCombobox_actionPerformed(ActionEvent e)\r
- {\r
- doDimensionChange();\r
- }\r
-\r
+ /**\r
+ * DOCUMENT ME!\r
+ *\r
+ * @param e DOCUMENT ME!\r
+ */\r
+ protected void zCombobox_actionPerformed(ActionEvent e)\r
+ {\r
+ doDimensionChange();\r
+ }\r
}\r