JAL-958 JAL-966 refactor group/alignment associated conservation, consensus and logo...
[jalview.git] / src / jalview / gui / AlignmentPanel.java
index bcdd620..ad7b995 100644 (file)
@@ -1402,66 +1402,7 @@ public class AlignmentPanel extends GAlignmentPanel implements
   }
   public void updateAnnotation(boolean applyGlobalSettings, boolean preserveNewGroupSettings)
   {
-    // TODO: this should be merged with other annotation update stuff - that
-    // sits on AlignViewport
-    boolean updateCalcs = false;
-    boolean conv = av.isShowGroupConservation();
-    boolean cons = av.isShowGroupConsensus();
-    boolean showprf = av.isShowSequenceLogo();
-    boolean showConsHist = av.isShowConsensusHistogram();
-    boolean normLogo = av.isNormaliseSequenceLogo();
-
-    boolean sortg = true;
-
-    // remove old automatic annotation
-    // add any new annotation
-
-    // intersect alignment annotation with alignment groups
-
-    AlignmentAnnotation[] aan = av.getAlignment().getAlignmentAnnotation();
-    Hashtable oldrfs = new Hashtable();
-    if (aan != null)
-    {
-      for (int an = 0; an < aan.length; an++)
-      {
-        if (aan[an].autoCalculated && aan[an].groupRef != null)
-        {
-          oldrfs.put(aan[an].groupRef, aan[an].groupRef);
-          av.getAlignment().deleteAnnotation(aan[an]);
-          aan[an] = null;
-        }
-      }
-    }
-    if (av.getAlignment().getGroups()!=null)
-    {
-      for (SequenceGroup sg:av.getAlignment().getGroups())
-      {
-        updateCalcs = false;
-        if (applyGlobalSettings || (!preserveNewGroupSettings && !oldrfs.containsKey(sg)))
-        {
-          // set defaults for this group's conservation/consensus
-          sg.setshowSequenceLogo(showprf);
-          sg.setShowConsensusHistogram(showConsHist);
-          sg.setNormaliseSequenceLogo(normLogo);
-        }
-        if (conv)
-        {
-          updateCalcs = true;
-          av.getAlignment().addAnnotation(sg.getConservationRow(), 0);
-        }
-        if (cons)
-        {
-          updateCalcs = true;
-          av.getAlignment().addAnnotation(sg.getConsensus(), 0);
-        }
-        // refresh the annotation rows
-        if (updateCalcs)
-        {
-          sg.recalcConservation();
-        }
-      }
-    }
-    oldrfs.clear();
+    av.updateGroupAnnotationSettings(applyGlobalSettings, preserveNewGroupSettings);
     adjustAnnotationHeight();
   }