JAL-3485 (enum) constants for Auto-annotation label and preference key
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index 8dc7bbd..01c7bb2 100644 (file)
@@ -81,6 +81,27 @@ import java.util.Map;
 public abstract class AlignmentViewport
         implements AlignViewportI, CommandListener, VamsasSource
 {
+  /**
+   * An enum for auto-calculated annotations, with constants for the
+   * annotation's label, and the key for the property to show it or not
+   */
+  public enum AutoAnnotation
+  {
+    CONSERVATION("Conservation", "SHOW_CONSERVATION"),
+    QUALITY("Quality", "SHOW_QUALITY"),
+    CONSENSUS("Consensus", "SHOW_IDENTITY"),
+    OCCUPANCY("Occupancy", "SHOW_OCCUPANCY");
+    
+    public final String label;
+    public final String preferenceKey;
+    
+    private AutoAnnotation(String lbl, String prefKey)
+    {
+      this.label = lbl;
+      this.preferenceKey = prefKey;
+    }
+  }
+
   protected ViewportRanges ranges;
 
   protected ViewStyleI viewStyle = new ViewStyle();
@@ -1938,7 +1959,7 @@ public abstract class AlignmentViewport
       {
         initRNAStructure();
       }
-      consensus = new AlignmentAnnotation("Consensus",
+      consensus = new AlignmentAnnotation(AutoAnnotation.CONSENSUS.label,
               MessageManager.getString("label.consensus_descr"),
               new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
       initConsensus(consensus);
@@ -1999,13 +2020,11 @@ public abstract class AlignmentViewport
     }
   }
 
-  // these should be extracted from the view model - style and settings for
-  // derived annotation
   private void initGapCounts()
   {
     if (showOccupancy)
     {
-      gapcounts = new AlignmentAnnotation("Occupancy",
+      gapcounts = new AlignmentAnnotation(AutoAnnotation.OCCUPANCY.label,
               MessageManager.getString("label.occupancy_descr"),
               new Annotation[1], 0f, alignment.getHeight(),
               AlignmentAnnotation.BAR_GRAPH);
@@ -2024,7 +2043,8 @@ public abstract class AlignmentViewport
     {
       if (conservation == null)
       {
-        conservation = new AlignmentAnnotation("Conservation",
+        conservation = new AlignmentAnnotation(
+                AutoAnnotation.CONSERVATION.label,
                 MessageManager.formatMessage("label.conservation_descr",
                         getConsPercGaps()),
                 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
@@ -2041,7 +2061,7 @@ public abstract class AlignmentViewport
     {
       if (quality == null)
       {
-        quality = new AlignmentAnnotation("Quality",
+        quality = new AlignmentAnnotation(AutoAnnotation.QUALITY.label,
                 MessageManager.getString("label.quality_descr"),
                 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
         quality.hasText = true;