JAL-516 JAL-759 JAL-1066 group & group colourscheme always gets notified when group...
[jalview.git] / src / jalview / appletgui / AlignmentPanel.java
index 99084ba..fffe55a 100644 (file)
@@ -464,7 +464,7 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
    */
   protected void validateAnnotationDimensions(boolean adjustPanelHeight) {
     boolean modified=false;
-    int height = annotationPanel.calcPanelHeight();
+    int height = av.calcPanelHeight();
     int minsize=0;
     if (hscroll.isVisible())
     {
@@ -906,67 +906,11 @@ public class AlignmentPanel extends Panel implements AdjustmentListener, Alignme
 
   public void updateAnnotation(boolean applyGlobalSettings)
   {
-    // 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 sortg = true;
-
-    // remove old automatic annotation
-    // add any new annotation
-
-    Vector gr = av.getAlignment().getGroups(); // OrderedBy(av.alignment.getSequencesArray());
-    // 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;
-        }
-      }
-    }
-    SequenceGroup sg;
-    if (gr != null)
-    {
-      for (int g = 0; g < gr.size(); g++)
-      {
-        updateCalcs = false;
-        sg = (SequenceGroup) gr.elementAt(g);
-        if (applyGlobalSettings || !oldrfs.containsKey(sg))
-        {
-          // set defaults for this group's conservation/consensus
-          sg.setshowSequenceLogo(showprf);
-          sg.setShowConsensusHistogram(showConsHist);
-        }
-        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();
+    updateAnnotation(applyGlobalSettings, false);
+  }
+  public void updateAnnotation(boolean applyGlobalSettings, boolean preserveNewGroupSettings)
+  {
+    av.updateGroupAnnotationSettings(applyGlobalSettings, preserveNewGroupSettings);
     adjustAnnotationHeight();
   }