JAL-1152 annotation sorting preferences and help documentation
[jalview.git] / src / jalview / analysis / AnnotationSorter.java
index b9e9ed5..28fa1f8 100644 (file)
@@ -17,9 +17,43 @@ import java.util.Comparator;
 public class AnnotationSorter
 {
 
+  /**
+   * enum for annotation sort options. The text description is used in the
+   * Preferences drop-down options. The enum name is saved in the preferences
+   * file.
+   * 
+   * @author gmcarstairs
+   *
+   */
   public enum SequenceAnnotationOrder
   {
-    SEQUENCE_AND_LABEL, LABEL_AND_SEQUENCE, NONE
+    // Text descriptions surface in the Preferences Sort by... options
+    SEQUENCE_AND_LABEL("Sequence"), LABEL_AND_SEQUENCE("Label"), NONE(
+            "No sort");
+
+    private String description;
+
+    private SequenceAnnotationOrder(String s)
+    {
+      description = s;
+    }
+
+    @Override
+    public String toString()
+    {
+      return description;
+    }
+
+    public static SequenceAnnotationOrder forDescription(String d) {
+      for (SequenceAnnotationOrder order : values())
+      {
+        if (order.toString().equals(d))
+        {
+          return order;
+        }
+      }
+      return null;
+    }
   }
 
   private final AlignmentI alignment;