Merge remote-tracking branch 'origin/develop' into
[jalview.git] / src / jalview / gui / OverviewCanvas.java
index 7d42e5e..6a7e56c 100644 (file)
@@ -3,6 +3,7 @@ package jalview.gui;
 import jalview.api.AlignViewportI;
 import jalview.datamodel.SequenceI;
 import jalview.renderer.AnnotationRenderer;
+import jalview.renderer.seqfeatures.FeatureColourFinder;
 import jalview.viewmodel.OverviewDimensions;
 
 import java.awt.Color;
@@ -159,9 +160,10 @@ public class OverviewCanvas extends JComponent
   {
     int lastcol = -1;
     int lastrow = -1;
-    int color = Color.white.getRGB();
+    int rgbcolor = Color.white.getRGB();
 
     SequenceI seq = null;
+    FeatureColourFinder finder = new FeatureColourFinder(fr);
 
     final boolean hasHiddenCols = av.hasHiddenColumns();
     boolean hiddenRow = false;
@@ -188,18 +190,18 @@ public class OverviewCanvas extends JComponent
       {
         if (doCopy)
         {
-          color = miniMe.getRGB(col, row - 1);
+          rgbcolor = miniMe.getRGB(col, row - 1);
         }
         else if ((int) (col * sampleCol) != lastcol
                 || (int) (row * sampleRow) != lastrow)
         {
           lastcol = (int) (col * sampleCol);
-          color = getColumnColourFromSequence(seq, hiddenRow,
-                  hasHiddenCols, lastcol);
+          rgbcolor = getColumnColourFromSequence(seq, hiddenRow,
+                  hasHiddenCols, lastcol, finder);
         }
         // else we just use the color we already have , so don't need to set it
 
-        miniMe.setRGB(col, row, color);
+        miniMe.setRGB(col, row, rgbcolor);
       }
     }
   }
@@ -208,36 +210,24 @@ public class OverviewCanvas extends JComponent
    * Find the colour of a sequence at a specified column position
    */
   private int getColumnColourFromSequence(jalview.datamodel.SequenceI seq,
-          boolean hiddenRow, boolean hasHiddenCols, int lastcol)
+          boolean hiddenRow, boolean hasHiddenCols, int lastcol,
+          FeatureColourFinder finder)
   {
-    int color;
+    Color color = Color.white;
 
-    if (seq == null)
+    if ((seq != null) && (seq.getLength() > lastcol))
     {
-      color = Color.white.getRGB();
-    }
-    else if (seq.getLength() > lastcol)
-    {
-      color = sr.getResidueBoxColour(seq, lastcol).getRGB();
-
-      if (av.isShowSequenceFeatures())
-      {
-        color = fr.findFeatureColour(color, seq, lastcol);
-      }
-    }
-    else
-    {
-      color = Color.white.getRGB();
+      color = sr.getResidueColour(seq, lastcol, finder);
     }
 
     if (hiddenRow
             || (hasHiddenCols && !av.getColumnSelection()
                     .isVisible(lastcol)))
     {
-      color = new Color(color).darker().darker().getRGB();
+      color = color.darker().darker();
     }
 
-    return color;
+    return color.getRGB();
   }
 
 }