Merge branch 'features/JAL-1596ChimeraREST' into develop
[jalview.git] / src / jalview / gui / AlignViewport.java
index 6d6531f..497dad4 100644 (file)
  */
 package jalview.gui;
 
+import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.analysis.NJTree;
 import jalview.api.AlignViewportI;
 import jalview.bin.Cache;
-import jalview.datamodel.AlignmentAnnotation;
+import jalview.commands.CommandI;
 import jalview.datamodel.AlignmentI;
-import jalview.datamodel.Annotation;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.PDBEntry;
 import jalview.datamodel.Sequence;
@@ -97,7 +97,9 @@ public class AlignViewport extends AlignmentViewport implements
 
   boolean showSequenceFeatures = false;
 
-  boolean showAnnotation = true;
+  private boolean showAnnotation = true;
+
+  SequenceAnnotationOrder sortAnnotationsBy = null;
 
   int charHeight;
 
@@ -127,7 +129,7 @@ public class AlignViewport extends AlignmentViewport implements
    * Keys are the feature types which are currently visible. Note: Values are
    * not used!
    */
-  Hashtable featuresDisplayed = null;
+  private Hashtable featuresDisplayed = null;
 
   boolean antiAlias = false;
 
@@ -137,9 +139,9 @@ public class AlignViewport extends AlignmentViewport implements
 
   boolean gatherViewsHere = false;
 
-  Stack historyList = new Stack();
+  Stack<CommandI> historyList = new Stack<CommandI>();
 
-  Stack redoList = new Stack();
+  Stack<CommandI> redoList = new Stack<CommandI>();
 
   int thresholdTextColour = 0;
 
@@ -147,7 +149,7 @@ public class AlignViewport extends AlignmentViewport implements
 
   Color textColour2 = Color.white;
 
-  boolean rightAlignIds = false;
+  private boolean rightAlignIds = false;
 
   /**
    * Creates a new AlignViewport object.
@@ -284,9 +286,9 @@ public class AlignViewport extends AlignmentViewport implements
     antiAlias = Cache.getDefault("ANTI_ALIAS", false);
 
     showJVSuffix = Cache.getDefault("SHOW_JVSUFFIX", true);
-    showAnnotation = Cache.getDefault("SHOW_ANNOTATIONS", true);
+    setShowAnnotation(Cache.getDefault("SHOW_ANNOTATIONS", true));
 
-    rightAlignIds = Cache.getDefault("RIGHT_ALIGN_IDS", false);
+    setRightAlignIds(Cache.getDefault("RIGHT_ALIGN_IDS", false));
     centreColumnLabels = Cache.getDefault("CENTRE_COLUMN_LABELS", false);
     autoCalculateConsensus = Cache.getDefault("AUTO_CALC_CONSENSUS", true);
 
@@ -334,10 +336,6 @@ public class AlignViewport extends AlignmentViewport implements
               false);
       showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
       showConsensus = Cache.getDefault("SHOW_IDENTITY", true);
-      consensus = new AlignmentAnnotation("Consensus", "PID",
-              new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
-      consensus.hasText = true;
-      consensus.autoCalculated = true;
     }
     initAutoAnnotation();
     if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null)
@@ -358,12 +356,15 @@ public class AlignViewport extends AlignmentViewport implements
       }
     }
 
-    wrapAlignment = jalview.bin.Cache.getDefault("WRAP_ALIGNMENT", false);
-    showUnconserved = jalview.bin.Cache.getDefault("SHOW_UNCONSERVED",
-            false);
-    sortByTree = jalview.bin.Cache.getDefault("SORT_BY_TREE", false);
-    followSelection = jalview.bin.Cache.getDefault("FOLLOW_SELECTIONS",
-            true);
+    wrapAlignment = Cache.getDefault("WRAP_ALIGNMENT", false);
+    showUnconserved = Cache.getDefault("SHOW_UNCONSERVED", false);
+    sortByTree = Cache.getDefault("SORT_BY_TREE", false);
+    followSelection = Cache.getDefault("FOLLOW_SELECTIONS", true);
+    sortAnnotationsBy = SequenceAnnotationOrder.valueOf(Cache.getDefault(
+            Preferences.SORT_ANNOTATIONS,
+            SequenceAnnotationOrder.NONE.name()));
+    showAutocalculatedAbove = Cache.getDefault(
+            Preferences.SHOW_AUTOCALC_ABOVE, false);
   }
 
   /**
@@ -838,7 +839,7 @@ public class AlignViewport extends AlignmentViewport implements
    */
   public boolean getShowAnnotation()
   {
-    return showAnnotation;
+    return isShowAnnotation();
   }
 
   /**
@@ -969,8 +970,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 +1210,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 +1220,9 @@ public class AlignViewport extends AlignmentViewport implements
           if (p1.getId().equals(pdb.getId()))
           {
             if (!seqs.contains(sq = alignment.getSequenceAt(i)))
+            {
               seqs.add(sq);
+            }
 
             continue;
           }
@@ -1247,6 +1254,8 @@ public class AlignViewport extends AlignmentViewport implements
 
   private Hashtable<String, AutoCalcSetting> calcIdParams = new Hashtable<String, AutoCalcSetting>();
 
+  private boolean showAutocalculatedAbove;
+
   public AutoCalcSetting getCalcIdSettingsFor(String calcId)
   {
     return calcIdParams.get(calcId);
@@ -1264,4 +1273,49 @@ public class AlignViewport extends AlignmentViewport implements
       Cache.log.debug("trigger update for " + calcId);
     }
   }
+
+
+  public Hashtable getFeaturesDisplayed()
+  {
+    return featuresDisplayed;
+  }
+
+  public void setFeaturesDisplayed(Hashtable featuresDisplayed)
+  {
+    this.featuresDisplayed = featuresDisplayed;
+  }
+  protected SequenceAnnotationOrder getSortAnnotationsBy()
+  {
+    return sortAnnotationsBy;
+  }
+
+  protected void setSortAnnotationsBy(SequenceAnnotationOrder sortAnnotationsBy)
+  {
+    this.sortAnnotationsBy = sortAnnotationsBy;
+  }
+
+  protected boolean isShowAutocalculatedAbove()
+  {
+    return showAutocalculatedAbove;
+  }
+
+  protected void setShowAutocalculatedAbove(boolean showAutocalculatedAbove)
+  {
+    this.showAutocalculatedAbove = showAutocalculatedAbove;
+  }
+
+  public boolean isShowAnnotation()
+  {
+    return showAnnotation;
+  }
+
+  public boolean isRightAlignIds()
+  {
+    return rightAlignIds;
+  }
+
+  public void setRightAlignIds(boolean rightAlignIds)
+  {
+    this.rightAlignIds = rightAlignIds;
+  }
 }