Merge branch 'develop' into features/JAL-2393customMatrices
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index 47dceec..0015299 100644 (file)
@@ -823,7 +823,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
   public void updateConsensus(final AlignmentViewPanel ap)
   {
     // see note in mantis : issue number 8585
-    if ((consensus == null || gapcounts == null) || !autoCalculateConsensus)
+    if (consensus == null || !autoCalculateConsensus)
     {
       return;
     }
@@ -1284,6 +1284,8 @@ public abstract class AlignmentViewport implements AlignViewportI,
 
   protected boolean showConsensus = true;
 
+  protected boolean showOccupancy = true;
+
   private Map<SequenceI, Color> sequenceColours = new HashMap<SequenceI, Color>();
 
   protected SequenceAnnotationOrder sortAnnotationsBy = null;
@@ -1893,11 +1895,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
       consensus = new AlignmentAnnotation("Consensus", "PID",
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       initConsensus(consensus);
-      gapcounts = new AlignmentAnnotation("Occupancy",
-              "Number of aligned positions",
-              new Annotation[1], 0f, alignment.getHeight(),
-              AlignmentAnnotation.BAR_GRAPH);
-      initGapCounts(gapcounts);
+      initGapCounts();
 
       initComplementConsensus();
     }
@@ -1954,15 +1952,19 @@ public abstract class AlignmentViewport implements AlignViewportI,
 
   // these should be extracted from the view model - style and settings for
   // derived annotation
-  private void initGapCounts(AlignmentAnnotation counts)
+  private void initGapCounts()
   {
-    counts.hasText = false;
-    counts.autoCalculated = true;
-    counts.graph = AlignmentAnnotation.BAR_GRAPH;
-
-    if (showConsensus)
+    if (showOccupancy)
     {
-      alignment.addAnnotation(counts);
+      gapcounts = new AlignmentAnnotation("Occupancy",
+              "Number of aligned positions", new Annotation[1], 0f,
+              alignment.getHeight(), AlignmentAnnotation.BAR_GRAPH);
+      gapcounts.hasText = true;
+      gapcounts.autoCalculated = true;
+      gapcounts.scaleColLabel = true;
+      gapcounts.graph = AlignmentAnnotation.BAR_GRAPH;
+
+      alignment.addAnnotation(gapcounts);
     }
   }