JAL-969 - refactor initialisation of automatic annotation rows to base class
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 28 Oct 2011 16:22:16 +0000 (17:22 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 28 Oct 2011 16:22:16 +0000 (17:22 +0100)
src/jalview/appletgui/AlignViewport.java
src/jalview/gui/AlignViewport.java
src/jalview/viewmodel/AlignmentViewport.java

index 95aafab..e094d7d 100644 (file)
@@ -61,12 +61,6 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
 
   boolean showAnnotation = true;
 
-  boolean showConservation = true;
-
-  boolean showQuality = true;
-
-  boolean showConsensus = true;
-
   boolean upperCasebold = false;
 
   boolean colourAppliesToAllGroups = true;
@@ -254,56 +248,7 @@ public class AlignViewport extends AlignmentViewport implements AlignViewportI,
                 .getParameter("userDefinedColour"));
       }
     }
-    if (hconsensus == null)
-    {
-      if (!alignment.isNucleotide())
-      {
-        conservation = new AlignmentAnnotation("Conservation",
-                "Conservation of total alignment less than " + getConsPercGaps()
-                        + "% gaps", new Annotation[1], 0f, 11f,
-                AlignmentAnnotation.BAR_GRAPH);
-        conservation.hasText = true;
-        conservation.autoCalculated = true;
-
-        if (showConservation)
-        {
-          alignment.addAnnotation(conservation);
-        }
-
-        if (showQuality)
-        {
-          quality = new AlignmentAnnotation("Quality",
-                  "Alignment Quality based on Blosum62 scores",
-                  new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
-          quality.hasText = true;
-          quality.autoCalculated = true;
-
-          alignment.addAnnotation(quality);
-        }
-      } else {
-        if (alignment.hasRNAStructure())
-        {
-          strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
-                  new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
-          strucConsensus.hasText = true;
-          strucConsensus.autoCalculated = true;
-        }
-      }
-
-      consensus = new AlignmentAnnotation("Consensus", "PID",
-              new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
-      consensus.hasText = true;
-      consensus.autoCalculated = true;
-
-      if (showConsensus)
-      {
-        alignment.addAnnotation(consensus);
-        if (strucConsensus!=null)
-        {
-          alignment.addAnnotation(strucConsensus);
-        }
-      }
-    }
+    initAutoAnnotation();
 
   }
 
index c168b7b..8f615aa 100644 (file)
@@ -133,9 +133,6 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
    */
   Hashtable featuresDisplayed = null;
 
-
-  boolean isDataset = false;
-
   boolean antiAlias = false;
 
   Rectangle explodedPosition;
@@ -331,68 +328,23 @@ public class AlignViewport extends AlignmentViewport implements SelectionSource,
     {
       if (!alignment.isNucleotide())
       {
-        conservation = new AlignmentAnnotation("Conservation",
-                "Conservation of total alignment less than " + getConsPercGaps()
-                        + "% gaps", new Annotation[1], 0f, 11f,
-                AlignmentAnnotation.BAR_GRAPH);
-        conservation.hasText = true;
-        conservation.autoCalculated = true;
-
-        if (Cache.getDefault("SHOW_CONSERVATION", true))
-        {
-          alignment.addAnnotation(conservation);
-        }
-
-        if (Cache.getDefault("SHOW_QUALITY", true))
-        {
-          quality = new AlignmentAnnotation("Quality",
-                  "Alignment Quality based on Blosum62 scores",
-                  new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
-          quality.hasText = true;
-          quality.autoCalculated = true;
-
-          alignment.addAnnotation(quality);
-        }
+        showConservation=Cache.getDefault("SHOW_CONSERVATION", true);
+        showQuality=Cache.getDefault("SHOW_QUALITY", true);
         showGroupConservation = Cache.getDefault("SHOW_GROUP_CONSERVATION",
                 false);
-
-        {
-
-        }
-      }
+      } 
       showConsensusHistogram = Cache.getDefault("SHOW_CONSENSUS_HISTOGRAM",
               true);
       showSequenceLogo = Cache.getDefault("SHOW_CONSENSUS_LOGO", false);
       normaliseSequenceLogo = Cache.getDefault("NORMALISE_CONSENSUS_LOGO", false);
       showGroupConsensus = Cache.getDefault("SHOW_GROUP_CONSENSUS", false);
-      // TODO: add menu option action that nulls or creates consensus object
-      // depending on if the user wants to see the annotation or not in a
-      // specific alignment
+      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;
-
-      if (alignment.isNucleotide() && alignment.hasRNAStructure())
-      {
-        strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
-                new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
-        strucConsensus.hasText = true;
-        strucConsensus.autoCalculated = true;
-      }
-      
-      if (Cache.getDefault("SHOW_IDENTITY", true))
-      {
-        alignment.addAnnotation(consensus);
-        // TODO: Make own if for structure
-        if (alignment.isNucleotide() && alignment.hasRNAStructure())
-        {
-          alignment.addAnnotation(strucConsensus);
-        }
-      }
-
     }
-
+    initAutoAnnotation();
     if (jalview.bin.Cache.getProperty("DEFAULT_COLOUR") != null)
     {
       globalColourScheme = ColourSchemeProperty.getColour(alignment,
index 8e66188..3cac289 100644 (file)
@@ -24,6 +24,7 @@ import jalview.api.AlignmentViewPanel;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentView;
+import jalview.datamodel.Annotation;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceGroup;
@@ -53,6 +54,11 @@ public abstract class AlignmentViewport implements AlignViewportI
 
   protected String sequenceSetID;
 
+  /**
+   * probably unused indicator that view is of a dataset rather than an alignment
+   */
+  protected boolean isDataset = false;
+
   private Hashtable hiddenRepSequences;
 
   protected ColumnSelection colSel = new ColumnSelection();
@@ -197,6 +203,11 @@ public abstract class AlignmentViewport implements AlignViewportI
   // --------START Structure Conservation
   public void updateStrucConsensus(final AlignmentViewPanel ap)
   {
+    if (autoCalculateStrucConsensus && strucConsensus==null && alignment.isNucleotide() && alignment.hasRNAStructure())
+    {
+      
+    }
+
     // see note in mantis : issue number 8585
     if (strucConsensus == null || !autoCalculateStrucConsensus)
     {
@@ -543,6 +554,12 @@ public abstract class AlignmentViewport implements AlignViewportI
   private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
           this);
 
+  protected boolean showConservation = true;
+
+  protected boolean showQuality = true;
+
+  protected boolean showConsensus = true;
+
 
   /**
    * Property change listener for changes in alignment
@@ -1076,4 +1093,65 @@ public abstract class AlignmentViewport implements AlignViewportI
     }
   }
 
+  protected void initAutoAnnotation()
+  {
+    // TODO: add menu option action that nulls or creates consensus object
+    // depending on if the user wants to see the annotation or not in a
+    // specific alignment
+
+    if (hconsensus == null && !isDataset)
+    {
+      if (!alignment.isNucleotide())
+      {
+        if (showConservation)
+        {
+          if (conservation==null)
+        {
+        conservation = new AlignmentAnnotation("Conservation",
+                "Conservation of total alignment less than " + getConsPercGaps()
+                        + "% gaps", new Annotation[1], 0f, 11f,
+                AlignmentAnnotation.BAR_GRAPH);
+        conservation.hasText = true;
+        conservation.autoCalculated = true;
+          alignment.addAnnotation(conservation);
+        }
+        }
+        if (showQuality)
+        {
+          if (quality==null)
+          {
+          quality = new AlignmentAnnotation("Quality",
+                  "Alignment Quality based on Blosum62 scores",
+                  new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
+          quality.hasText = true;
+          quality.autoCalculated = true;
+          alignment.addAnnotation(quality);
+        }
+        }
+      } else {
+        if (alignment.hasRNAStructure())
+        {
+          strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
+                  new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
+          strucConsensus.hasText = true;
+          strucConsensus.autoCalculated = true;
+        }
+      }
+        
+      consensus = new AlignmentAnnotation("Consensus", "PID",
+              new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
+      consensus.hasText = true;
+      consensus.autoCalculated = true;
+  
+      if (showConsensus)
+      {
+        alignment.addAnnotation(consensus);
+        if (strucConsensus!=null)
+        {
+          alignment.addAnnotation(strucConsensus);
+        }
+      }
+    }
+  }
+
 }