JAL-4134 - store colours in annotation row, so colour by annotation can be used to...
authorJames Procter <j.procter@dundee.ac.uk>
Fri, 24 Mar 2023 13:29:40 +0000 (13:29 +0000)
committerJames Procter <j.procter@dundee.ac.uk>
Fri, 24 Mar 2023 13:29:50 +0000 (13:29 +0000)
src/jalview/gui/TreeCanvas.java

index 29826f0..8de161f 100755 (executable)
@@ -54,6 +54,7 @@ import jalview.analysis.Conservation;
 import jalview.analysis.TreeModel;
 import jalview.api.AlignViewportI;
 import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.Annotation;
 import jalview.datamodel.BinaryNode;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.ContactMatrixI;
@@ -1028,6 +1029,21 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
             cm.setColorForGroup(gp, colors.get(gp));
           }
         }
+        // stash colors in linked annotation row.
+        // doesn't work yet. TESTS!
+        int sstart=aa.sequenceRef!=null ? aa.sequenceRef.getStart()-1 : 0;
+        for (BitSet gp : colors.keySet())
+        {
+          Color gpcol = colors.get(gp);
+          for (int p = gp.nextSetBit(0); p >= 0; p = gp.nextSetBit(p + 1))
+          {
+            Annotation ae = aa.getAnnotationForPosition(p+sstart);
+            if (ae != null)
+            {
+              ae.colour = gpcol.brighter().darker();
+            }
+          }
+        }
       }
     }