JAL-3383 minor code tidying and commenting
[jalview.git] / src / jalview / renderer / OverviewResColourFinder.java
index e0d6696..8d7980a 100644 (file)
@@ -36,11 +36,15 @@ public class OverviewResColourFinder extends ResidueColourFinder
   public static final Color OVERVIEW_DEFAULT_HIDDEN = Color.darkGray
           .darker();
 
-  final int GAP_COLOUR; // default colour to use at gaps
+  final Color gapColour; // colour to use for gaps
 
-  final int RESIDUE_COLOUR; // default colour to use at residues
+  final int gapColourInt;
 
-  final Color HIDDEN_COLOUR; // colour for hidden regions
+  final Color residueColour; // colour to use for uncoloured residues
+
+  final int residueColourInt;
+
+  final Color hiddenColour; // colour for hidden regions
 
   boolean useLegacy = false;
 
@@ -67,21 +71,20 @@ public class OverviewResColourFinder extends ResidueColourFinder
   {
     if (useLegacyColouring)
     {
-      GAP_COLOUR = Color.white.getRGB();
-      RESIDUE_COLOUR = Color.lightGray.getRGB();
+      gapColour = Color.white;
+      residueColour = Color.lightGray;
     }
     else
     {
-      GAP_COLOUR = gapCol.getRGB();
-      RESIDUE_COLOUR = Color.white.getRGB();
+      gapColour = gapCol;
+      residueColour = Color.WHITE;
     }
-    HIDDEN_COLOUR = hiddenCol;
+    gapColourInt = gapColour.getRGB();
+    residueColourInt = residueColour.getRGB();
+    hiddenColour = hiddenCol;
   }
 
   @Override
-  /**
-   * for Test suite only.
-   */
   public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i)
   {
     return new Color(getBoxColourInt(shader, seq, i));
@@ -96,22 +99,24 @@ public class OverviewResColourFinder extends ResidueColourFinder
     boolean isGap = Comparison.isGap(currentChar);
     if (shader.getColourScheme() == null)
     {
-      return (isGap ? GAP_COLOUR : RESIDUE_COLOUR);
+      return (isGap ? gapColourInt : residueColourInt);
     }
-    return (isGap && !shader.getColourScheme().hasGapColour() ? GAP_COLOUR
+    return (isGap && !shader.getColourScheme().hasGapColour() ? gapColourInt
             : shader.findColourInt(currentChar, i, seq));
   }
 
-  /**
-   * For test suite only.
-   */
   @Override
   public Color getResidueColour(boolean showBoxes, ResidueShaderI shader,
           SequenceGroup[] allGroups, final SequenceI seq, int i,
           FeatureColourFinder finder)
   {
-    return new Color(getResidueColourInt(showBoxes, shader, allGroups, seq,
-            i, finder));
+    Color col = getResidueBoxColour(showBoxes, shader, allGroups, seq, i);
+
+    // if there's a FeatureColourFinder we might override the residue colour
+    // here with feature colouring
+    col = finder == null || finder.noFeaturesDisplayed() ? col
+            : finder.findFeatureColour(col, seq, i);
+    return col;
   }
 
 
@@ -135,9 +140,6 @@ public class OverviewResColourFinder extends ResidueColourFinder
     return seq.setColor(i, col);
   }
 
-  /**
-   * For test suite only.
-   */
   @Override
   protected Color getResidueBoxColour(boolean showBoxes,
           ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq,
@@ -169,6 +171,6 @@ public class OverviewResColourFinder extends ResidueColourFinder
    */
   protected Color getHiddenColour()
   {
-    return HIDDEN_COLOUR;
+    return hiddenColour;
   }
 }