JAL-3253-applet JAL-3383
[jalview.git] / src / jalview / renderer / OverviewResColourFinder.java
index ff52f1d..b950542 100644 (file)
@@ -22,15 +22,16 @@ package jalview.renderer;
 
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
+import jalview.renderer.seqfeatures.FeatureColourFinder;
 import jalview.util.Comparison;
 
 import java.awt.Color;
 
 public class OverviewResColourFinder extends ResidueColourFinder
 {
-  final Color GAP_COLOUR; // default colour to use at gaps
+  final int GAP_COLOUR; // default colour to use at gaps
 
-  final Color RESIDUE_COLOUR; // default colour to use at residues
+  final int RESIDUE_COLOUR; // default colour to use at residues
 
   final Color HIDDEN_COLOUR; // colour for hidden regions
 
@@ -66,27 +67,19 @@ public class OverviewResColourFinder extends ResidueColourFinder
   {
     if (useLegacyColouring)
     {
-      GAP_COLOUR = Color.white;
-      RESIDUE_COLOUR = Color.lightGray;
-      HIDDEN_COLOUR = hiddenCol;
+      GAP_COLOUR = Color.white.getRGB();
+      RESIDUE_COLOUR = Color.lightGray.getRGB();
     }
     else
     {
-      GAP_COLOUR = gapCol;
-      RESIDUE_COLOUR = Color.white;
-      HIDDEN_COLOUR = hiddenCol;
+      GAP_COLOUR = gapCol.getRGB();
+      RESIDUE_COLOUR = Color.white.getRGB();
     }
+    HIDDEN_COLOUR = hiddenCol;
   }
 
-  @Override
-  public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
+  public int getBoxColourInt(ResidueShaderI shader, SequenceI seq, int i)
   {
-    seq.resetColors();
-    Color c = seq.getColor(i);
-    if (c != null)
-    {
-      return c;
-    }
     char currentChar = seq.getCharAt(i);
     // In the overview window, gaps are coloured grey, unless the colour scheme
     // specifies a gap colour, in which case gaps honour the colour scheme
@@ -94,19 +87,39 @@ public class OverviewResColourFinder extends ResidueColourFinder
     boolean isGap = Comparison.isGap(currentChar);
     if (shader.getColourScheme() == null)
     {
-      return seq.setColor(i, isGap ? GAP_COLOUR : RESIDUE_COLOUR);
+      return (isGap ? GAP_COLOUR : RESIDUE_COLOUR);
     }
-    return seq.setColor(i,
-            isGap && !shader.getColourScheme().hasGapColour() ? GAP_COLOUR
-                    : shader.findColour(currentChar, i, seq));
+    return (isGap && !shader.getColourScheme().hasGapColour() ? GAP_COLOUR
+                    : shader.findColour(currentChar, i, seq).getRGB());
   }
 
+  public int getResidueColourInt(boolean showBoxes, ResidueShaderI shader,
+          SequenceGroup[] allGroups, final SequenceI seq, int i,
+          FeatureColourFinder finder)
+  {
+
+    int c = seq.getColor(i);
+    if (c != 0)
+    {
+      return c;
+    }
+
+    int col = getResidueBoxColourInt(showBoxes, shader, allGroups, seq,
+            i);
+
+
+    // if there's a FeatureColourFinder we might override the residue colour
+    // here with feature colouring
+    return seq.setColor(i,
+            finder == null || finder.noFeaturesDisplayed() ? col
+            : finder.findFeatureColourInt(col, seq, i));
+  }
+  
   /**
-   * {@inheritDoc} In the overview, the showBoxes setting is ignored, as the
-   * overview displays the colours regardless.
+   * In the overview, the showBoxes setting is ignored, as the overview displays
+   * the colours regardless.
    */
-  @Override
-  protected Color getResidueBoxColour(boolean showBoxes,
+  protected int getResidueBoxColourInt(boolean showBoxes,
           ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
           int i)
   {
@@ -114,7 +127,7 @@ public class OverviewResColourFinder extends ResidueColourFinder
             i);
     ResidueShaderI currentShader = (currentSequenceGroup == null ? shader
             : currentSequenceGroup.getGroupColourScheme());
-    return getBoxColour(currentShader, seq, i);
+    return getBoxColourInt(currentShader, seq, i);
   }
 
   /**