JAL-4158 first attempt at stashing colours for contact matrix groups and allowing...
[jalview.git] / src / jalview / renderer / ContactMapRenderer.java
index 0a2278b..e54f471 100644 (file)
@@ -12,6 +12,7 @@ import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.ContactListI;
+import jalview.datamodel.ContactMatrixI;
 import jalview.datamodel.ContactRange;
 import jalview.datamodel.HiddenColumns;
 import jalview.renderer.api.AnnotationRowRendererI;
@@ -114,6 +115,7 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI
 
     int column;
     int aaMax = aa_annotations.length - 1;
+    ContactMatrixI cm = viewport.getContactMatrix(_aa);
     while (x < eRes - sRes)
     {
       column = sRes + x;
@@ -144,6 +146,7 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI
         x++;
         continue;
       }
+      Color gpcol = (cm==null) ? Color.white: cm.getColourForGroup(cm.getGroupsFor(column));
       // feature still in development - highlight or omit regions hidden in
       // the alignment - currently marks them as red rows
       boolean maskHiddenCols = false;
@@ -213,7 +216,14 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI
         {
           col = shade.hidden;
         }
+        if (gpcol!=null && gpcol!=Color.white) {
+          // todo - could overlay group as a transparent rectangle ?
+          col = new Color((int)(((float)(col.getRed()+gpcol.getRed()))/2f),
+                  (int)(((float)(col.getGreen()+gpcol.getGreen()))/2f),
+                  (int)(((float)(col.getBlue()+gpcol.getBlue()))/2f));
+        }
         g.setColor(col);
+        
         if (cgeom.pixels_step > 1)
         {
           g.fillRect(x * charWidth, ht, charWidth, 1 + cgeom.pixels_step);