JAL-3127 tidier tree group colour -> view propagation
authorJim Procter <jprocter@issues.jalview.org>
Mon, 19 Nov 2018 15:56:53 +0000 (15:56 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Mon, 19 Nov 2018 15:57:15 +0000 (15:57 +0000)
src/jalview/gui/TreeCanvas.java

index 67ddbd1..f1bdd31 100755 (executable)
@@ -28,8 +28,6 @@ import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.SequenceNode;
 import jalview.schemes.ColourSchemeI;
-import jalview.schemes.ColourSchemeProperty;
-import jalview.schemes.UserColourScheme;
 import jalview.structure.SelectionSource;
 import jalview.util.Format;
 import jalview.util.MessageManager;
@@ -994,54 +992,41 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
       }
 
       ColourSchemeI cs = null;
-      SequenceGroup sg = new SequenceGroup(sequences, null, cs, true, true,
+      SequenceGroup _sg = new SequenceGroup(sequences, null, cs, true, true,
               false, 0, av.getAlignment().getWidth() - 1);
 
-      if (av.getGlobalColourScheme() != null)
-      {
-        if (av.getGlobalColourScheme() instanceof UserColourScheme)
-        {
-          cs = new UserColourScheme(
-                  ((UserColourScheme) av.getGlobalColourScheme())
-                          .getColours());
-
-        }
-        else
-        {
-          cs = ColourSchemeProperty.getColourScheme(av, sg,
-                  ColourSchemeProperty
-                  .getColourName(av.getGlobalColourScheme()));
-        }
-        // cs is null if shading is an annotationColourGradient
-        // if (cs != null)
-        // {
-        // cs.setThreshold(av.getViewportColourScheme().getThreshold(),
-        // av.isIgnoreGapsConsensus());
-        // }
-      }
-      sg.setColourScheme(cs);
-      sg.getGroupColourScheme().setThreshold(
-              av.getResidueShading().getThreshold(),
-              av.isIgnoreGapsConsensus());
-      // sg.recalcConservation();
-      sg.setName("JTreeGroup:" + sg.hashCode());
-      sg.setIdColour(col);
+      _sg.setName("JTreeGroup:" + _sg.hashCode());
+      _sg.setIdColour(col);
 
       for (int a = 0; a < aps.length; a++)
       {
-        if (aps[a].av.getGlobalColourScheme() != null
-                && aps[a].av.getResidueShading().conservationApplied())
+        SequenceGroup sg = new SequenceGroup(_sg);
+        AlignViewport viewport = aps[a].av;
+
+        // Propagate group colours in each view
+        if (viewport.getGlobalColourScheme() != null)
         {
-          Conservation c = new Conservation("Group", sg.getSequences(null),
-                  sg.getStartRes(), sg.getEndRes());
-          c.calculate();
-          c.verdict(false, aps[a].av.getConsPercGaps());
-          sg.cs.setConservation(c);
+          cs = viewport.getGlobalColourScheme().getInstance(viewport, sg,
+                  null);
+          sg.setColourScheme(cs);
+          sg.getGroupColourScheme().setThreshold(
+                  viewport.getResidueShading().getThreshold(),
+                  viewport.isIgnoreGapsConsensus());
+
+          if (viewport.getResidueShading().conservationApplied())
+          {
+            Conservation c = new Conservation("Group",
+                    sg.getSequences(null), sg.getStartRes(),
+                    sg.getEndRes());
+            c.calculate();
+            c.verdict(false, viewport.getConsPercGaps());
+            sg.cs.setConservation(c);
+          }
         }
         // indicate that associated structure views will need an update
-        aps[a].av.setUpdateStructures(true);
+        viewport.setUpdateStructures(true);
         // propagate structure view update and sequence group to complement view
-        aps[a].av.addSequenceGroup(new SequenceGroup(sg));
+        viewport.addSequenceGroup(sg);
       }
     }