Merge develop to Release_2_8_3_Branch
[jalview.git] / src / jalview / commands / OrderCommand.java
index bc72406..5758e19 100644 (file)
  */
 package jalview.commands;
 
-import jalview.analysis.*;
-import jalview.datamodel.*;
+import jalview.analysis.AlignmentSorter;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SequenceI;
 
+/**
+ * An undoable command to reorder the sequences in an alignment.
+ * 
+ * @author gmcarstairs
+ *
+ */
 public class OrderCommand implements CommandI
 {
   String description;
 
+  /*
+   * The sequence order before sorting (target order for an undo)
+   */
   SequenceI[] seqs;
 
+  /*
+   * The sequence order specified by this command
+   */
   SequenceI[] seqs2;
 
+  /*
+   * The alignment the command acts on
+   */
   AlignmentI al;
 
+  /**
+   * Constructor given the 'undo' sequence order, and the (already) sorted
+   * alignment.
+   * 
+   * @param description
+   *          a text label for the 'undo' menu option
+   * @param seqs
+   *          the sequence order for undo
+   * @param al
+   *          the alignment as ordered by this command
+   */
   public OrderCommand(String description, SequenceI[] seqs, AlignmentI al)
   {
     this.description = description;
@@ -61,4 +88,15 @@ public class OrderCommand implements CommandI
   {
     AlignmentSorter.setOrder(al, seqs);
   }
+
+  /**
+   * Returns the sequence order used to sort, or before sorting if undo=true.
+   * 
+   * @param undo
+   * @return
+   */
+  public SequenceI[] getSequenceOrder(boolean undo)
+  {
+    return undo ? seqs : seqs2;
+  }
 }