X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Frenderer%2FOverviewResColourFinder.java;h=4cbb1ba298fb448aa8604920fbf62de913908c5d;hb=refs%2Fheads%2Fspike%2FJAL-4047%2FJAL-4048_columns_in_sequenceID;hp=8fa0e233f1d6094def9e1185ceb3cd7cf9355a01;hpb=547480978230204efda55a1ec533b7b25be2a06f;p=jalview.git diff --git a/src/jalview/renderer/OverviewResColourFinder.java b/src/jalview/renderer/OverviewResColourFinder.java index 8fa0e23..4cbb1ba 100644 --- a/src/jalview/renderer/OverviewResColourFinder.java +++ b/src/jalview/renderer/OverviewResColourFinder.java @@ -20,50 +20,61 @@ */ package jalview.renderer; +import java.awt.Color; + import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; import jalview.util.Comparison; -import java.awt.Color; - public class OverviewResColourFinder extends ResidueColourFinder { - final Color GAP_COLOUR; - - final Color RESIDUE_COLOUR; + /* + * colour for gaps (unless overridden by colour scheme) + * - as set in Preferences, _or_ read from a project file + */ + Color gapColour; - final Color HIDDEN_COLOUR; + /* + * colour for residues if no colour scheme set (before feature colouring) + * - as set in Preferences, _or_ read from a project file + */ + Color residueColour; - boolean useLegacy = false; + /* + * colour for hidden regions + * - as set in Preferences, _or_ read from a project file + */ + Color hiddenColour; + /** + * Constructor without colour settings (used by applet) + * + * @deprecated + */ + @Deprecated public OverviewResColourFinder() { - GAP_COLOUR = Color.lightGray; // new Color(240, 240, 240); - RESIDUE_COLOUR = Color.white; - HIDDEN_COLOUR = Color.DARK_GRAY.darker(); + this(Color.lightGray, Color.white, Color.darkGray.darker()); } - public OverviewResColourFinder(boolean useLegacyColouring, Color gapCol, - Color hiddenCol) + /** + * Constructor given default colours for gaps, residues and hidden regions + * + * @param gaps + * @param residues + * @param hidden + */ + public OverviewResColourFinder(Color gaps, Color residues, Color hidden) { - if (useLegacyColouring) - { - GAP_COLOUR = Color.white; - RESIDUE_COLOUR = Color.lightGray; - HIDDEN_COLOUR = hiddenCol; - } - else - { - GAP_COLOUR = gapCol; - RESIDUE_COLOUR = Color.white; - HIDDEN_COLOUR = hiddenCol; - } + gapColour = gaps; + residueColour = residues; + hiddenColour = hidden; } @Override public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i) { - Color resBoxColour = RESIDUE_COLOUR; + Color resBoxColour = residueColour; char currentChar = seq.getCharAt(i); // In the overview window, gaps are coloured grey, unless the colour scheme @@ -71,10 +82,10 @@ public class OverviewResColourFinder extends ResidueColourFinder // settings if (shader.getColourScheme() != null) { - if (!shader.getColourScheme().hasGapColour() - && Comparison.isGap(currentChar)) + if (Comparison.isGap(currentChar) + && (!shader.getColourScheme().hasGapColour())) { - resBoxColour = GAP_COLOUR; + resBoxColour = gapColour; } else { @@ -83,7 +94,7 @@ public class OverviewResColourFinder extends ResidueColourFinder } else if (Comparison.isGap(currentChar)) { - resBoxColour = GAP_COLOUR; + resBoxColour = gapColour; } return resBoxColour; @@ -95,8 +106,8 @@ public class OverviewResColourFinder extends ResidueColourFinder */ @Override protected Color getResidueBoxColour(boolean showBoxes, - ResidueShaderI shader, - SequenceGroup[] allGroups, SequenceI seq, int i) + ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq, + int i) { ResidueShaderI currentShader; SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups, @@ -113,8 +124,35 @@ public class OverviewResColourFinder extends ResidueColourFinder return getBoxColour(currentShader, seq, i); } - protected Color getHiddenColour() + /** + * Returns the colour used for hidden regions + * + * @return + */ + public Color getHiddenColour() + { + return hiddenColour; + } + + /** + * Returns the colour used for gaps, if not overridden by the alignment colour + * scheme + * + * @return + */ + public Color getGapColour() + { + return gapColour; + } + + /** + * Returns the colour used for residues (before applying any feature + * colouring) if there is no alignment colour scheme + * + * @return + */ + public Color getResidueColour() { - return HIDDEN_COLOUR; + return residueColour; } }