JAL-1551 spotlessApply
[jalview.git] / src / jalview / renderer / ContactMapRenderer.java
index 0a2278b..cbc4af9 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;
@@ -24,6 +25,7 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI
 {
   /**
    * bean holding colours for shading
+   * 
    * @author jprocter
    *
    */
@@ -33,10 +35,12 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI
      * shown when no data available from map
      */
     Color no_data;
+
     /**
      * shown for region not currently visible - should normally not see this
      */
     Color hidden;
+
     /**
      * linear shading scheme min/max
      */
@@ -65,6 +69,7 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI
 
   /**
    * build an EBI-AlphaFold style renderer of PAE matrices
+   * 
    * @return
    */
   public static ContactMapRenderer newPAERenderer()
@@ -114,6 +119,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 +150,8 @@ 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 +221,17 @@ 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);
@@ -230,8 +248,8 @@ public abstract class ContactMapRenderer implements AnnotationRowRendererI
 
   Color shadeFor(float min, float max, float value)
   {
-    return jalview.util.ColorUtils.getGraduatedColour(value, 0, shade.minColor,
-            max, shade.maxColor);
+    return jalview.util.ColorUtils.getGraduatedColour(value, 0,
+            shade.minColor, max, shade.maxColor);
   }
 
   public Color getColorForRange(float min, float max, ContactListI cl,