sort by length
authorjprocter <Jim Procter>
Fri, 30 Apr 2010 11:52:23 +0000 (11:52 +0000)
committerjprocter <Jim Procter>
Fri, 30 Apr 2010 11:52:23 +0000 (11:52 +0000)
src/jalview/appletgui/AlignFrame.java

index 954648e..56948e3 100755 (executable)
@@ -85,6 +85,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
         {
           sortPairwiseMenuItem_actionPerformed();
         }
+        else if (param.equalsIgnoreCase("Length"))
+        {
+          sortLengthMenuItem_actionPerformed();
+        }
       }
 
       param = applet.getParameter("wrap");
@@ -905,6 +909,10 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     {
       sortIDMenuItem_actionPerformed();
     }
+    else if (source == sortLengthMenuItem)
+    {
+      sortLengthMenuItem_actionPerformed();
+    }
     else if (source == sortGroupMenuItem)
     {
       sortGroupMenuItem_actionPerformed();
@@ -2268,6 +2276,14 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     alignPanel.paintAlignment(true);
   }
 
+  public void sortLengthMenuItem_actionPerformed()
+  {
+    SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
+    AlignmentSorter.sortByLength(viewport.getAlignment());
+    addHistoryItem(new OrderCommand("Length Sort", oldOrder, viewport.alignment));
+    alignPanel.paintAlignment(true);
+  }
+
   public void sortGroupMenuItem_actionPerformed()
   {
     SequenceI[] oldOrder = viewport.getAlignment().getSequencesArray();
@@ -2620,6 +2636,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
 
   MenuItem sortIDMenuItem = new MenuItem();
 
+  MenuItem sortLengthMenuItem = new MenuItem();
+
   MenuItem sortGroupMenuItem = new MenuItem();
 
   MenuItem removeRedundancyMenuItem = new MenuItem();
@@ -2797,6 +2815,8 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     sortPairwiseMenuItem.addActionListener(this);
     sortIDMenuItem.setLabel("by ID");
     sortIDMenuItem.addActionListener(this);
+    sortLengthMenuItem.setLabel("by Length");
+    sortLengthMenuItem.addActionListener(this);
     sortGroupMenuItem.setLabel("by Group");
     sortGroupMenuItem.addActionListener(this);
     removeRedundancyMenuItem.setLabel("Remove Redundancy...");
@@ -3040,6 +3060,7 @@ public class AlignFrame extends EmbmenuFrame implements ActionListener,
     pasteMenu.add(pasteNew);
     pasteMenu.add(pasteThis);
     sort.add(sortIDMenuItem);
+    sort.add(sortLengthMenuItem);
     sort.add(sortByTreeMenu);
     sort.add(sortGroupMenuItem);
     sort.add(sortPairwiseMenuItem);