\r
public void PCAMenuItem_actionPerformed(ActionEvent e)\r
{\r
+ //are the sequences aligned?\r
+ if (!viewport.alignment.isAligned())\r
+ {\r
+ SequenceI current;\r
+ int Width = viewport.getAlignment().getWidth();\r
+\r
+ for (int i = 0; i < viewport.getAlignment().getSequences().size();\r
+ i++)\r
+ {\r
+ current = viewport.getAlignment().getSequenceAt(i);\r
+\r
+ if (current.getLength() < Width)\r
+ {\r
+ current.insertCharAt(Width - 1, viewport.getGapCharacter());\r
+ }\r
+ }\r
+ alignPanel.repaint();\r
+ }\r
\r
if ( (viewport.getSelectionGroup() != null &&\r
viewport.getSelectionGroup().getSize() < 4 &&\r
*/\r
public void font_actionPerformed(ActionEvent e)\r
{\r
- FontChooser fc = new FontChooser(alignPanel);\r
+ new FontChooser(alignPanel);\r
}\r
\r
/**\r
return;\r
}\r
\r
- PCAPanel pcaPanel = new PCAPanel(viewport);\r
- JInternalFrame frame = new JInternalFrame();\r
- frame.setContentPane(pcaPanel);\r
- Desktop.addInternalFrame(frame, "Principal component analysis",\r
- 400, 400);\r
+ new PCAPanel(viewport);\r
}\r
\r
/**\r
\r
import java.util.*;\r
import javax.swing.JOptionPane;\r
+import javax.swing.JInternalFrame;\r
\r
\r
/**\r
{\r
this.av = av;\r
\r
+ boolean sameLength = true;\r
+\r
if ((av.getSelectionGroup() != null) &&\r
(av.getSelectionGroup().getSize() > 3))\r
{\r
seqs = new Sequence[av.getSelectionGroup().getSize()];\r
-\r
+ int length = av.getSelectionGroup().getSequenceAt(0).getLength();\r
for (int i = 0; i < av.getSelectionGroup().getSize(); i++)\r
{\r
seqs[i] = av.getSelectionGroup().getSequenceAt(i);\r
+ if(seqs[i].getLength()!=length)\r
+ {\r
+ sameLength = false;\r
+ break;\r
+ }\r
}\r
}\r
else\r
{\r
seqs = new Sequence[av.getAlignment().getHeight()];\r
+ int length = av.alignment.getSequenceAt(0).getLength();\r
\r
for (int i = 0; i < av.getAlignment().getHeight(); i++)\r
{\r
seqs[i] = av.getAlignment().getSequenceAt(i);\r
+ if(seqs[i].getLength()!=length)\r
+ {\r
+ sameLength = false;\r
+ break;\r
+ }\r
+\r
}\r
}\r
\r
+ if (!sameLength)\r
+ {\r
+ JOptionPane.showMessageDialog(Desktop.desktop,\r
+ "The sequences must be aligned before calculating PCA.\n" +\r
+ "Try using the Pad function in the edit menu,\n" +\r
+ "or one of the multiple sequence alignment web services.",\r
+ "Sequences not aligned",\r
+ JOptionPane.WARNING_MESSAGE);\r
+\r
+ return;\r
+ }\r
+\r
+ JInternalFrame frame = new JInternalFrame();\r
+ frame.setContentPane(this);\r
+ Desktop.addInternalFrame(frame, "Principal component analysis",\r
+ 400, 400);\r
+\r
\r
rc = new RotatableCanvas(av);\r
add(rc, BorderLayout.CENTER);\r