JAL-1264 adding show/hide annotation options to applet
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index df08682..7054ed3 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  */
 package jalview.viewmodel;
 
+import java.awt.Color;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
 import jalview.analysis.Conservation;
 import jalview.api.AlignCalcManagerI;
 import jalview.api.AlignViewportI;
@@ -51,17 +63,6 @@ import jalview.workers.ComplementConsensusThread;
 import jalview.workers.ConsensusThread;
 import jalview.workers.StrucConsensusThread;
 
-import java.awt.Color;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.BitSet;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * base class holding visualization and analysis attributes and common logic for
  * an active alignment view displayed in the GUI
@@ -1190,6 +1191,10 @@ public abstract class AlignmentViewport implements AlignViewportI,
 
   private Map<SequenceI, Color> sequenceColours = new HashMap<SequenceI, Color>();
 
+  protected SequenceAnnotationOrder sortAnnotationsBy = null;
+
+  protected boolean showAutocalculatedAbove;
+
   /**
    * Property change listener for changes in alignment
    * 
@@ -1718,17 +1723,26 @@ public abstract class AlignmentViewport implements AlignViewportI,
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       initConsensus(consensus);
 
-      if (!alignment.isNucleotide())
+      initComplementConsensus();
+    }
+  }
+
+  /**
+   * If this is a protein alignment and there are mappings to cDNA, add the cDNA
+   * consensus annotation.
+   */
+  protected void initComplementConsensus()
+  {
+    if (!alignment.isNucleotide())
+    {
+      final Set<AlignedCodonFrame> codonMappings = alignment
+              .getCodonFrames();
+      if (codonMappings != null && !codonMappings.isEmpty())
       {
-        final Set<AlignedCodonFrame> codonMappings = alignment
-                .getCodonFrames();
-        if (codonMappings != null && !codonMappings.isEmpty())
-        {
-          complementConsensus = new AlignmentAnnotation("cDNA Consensus",
-                  "PID for cDNA", new Annotation[1], 0f, 100f,
-                  AlignmentAnnotation.BAR_GRAPH);
-          initConsensus(complementConsensus);
-        }
+        complementConsensus = new AlignmentAnnotation("cDNA Consensus",
+                "PID for cDNA", new Annotation[1], 0f, 100f,
+                AlignmentAnnotation.BAR_GRAPH);
+        initConsensus(complementConsensus);
       }
     }
   }
@@ -2377,4 +2391,24 @@ public abstract class AlignmentViewport implements AlignViewportI,
   {
     return this;
   }
+
+  public SequenceAnnotationOrder getSortAnnotationsBy()
+  {
+    return sortAnnotationsBy;
+  }
+
+  public void setSortAnnotationsBy(SequenceAnnotationOrder sortAnnotationsBy)
+  {
+    this.sortAnnotationsBy = sortAnnotationsBy;
+  }
+
+  public boolean isShowAutocalculatedAbove()
+  {
+    return showAutocalculatedAbove;
+  }
+
+  public void setShowAutocalculatedAbove(boolean showAutocalculatedAbove)
+  {
+    this.showAutocalculatedAbove = showAutocalculatedAbove;
+  }
 }