JAL-1152 with sticky annotation sort order that updates as sequences are
[jalview.git] / src / jalview / gui / AlignViewport.java
index 6d6531f..6969513 100644 (file)
@@ -38,6 +38,7 @@
  */
 package jalview.gui;
 
+import jalview.analysis.AnnotationSorter.SortOrder;
 import jalview.analysis.NJTree;
 import jalview.api.AlignViewportI;
 import jalview.bin.Cache;
@@ -99,6 +100,8 @@ public class AlignViewport extends AlignmentViewport implements
 
   boolean showAnnotation = true;
 
+  SortOrder sortAnnotationsBy = null;
+
   int charHeight;
 
   int charWidth;
@@ -358,12 +361,14 @@ public class AlignViewport extends AlignmentViewport implements
       }
     }
 
-    wrapAlignment = jalview.bin.Cache.getDefault("WRAP_ALIGNMENT", false);
-    showUnconserved = jalview.bin.Cache.getDefault("SHOW_UNCONSERVED",
+    wrapAlignment = Cache.getDefault("WRAP_ALIGNMENT", false);
+    showUnconserved = Cache.getDefault("SHOW_UNCONSERVED",
             false);
-    sortByTree = jalview.bin.Cache.getDefault("SORT_BY_TREE", false);
-    followSelection = jalview.bin.Cache.getDefault("FOLLOW_SELECTIONS",
+    sortByTree = Cache.getDefault("SORT_BY_TREE", false);
+    followSelection = Cache.getDefault("FOLLOW_SELECTIONS",
             true);
+    sortAnnotationsBy = SortOrder.valueOf(Cache.getDefault(
+            "SORT_ANNOTATIONS", SortOrder.SEQUENCE_AND_TYPE.name()));
   }
 
   /**
@@ -969,8 +974,10 @@ public class AlignViewport extends AlignmentViewport implements
   {
     // TODO: JAL-1126
     if (historyList == null || redoList == null)
+    {
       return new long[]
       { -1, -1 };
+    }
     return new long[]
     { historyList.hashCode(), this.redoList.hashCode() };
   }
@@ -1207,7 +1214,9 @@ public class AlignViewport extends AlignmentViewport implements
         Vector pdbs = alignment.getSequenceAt(i).getDatasetSequence()
                 .getPDBId();
         if (pdbs == null)
+        {
           continue;
+        }
         SequenceI sq;
         for (int p = 0; p < pdbs.size(); p++)
         {
@@ -1215,7 +1224,9 @@ public class AlignViewport extends AlignmentViewport implements
           if (p1.getId().equals(pdb.getId()))
           {
             if (!seqs.contains(sq = alignment.getSequenceAt(i)))
+            {
               seqs.add(sq);
+            }
 
             continue;
           }
@@ -1264,4 +1275,14 @@ public class AlignViewport extends AlignmentViewport implements
       Cache.log.debug("trigger update for " + calcId);
     }
   }
+
+  protected SortOrder getSortAnnotationsBy()
+  {
+    return sortAnnotationsBy;
+  }
+
+  protected void setSortAnnotationsBy(SortOrder sortAnnotationsBy)
+  {
+    this.sortAnnotationsBy = sortAnnotationsBy;
+  }
 }