X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fcommands%2FOrderCommand.java;h=5758e19aa1e4a14dc0f2110f7774c9f77df8993f;hb=be32c14cd8e48fe0a207cd7030cb9cd46f894678;hp=bc724068104c1d739d500d8f41a6a30bca4e43ad;hpb=10e637daad8983c41db8679baabea5563d7371f4;p=jalview.git diff --git a/src/jalview/commands/OrderCommand.java b/src/jalview/commands/OrderCommand.java index bc72406..5758e19 100644 --- a/src/jalview/commands/OrderCommand.java +++ b/src/jalview/commands/OrderCommand.java @@ -20,19 +20,46 @@ */ 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; + } }