move sequences up and down
authoramwaterhouse <Andrew Waterhouse>
Fri, 11 Feb 2005 12:44:39 +0000 (12:44 +0000)
committeramwaterhouse <Andrew Waterhouse>
Fri, 11 Feb 2005 12:44:39 +0000 (12:44 +0000)
src/jalview/gui/AlignFrame.java

index 7f8b8e9..3a38769 100755 (executable)
@@ -197,6 +197,50 @@ public class AlignFrame extends GAlignFrame
       alignPanel.RefreshPanels();\r
   }\r
 \r
+  public void moveSelectedSequences(boolean up)\r
+  {\r
+    SequenceGroup sg = viewport.getRubberbandGroup();\r
+    if (sg == null)\r
+      return;\r
+\r
+    if (up)\r
+    {\r
+      for (int i = 1; i < viewport.alignment.getHeight(); i++)\r
+      {\r
+        SequenceI seq = viewport.alignment.getSequenceAt(i);\r
+        if (!sg.sequences.contains(seq))\r
+          continue;\r
+\r
+        SequenceI temp = viewport.alignment.getSequenceAt(i - 1);\r
+        if (sg.sequences.contains(temp))\r
+          continue;\r
+\r
+        viewport.alignment.getSequences().setElementAt(temp, i);\r
+        viewport.alignment.getSequences().setElementAt(seq, i - 1);\r
+      }\r
+    }\r
+    else\r
+    {\r
+      for (int i = viewport.alignment.getHeight() - 2; i > -1; i--)\r
+      {\r
+        SequenceI seq = viewport.alignment.getSequenceAt(i);\r
+        if (!sg.sequences.contains(seq))\r
+          continue;\r
+\r
+        SequenceI temp = viewport.alignment.getSequenceAt(i + 1);\r
+        if (sg.sequences.contains(temp))\r
+          continue;\r
+\r
+        viewport.alignment.getSequences().setElementAt(temp, i);\r
+        viewport.alignment.getSequences().setElementAt(seq, i + 1);\r
+      }\r
+    }\r
+\r
+    alignPanel.RefreshPanels();\r
+  }\r
+\r
+\r
+\r
   protected void copy_actionPerformed(ActionEvent e)\r
   {\r
    if(viewport.getRubberbandGroup()==null)\r