JAL-1152 with sticky annotation sort order that updates as sequences are
[jalview.git] / src / jalview / gui / AlignViewport.java
index e9829bb..6969513 100644 (file)
@@ -1,19 +1,21 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
  * Copyright (C) 2014 The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * Jalview is free software: you can redistribute it and/or
  * modify it under the terms of the GNU General Public License 
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
  *  
  * Jalview is distributed in the hope that it will be useful, but 
  * WITHOUT ANY WARRANTY; without even the implied warranty 
  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
  * PURPOSE.  See the GNU General Public License for more details.
  * 
- * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 /*
@@ -36,6 +38,7 @@
  */
 package jalview.gui;
 
+import jalview.analysis.AnnotationSorter.SortOrder;
 import jalview.analysis.NJTree;
 import jalview.api.AlignViewportI;
 import jalview.bin.Cache;
@@ -97,6 +100,8 @@ public class AlignViewport extends AlignmentViewport implements
 
   boolean showAnnotation = true;
 
+  SortOrder sortAnnotationsBy = null;
+
   int charHeight;
 
   int charWidth;
@@ -356,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()));
   }
 
   /**
@@ -967,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() };
   }
@@ -1014,7 +1023,6 @@ public class AlignViewport extends AlignmentViewport implements
     centreColumnLabels = centrecolumnlabels;
   }
 
-
   /**
    * enable or disable the display of Database Cross References in the sequence
    * ID tooltip
@@ -1206,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++)
         {
@@ -1214,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;
           }
@@ -1263,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;
+  }
 }