X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Frenderer%2FResidueColourFinder.java;h=2e45117a97addbb20b908b77453ad74ee5f96981;hb=0481d6e44a06a650bfc16684e04ff1c0d8656c84;hp=99f51075c85bc61c4594581ffa933b3e357bc5f6;hpb=fb548a8458941602b0b8b45da5aaf60206e10ec2;p=jalview.git diff --git a/src/jalview/renderer/ResidueColourFinder.java b/src/jalview/renderer/ResidueColourFinder.java index 99f5107..2e45117 100644 --- a/src/jalview/renderer/ResidueColourFinder.java +++ b/src/jalview/renderer/ResidueColourFinder.java @@ -32,12 +32,32 @@ public class ResidueColourFinder { } - public Color getResidueColour(ResidueShaderI shader, + /** + * Get the colour of a residue in a sequence + * + * @param showBoxes + * true if the viewport's Show Boxes setting is true + * @param shader + * the viewport's colour scheme + * @param allGroups + * all the groups which seq participates in + * @param seq + * the sequence containing the residue + * @param position + * the position of the residue in the sequence + * @param finder + * FeatureColourFinder for the viewport + * @return colour of the residue + */ + public Color getResidueColour(boolean showBoxes, ResidueShaderI shader, SequenceGroup[] allGroups, final SequenceI seq, int position, FeatureColourFinder finder) { - Color col = getResidueBoxColour(shader, allGroups, seq, position); + Color col = getResidueBoxColour(showBoxes, shader, allGroups, seq, + position); + // if there's a FeatureColourFinder we might override the residue colour + // here with feature colouring if (finder != null) { col = finder.findFeatureColour(col, seq, position); @@ -45,36 +65,64 @@ public class ResidueColourFinder return col; } - private Color getResidueBoxColour(ResidueShaderI shader, + /** + * Get the residue colour without accounting for any features + * + * @param showBoxes + * true if the viewport's Show Boxes setting is true + * @param shader + * the viewport's colour scheme + * @param allGroups + * all the groups which seq participates in + * @param seq + * the sequence containing the residue + * @param i + * the position of the residue in the sequence + * @return + */ + protected Color getResidueBoxColour(boolean showBoxes, + ResidueShaderI shader, SequenceGroup[] allGroups, SequenceI seq, int i) { - - ResidueShaderI currentShader; - SequenceGroup currentSequenceGroup = getCurrentSequenceGroup(allGroups, i); if (currentSequenceGroup != null) { - currentShader = currentSequenceGroup.getGroupColourScheme(); + if (currentSequenceGroup.getDisplayBoxes()) + { + return getBoxColour(currentSequenceGroup.getGroupColourScheme(), + seq, i); + } } - else + else if (showBoxes) { - currentShader = shader; + return getBoxColour(shader, seq, i); } - - return getBoxColour(currentShader, seq, i); + + return Color.white; } + /** + * Search all the groups for a sequence to find the one which a given res + * falls into + * + * @param allGroups + * all the groups a sequence participates in + * @param res + * the residue to search for + * @return a sequence group for res, or null if no sequence group applies + */ public SequenceGroup getCurrentSequenceGroup(SequenceGroup[] allGroups, int res) { - if (allGroups == null) + int n; + if (allGroups == null || (n = allGroups.length) == 0) { return null; } - for (int i = 0; i < allGroups.length; i++) + for (int i = 0; i < n; i++) { if ((allGroups[i].getStartRes() <= res) && (allGroups[i].getEndRes() >= res)) @@ -90,11 +138,11 @@ public class ResidueColourFinder * DOCUMENT ME! * * @param shader - * DOCUMENT ME! + * the viewport's colour scheme * @param seq - * DOCUMENT ME! + * the sequence containing the residue * @param i - * DOCUMENT ME! + * the position of the residue in the sequence */ public Color getBoxColour(ResidueShaderI shader, SequenceI seq, int i) {